Closed
Description
Transform subAgent tool into agentStart and agentMessage tools
Problem Statement
Currently, the subAgent tool creates a sub-agent that runs autonomously until completion. This can lead to sub-agents getting off task and wasting time, as there's no way for the parent agent to monitor or intervene in the sub-agent's execution.
Proposed Solution
Transform the subAgent tool into two separate tools similar to how shellStart and shellMessage work:
-
agentStart: Starts a sub-agent and immediately returns an instance ID
- Does not wait for any timeout before returning (unlike shellStart)
- Returns immediately so the parent agent can continue execution
-
agentMessage: Bidirectional communication with a running sub-agent
- Get the current state/output of the sub-agent
- Send instructions or guidance to the sub-agent
- Optionally terminate the sub-agent
Benefits
- Parent agents can monitor sub-agent progress in real-time
- Parent agents can provide guidance or correction if sub-agents get off track
- Multiple sub-agents can run in parallel with parent supervision
- Improved efficiency by preventing sub-agents from wasting time on unproductive paths
Requirements
agentStart Tool
- Similar parameters to the current subAgent tool
- Returns an instance ID and initial state immediately
- Maintains a global map of running sub-agents (similar to processStates in shellStart)
- Sub-agent execution happens asynchronously
agentMessage Tool
- Takes an instance ID parameter to identify which sub-agent to interact with
- Allows getting the current state/output of the sub-agent
- Optionally allows sending guidance or instructions to the sub-agent
- Optionally allows terminating the sub-agent
Implementation Notes
- Keep the existing subAgent tool for backward compatibility and comparison
- Create a new implementation that uses the same toolAgent core but in an asynchronous manner
- Ensure proper cleanup of resources when sub-agents complete or are terminated
Acceptance Criteria
- New agentStart and agentMessage tools implemented
- Existing subAgent tool maintained for backward compatibility
- Documentation updated to explain both approaches
- Tests added for the new tools
- Example usage provided in documentation