feat(agent): add Swarm child lifecycle controls - #2399
Merged
Conversation
Use seconds for the wait timeout with a 30-minute default and minimum. Remove caller-selected wait modes so AgentWait consistently waits for all selected tasks, while retaining tolerant task ID parsing.
Add concise response, file-link, and formatting guidance to the Ultra mode prompt so generated answers expose navigable workspace references consistently.
Add AgentList for inspecting direct child agent status and AgentDelete for permanently removing one or more direct child subtrees. - Preserve latest status independently of AgentWait consumption - Validate direct-child ownership before deletion - Cancel and drain active work before removing session data - Expose both tools only to Ultra and SwarmPlanner
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
AgentWaitto use seconds, enforce all-task waiting, and use a30-minute default and minimum timeout.
AgentListfor inspecting the latest status of direct child agents.AgentDeletefor permanently deleting one or more direct child agentsubtrees after cancelling and draining active work.
references.
Type and Areas
Type:
Feature / refactor / docs / test
Areas:
Rust core, Agent coordination, tool contracts, built-in Agent prompts
Motivation / Impact
Swarm planners previously lacked dedicated tools for inspecting and permanently
removing their direct child agents. They could interrupt active work, but could
not clean up obsolete agent sessions and descendant subtrees.
This PR adds explicit child lifecycle controls:
AgentListreports each direct child's latest background-task status.Consuming a result through
AgentWaitdoes not remove it from this view.AgentDeletevalidates all requested IDs as direct children before deletion,cancels and drains active work, then removes each selected subtree in
postorder.
AgentDelete.agent_idsis exposed as a required string array while runtimeparsing also tolerates a single string.
AgentWaitnow has a narrower contract:timeout_secondsreplacestimeout_ms.wait_modeis removed and behavior is alwaysall.bg_task_idsis required by the schema, while missing or empty values remaintolerated by runtime parsing.
Verification
Passed:
cargo check -p bitfun-core --no-default-features --features agent-runtimecargo test -p bitfun-core --no-default-features --features agent-runtime --lib agentic::coordination::coordination_store::tests::direct_child -- --nocapturecargo test -p bitfun-core --no-default-features --features agent-runtime --lib agentic::tools::implementations::agent_delete_tool::tests -- --nocapturecargo test -p bitfun-core --no-default-features --features agent-runtime --lib agentic::tools::implementations::agent_ -- --nocapturecargo test -p bitfun-core --no-default-features --features agent-runtime --lib agentic::agents::registry::tests::agent_list_and_delete_are_exposed_only_to_swarm_planners -- --nocapturecargo test -p bitfun-tool-packs --features basiccargo test -p bitfun-agent-content --test prompt_catalog_contractsgit diff --checkNot run:
built-in prompts only.
statically through the existing session-owned storage binding path.
The focused Core test builds emitted existing unrelated unused-import and
dead-code warnings.
Reviewer Notes
AgentWaitschema change is intentionally not backward compatible:timeout_msandwait_modeare no longer accepted.AgentDeleteis destructive and cascading. It differs fromAgentInterrupt, which stops active work while retaining the agent session.deletion. A runtime failure after deletion begins may still produce a partial
result and is returned as an error rather than reported as success.
persisted Swarm tree.
Checklist