Skip to content

Conversation

@rtfeldman
Copy link
Contributor

Summary

This PR implements the core subagent execution logic:

Core subagent execution

  • Add Thread::new_subagent() constructor for creating subagent threads
  • Implement SubagentTool::run() to spawn and manage subagent lifecycle
  • Add SubagentContext for parent-child thread relationship
  • Implement submit_user_message(), interrupt_for_summary(), request_final_summary()
  • Add timeout support and context-low detection (25% threshold)
  • Propagate cancellation from parent to child threads

Thread management

  • Add MAX_SUBAGENT_DEPTH (4) and MAX_PARALLEL_SUBAGENTS (8) limits
  • Add register/unregister_running_subagent() for tracking
  • Add restrict_tools() for allowed_tools filtering
  • Add is_subagent(), depth(), is_turn_complete() accessors

ACP thread changes

  • Add ToolCallContent::SubagentThread variant
  • Add ToolCallUpdateSubagentThread for UI updates
  • Add tool_name field for subagent detection
  • Add is_subagent() method on ToolCall
  • Add image support in ContentBlock

Tests

Comprehensive test coverage for all subagent scenarios.

Part of stacked PRs

This is PR 2 of 4 for the subagents feature:

  • PR 1: Feature flag + tool skeleton
  • PR 2: Thread spawning + execution (this PR)
  • PR 3: UI card rendering
  • PR 4: Visual testing infrastructure

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jan 6, 2026
rtfeldman and others added 2 commits January 7, 2026 13:26
- Add SubagentsFeatureFlag with staff-disabled default
- Create SubagentTool with input schema for task/summary/context-low prompts
- Register SubagentTool conditionally when feature flag is enabled
- Tool returns stub message 'not yet implemented' for now

Amp-Thread-ID: https://ampcode.com/threads/T-019b94c4-0a15-7799-aba2-83a644590a2e
Co-authored-by: Amp <[email protected]>
Core subagent execution:
- Add Thread::new_subagent() constructor for creating subagent threads
- Implement SubagentTool::run() to spawn and manage subagent lifecycle
- Add SubagentContext for parent-child thread relationship
- Implement submit_user_message(), interrupt_for_summary(), request_final_summary()
- Add timeout support and context-low detection
- Propagate cancellation from parent to child threads

Thread management:
- Add MAX_SUBAGENT_DEPTH (4) and MAX_PARALLEL_SUBAGENTS (8) limits
- Add register/unregister_running_subagent() for tracking
- Add restrict_tools() for allowed_tools filtering
- Add is_subagent(), depth(), is_turn_complete() accessors

ACP thread changes:
- Add ToolCallContent::SubagentThread variant
- Add ToolCallUpdateSubagentThread for UI updates
- Add tool_name field for subagent detection
- Add is_subagent() method on ToolCall
- Add image support in ContentBlock

Comprehensive test coverage for all subagent scenarios
@SomeoneToIgnore SomeoneToIgnore added the area:ai Improvement related to Agent Panel, Edit Prediction, Copilot, or other AI features label Jan 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ai Improvement related to Agent Panel, Edit Prediction, Copilot, or other AI features cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants