Skip to content

fix(sendmessage): accept subagent names and agent ids with agent teams off - #298

Draft
jay23606 wants to merge 2 commits into
GoDiao:mainfrom
jay23606:pr-go/272-harness-sendmessage-should-accept-subage
Draft

jay23606 wants to merge 2 commits into
GoDiao:mainfrom
jay23606:pr-go/272-harness-sendmessage-should-accept-subage

Conversation

@jay23606

@jay23606 jay23606 commented Nov 21, 2026 •

Copy link
Copy Markdown

Problem

The Agent tool tells the model to continue a subagent with SendMessage and its id. With agent teams off, SendMessage's input check rejected anything but session:<id>, so the routing that queues a message to a running subagent or resumes a stopped one never ran.

Change

  • A shared resolver maps an agent id or registered background-agent name to the same subagent id for both validation and routing.
  • With agent teams off, only plain-text messages may target a subagent; structured protocol messages remain rejected.
  • The SendMessage recipient description, validation error and tool prompt explain how to address a background agent. Teammate names and * still require agent teams.
  • Added tests for structured-message rejection, delivery by registered name and resuming from the transcript when the task has been evicted.
  • Updated the T-TOOL-01 status and changelog.

Testing

  • git diff --check passes.
  • After bun install --frozen-lockfile in vendor/showai, bun test src/tools/SendMessageTool --randomize --seed=1 from the repository root passed: 28 tests, 0 failures (Bun 1.4.5).

Fixes #272

@jay23606
jay23606 marked this pull request as ready for review November 21, 2026 19:21

@GoDiao GoDiao left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jay23606, and welcome to DreamCoder! The main fix is right. With agent teams off, a plain-text message to an agent id now reaches the subagent: queued while it runs, resumed when it has stopped, resumed from the transcript when its task is gone, and a well-formed id that doesn't exist gets success: false. The new Agent wording is accurate, since only background agents started with a name are registered. Behaviour with agent teams on is unchanged. We ran bun test SendMessageTool here without a stub preload: 25 pass, also in shuffled order, and 4 of the new tests fail with the base code. A few things before we merge.

Should fix

1. Structured messages now pass validation too, and the model gets a false "sent". isSubagentReference (SendMessageTool.ts:56-58) accepts any to that looks like an agent id or a registered name, whatever the message is. call() only routes to a subagent when the message is a string (:789). With agent teams off (the desktop default), the input schema still offers shutdown_request, so a model that wants to stop a background subagent can send

{ "to": "a1234567890abcdef", "message": { "type": "shutdown_request" } }

Before this PR, validation rejected it. Now it passes, call() skips the subagent branch and reaches handleShutdownRequest (:875-876), which writes the request to a team inbox nobody reads and returns "Shutdown request sent". The subagent keeps running.

The check also duplicates the resolution in call(): validation uses toAgentId(to) !== null || agentNameRegistry.has(to), routing uses agentNameRegistry.get(to) ?? toAgentId(to). Please put the resolution in one helper that both use, accept a subagent reference only when the message is a string, and add a test that a structured message to an agent id is still rejected with agent teams off.

2. SendMessage's own text still says only session addresses work. With agent teams off, the to description (describeRecipient, :60-62), the validation error (:667) and the tool prompt describe only session:<id>, while the Agent tool now tells the model to pass the agent's id. A model that reads SendMessage's description will keep using session addresses, and one that gets an id slightly wrong is told to use a session address. Please mention agent ids, and names of background agents started with one, in all three when agent teams are off. T-TOOL-01 in docs/features/harness/prompt/tools.md lists these as part of the fix.

3. Docs and CHANGELOG.

  • docs/features/harness/prompt/tools.md:66 still reads "状态:维护者已定(2026-11-18):…". Fixed findings carry a status line like - 状态:已修复(#NNN):…; please change it to - 状态:已修复(#298): followed by what changed. Line 72, which you mentioned, is in the "现状" part that records the behaviour before the fix, so it stays as it is.
  • The CHANGELOG entry should reference the PR and end with a thank-you, like the other external entries: (#298). Thanks @jay23606. Please also word it as what the user sees, for example "The agent can continue a subagent it started when agent teams are off".

Notes

  • Please drop the "Regression test: untested: CONTRIBUTING does not mention tests" line from the PR description; it contradicts the tests the PR adds.
  • Two paths have no test yet: delivery by name through call() (the name case is only validated), and resuming a subagent whose task has been removed. Worth adding while you're in the file.

Signed-off-by: jay23606 <4602056+jay23606@users.noreply.github.com>
@jay23606
jay23606 marked this pull request as draft November 22, 2026 05:04
@jay23606

Copy link
Copy Markdown
Author

No change this round: the structured-message check, the shared subagent resolver, the recipient, validation and prompt wording, the tools.md status line, and the CHANGELOG ending "(#298). Thanks @jay23606." were already in place, and the subagent tests cover a structured message to an agent id. The request after "Please also word" is cut off, so the CHANGELOG sentence is unchanged.

This branch has not been deployed

No deployments
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.

Harness: SendMessage should accept subagent names and ids when agent teams are off

2 participants