feat: sub-agent background execution, TUI panel, and CLI commands (M28-E/F/G)#737
Merged
feat: sub-agent background execution, TUI panel, and CLI commands (M28-E/F/G)#737
Conversation
M28-E: Replace stub spawn() with actual LLM loop running as background tokio task. Add poll_subagents() to Agent<C> for collecting results and shutdown_all() for graceful teardown. Switch tool_executor from Box to Arc<dyn ErasedToolExecutor> to allow cloning into spawned tasks. M28-F: Add SubAgentMetrics to MetricsSnapshot. Create sub-agents TUI widget with color-coded states. Extend AppLayout to 4 side panels. M28-G: Add /agent CLI commands (list, spawn, bg, status, cancel, approve, deny) parsed in Agent<C>::handle_agent_command(). Wire poll_subagents() completion notifications to the user channel.
01cfa07 to
0bb9205
Compare
This was
linked to
issues
Feb 21, 2026
Closed
Add 12 unit tests covering all /agent CLI command paths: list, spawn, bg, status, cancel, approve/deny, and unknown subcommands. Add definitions_mut() to SubAgentManager for test-time definition injection.
HIGH: - manager: LLM failure transitions to TaskState::Failed - manager: 2-turn tool call loop with ToolOnceExecutor mock - manager: collect() on running task completes within timeout - def: CRLF line endings parsed correctly (fix: normalize \r\n before toml::from_str) MEDIUM: - filter: proptest panic-safety and correctness for glob_match - channel: Cancel and ArtifactUpdate variant round-trip - grants: partial sweep keeps non-expired grants - grants: duplicate grant for same key tracked independently - manager: concurrency slot freed after cancel allows new spawn - manager: statuses() does not include collected task
Add crates/zeph-core/src/subagent/command.rs with AgentCommand enum (List, Spawn, Background, Status, Cancel, Approve, Deny) and AgentCommand::parse() that validates input and returns typed errors via SubAgentError::InvalidCommand. All argument validation moves into parse() — handle_agent_command() now takes AgentCommand, not &str. Add 16 unit tests on AgentCommand::parse() covering all valid commands, missing args, unknown subcommand, empty input, and extra whitespace.
Extend parse() to accept known_agents parameter and handle both /agent commands and @agent_name mentions through a single entry point. Consolidate duplicate parse paths in Agent<C> main loop.
Remove channel.rs (A2aMessage, OrchestratorHalf, AgentHalf) — unused mpsc-based A2A channel machinery that was dead code since sub-agents communicate via watch/JoinHandle/CancellationToken. Clean all references from manager.rs and mod.rs. Rewrite docs/src/advanced/sub-agents.md with progressive disclosure: quick start, commands, definitions, security, then internals. Replace ASCII diagrams with mermaid.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SubAgentManager::spawn(). Agent runs as background tokio task with cancellation support. Addedpoll_subagents()toAgent<C>for collecting results,shutdown_all()for graceful teardown. Switchedtool_executortoArc<dyn ErasedToolExecutor>for cloneability into spawned tasks.SubAgentMetricstoMetricsSnapshot. Newzeph-tuisub-agents widget with color-coded states (working=yellow, completed=green, failed=red, input_required=cyan). ExtendedAppLayoutto 4 side panels (25% each)./agentCLI commands inAgent<C>:list,spawn,bg,status,cancel,approve,deny. Completion notifications forwarded to user channel viapoll_subagents().Test plan
cargo +nightly fmt --check— passedcargo clippy --workspace -- -D warnings— 0 warningscargo nextest run --workspace --lib --bins— 2343 passed, 9 skipped, 0 failedshutdown_all_cancels_all_active_agents,cancellation_token_stops_agent_loop,max_turns_terminates_agent_loop