Skip to content

Conversation

bhouston
Copy link
Member

Add parent-to-subagent communication in agentMessage tool

Description

This PR adds bidirectional communication between parent agents and sub-agents through the agentMessage tool. Previously, parent agents could only check the output of sub-agents but couldn't communicate with them. This enhancement enables parent agents to send guidance messages to sub-agents, which are then inserted into the sub-agent's message queue.

Changes

  1. Added parentMessages array to the AgentState interface to store messages from parent agents
  2. Updated the agentMessage tool to append messages to this array when the guidance parameter is provided
  3. Modified the toolAgent core to check for parent messages on each iteration and insert them into the message queue
  4. Added appropriate return values to indicate if a message was sent and how many messages are in the queue

Testing

  • All existing tests pass
  • Manual testing confirms that messages from parent agents are received by sub-agents

Related Issues

Closes #315

How to Test

Use the agentMessage tool with the guidance parameter to send a message to a sub-agent. The sub-agent will receive the message in its next iteration and process it as if it came from the user.

Example:

const result = await agentMessage({
  instanceId: "sub-agent-id",
  guidance: "Please focus on optimizing the performance of the function",
  description: "Providing guidance to sub-agent"
});

The sub-agent will receive: "[Message from parent agent]: Please focus on optimizing the performance of the function"

@bhouston bhouston merged commit e20f001 into main Mar 18, 2025
1 check passed
Copy link

🎉 This PR is included in version mycoder-agent-v1.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add parent-to-subagent communication in agentMessage tool
1 participant