Skip to content

Graceful shutdown on Ctrl-C #355

@bug-ops

Description

@bug-ops

Problem

Currently Ctrl-C breaks the agent loop immediately with no cleanup:

  • No farewell message to the user
  • MCP servers left orphaned (shutdown_all() exists but is never called)
  • Mid-stream LLM responses are not cancelled — process hangs until the stream finishes

Scope

  1. Add Agent::shutdown() method with MCP cleanup and farewell message
  2. Call agent.shutdown() in main.rs after run() returns
  3. Cancel-aware streaming loops (wrap stream.next() with tokio::select! on shutdown signal)

Files

  • crates/zeph-core/src/agent/mod.rs
  • crates/zeph-core/src/agent/streaming.rs
  • src/main.rs

Reuse

  • McpManager::shutdown_all() at crates/zeph-mcp/src/manager.rs:190
  • shutdown_signal() helper at crates/zeph-core/src/agent/mod.rs:803

Metadata

Metadata

Assignees

No one assigned

    Labels

    epicMilestone-level tracking issue

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions