Skip to content

feat(agent): add Swarm child lifecycle controls - #2399

Merged
wsp1911 merged 3 commits into
GCWing:1.0.0-explorefrom
wsp1911:ultra
Aug 20, 2026
Merged

feat(agent): add Swarm child lifecycle controls#2399
wsp1911 merged 3 commits into
GCWing:1.0.0-explorefrom
wsp1911:ultra

Conversation

@wsp1911

@wsp1911 wsp1911 commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Simplify AgentWait to use seconds, enforce all-task waiting, and use a
    30-minute default and minimum timeout.
  • Add AgentList for inspecting the latest status of direct child agents.
  • Add AgentDelete for permanently deleting one or more direct child agent
    subtrees after cancelling and draining active work.
  • Expose the new lifecycle tools only to Ultra and SwarmPlanner.
  • Refine Ultra response guidance for concise answers and clickable file
    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:

  • AgentList reports each direct child's latest background-task status.
    Consuming a result through AgentWait does not remove it from this view.
  • AgentDelete validates all requested IDs as direct children before deletion,
    cancels and drains active work, then removes each selected subtree in
    postorder.
  • AgentDelete.agent_ids is exposed as a required string array while runtime
    parsing also tolerates a single string.
  • Delete permission intents are scoped to every selected agent.

AgentWait now has a narrower contract:

  • timeout_seconds replaces timeout_ms.
  • The default and minimum timeout are 30 minutes.
  • wait_mode is removed and behavior is always all.
  • bg_task_ids is required by the schema, while missing or empty values remain
    tolerated by runtime parsing.

Verification

Passed:

  • cargo check -p bitfun-core --no-default-features --features agent-runtime
  • cargo test -p bitfun-core --no-default-features --features agent-runtime --lib agentic::coordination::coordination_store::tests::direct_child -- --nocapture
    • 2 passed
  • cargo test -p bitfun-core --no-default-features --features agent-runtime --lib agentic::tools::implementations::agent_delete_tool::tests -- --nocapture
    • 4 passed
  • cargo test -p bitfun-core --no-default-features --features agent-runtime --lib agentic::tools::implementations::agent_ -- --nocapture
    • Agent lifecycle tool tests passed
  • cargo 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 -- --nocapture
    • 1 passed
  • cargo test -p bitfun-tool-packs --features basic
    • 11 passed
  • cargo test -p bitfun-agent-content --test prompt_catalog_contracts
    • 5 passed
  • git diff --check

Not run:

  • UI interaction validation, because the changes affect backend tools and
    built-in prompts only.
  • Remote runtime scenarios. Remote session storage behavior was reviewed
    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

  • The AgentWait schema change is intentionally not backward compatible:
    timeout_ms and wait_mode are no longer accepted.
  • AgentDelete is destructive and cascading. It differs from
    AgentInterrupt, which stops active work while retaining the agent session.
  • Batch deletion validates all requested direct-child IDs before beginning
    deletion. A runtime failure after deletion begins may still produce a partial
    result and is returned as an error rather than reported as success.
  • No database migration is required. Direct-child ownership uses the existing
    persisted Swarm tree.
  • Rollback can be performed by reverting these three commits.

Checklist

  • This PR is focused and does not include secrets, temporary prompts, generated scratch files, or unrelated artifacts.
  • Relevant verification is recorded above, or skipped checks are explained.
  • User-facing strings, docs, and locales are updated where applicable.

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
@wsp1911
wsp1911 merged commit 42d86b4 into GCWing:1.0.0-explore Aug 20, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant