GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(opencode): add message tool for agent-to-agent communication by iceteaSA · Pull Request #32192 · anomalyco/opencode

Conversation

@iceteaSA

@iceteaSA iceteaSA commented Jun 13, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Issue for this PR

Related to #19215 (agent-team coordination). This PR doesn't implement that whole proposal — it adds the smaller parent↔child messaging primitive it depends on.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds a message tool so a subagent can talk to the agent that spawned it, instead of only being able to ask the human (question). A subagent can ask its parent a question and block for the answer, or send a fire-and-forget update; the parent answers with the same tool. Off by default behind OPENCODE_EXPERIMENTAL_AGENT_MESSAGING.

The tricky part is that during a foreground task the parent's turn is parked waiting on the Task tool result, so there's no live parent turn to answer — and if the child also blocks waiting on the parent, they deadlock.

The fix reuses machinery that already exists rather than adding a new session state. When a subagent sends to its parent, it wakes the parent's parked task wait through a new background-job channel (background.message() / waitForMessage()), and parks on a reply Deferred held by a small per-instance Messaging service that's a near-copy of the existing Question service. Waking the parent returns the message (plus the child's task_id) out of the task tool; the parent replies with message(target:"subagent", task_id, …), which resolves the Deferred and the child continues. The child's later completion is delivered by the existing background-subagent inject path. This is why there's no loop change: the only edit to existing control flow is adding a third arm to the task await race (waitForMessage) next to wait/waitForPromotion.

Why it doesn't deadlock or hang: the message channel is deliberately separate from the promotion channel (it sets its own metadata.messaged marker, not background, so waitForPromotion's short-circuit can't race it). A parked reply is always bounded by a timeout (default 300s → the child proceeds without an answer), and cancelling either session cancels the child's background job and interrupts the parked fiber via the existing finalizer. If there's no parent at all (top-level/headless), the tool fails fast instead of blocking.

Security: reply only resolves a pending entry when the caller is the parent recorded at send time, and task_id resume in the task tool now checks the target is actually the caller's child — otherwise an agent that guessed a session id could drive or inject into someone else's subagent. Bodies are XML-escaped into their frame and size-capped; there's a per-child in-flight cap and a cumulative round-trip cap so a child can't spin the parent.

Sibling↔sibling is parent-mediated only for now (the parent relays); the registry is keyed by session id so direct edges can be added later.

Visible transcript markers (TUI). Messages were previously injected as synthetic parts — the model saw them, but the human watching the TUI saw nothing. Each message flow now also writes a distinct, non-synthetic ✉ marker into the relevant transcript so the user can follow what's happening: the recipient sees the incoming message/reply (✉ Message from subagent, ✉ Reply from parent) and the sender sees an echo of what it sent (✉ Sent to parent, ✉ Replied to subagent). The marker is additive — the model still receives the original <agent_message> frame; the marker is a separate part tagged via metadata.message and rendered as its own muted row (the same mechanism used for subagent-interrupt's markers). Bodies are XML-escaped in the marker too.

How did you verify your code works?

New tests (no mocks): request/reply, fire-and-forget, no-parent fail-fast, reply timeout, parent/child authorization, the abuse caps, a concurrent-send race, body escaping, the new background-job channel, the task_id parentage check, an integration test across the channel + reply seam, and the visible-marker flows (each direction/peer, with frame-breakout bodies asserted escaped, plus the Channel-A parked-parent marker).

  • cd packages/opencode && bun test → 3003 pass, 0 fail (22 skip, 1 todo)
  • cd packages/core && bun test → the failures on this branch also fail on a clean dev checkout (DB-migration sync, file-picker model/variant, SessionRunnerLLM Location, ripgrep git metadata, env-var plugin tests, locked edit/write schema docstrings); this branch adds no new failures
  • bun typecheck clean in packages/opencode and packages/tui; regenerated the SDK with ./packages/sdk/js/script/build.ts
  • rebased onto the current dev

Screenshots / recordings

UI change — the visible ✉ message markers in the subagent/parent transcript:

Subagent → parent

image

Parent → subagent (reply)

image

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Jun 13, 2026
@github-actions

github-actions Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iceteaSA
iceteaSA force-pushed the agent-messaging branch 2 times, most recently from ce6ddf7 to a430df0 Compare June 15, 2026 11:04
@iceteaSA iceteaSA mentioned this pull request Jun 16, 2026
feat(opencode): coordinator-messaging — sibling/coordinator subagent communication #32517
Closed
3 of 6 tasks
@iceteaSA
iceteaSA force-pushed the agent-messaging branch from cfc34ca to 146c8ed Compare June 17, 2026 12:01
@iceteaSA iceteaSA mentioned this pull request Jun 17, 2026
feat(opencode): session-to-session messaging — communicate between two running sessions #32693
Closed
3 tasks done
@github-actions github-actions Bot mentioned this pull request Jun 17, 2026
Allow all file attachments #32732
Closed
@iceteaSA
iceteaSA force-pushed the agent-messaging branch from 146c8ed to def31ba Compare June 26, 2026 19:33
@iceteaSA
iceteaSA force-pushed the agent-messaging branch from def31ba to a85a8d4 Compare July 2, 2026 11:16
@iceteaSA iceteaSA mentioned this pull request Jul 5, 2026
feat(opencode): task signals — structured returns, terse completion, sparse context, wake-on-message #35400
Closed
3 tasks done
iceteaSA added 12 commits July 8, 2026 22:33
@iceteaSA
feat(core): add background-job message channel
a75faa4
@iceteaSA
feat(opencode): add Messaging service for agent-to-agent replies
06ab4c3
@iceteaSA
fix(opencode): forward background-job message channel through wrapper
439a90e
@iceteaSA
fix(opencode): make agent-messaging send/message interruption-safe
bddb371
@iceteaSA
feat: add experimentalAgentMessaging flag and message permission key
598eb67
@iceteaSA
feat(opencode): add message tool
40f59d5
@iceteaSA
feat(opencode): register message tool and yield subagent messages to …
ae659cc
…parent
@iceteaSA
fix(opencode): harden agent messaging (authz, send race, body escapin…
474bd45
…g, delivery errors)
@iceteaSA
fix(opencode): close send publish interruption window; add messaging …
5b28bf8
…integration test
@iceteaSA
chore(sdk): regenerate for agent messaging
06e8046
@iceteaSA
feat(tui): visible transcript markers for agent messages
8bce86a
@iceteaSA
fix(opencode): make agent-message markers incoming-only
3ae0eaf
The sender-echo markers duplicated information already shown by the
message tool call itself (✉ Sent to parent / ✉ Replied to subagent sat
right under the visible tool call), and the subagent's "Reply from
parent" marker was written twice — once by the parent's reply branch and
again by the subagent's own send path.

Keep only the incoming markers: the parent sees "✉ Message from
subagent", the recipient subagent sees "✉ Reply from parent", each once.
Drop the now-unused marker direction field.
iceteaSA added 4 commits July 8, 2026 22:33
@iceteaSA
fix: adapt agent-messaging to current dev APIs
125d69d
@iceteaSA
refactor(schema): move messaging events to the event manifest
5c453d2
@iceteaSA
chore(sdk): regenerate
cbce310
@iceteaSA
fix(opencode): repair message test layer composability for dev APIs
ec598cb
@iceteaSA
iceteaSA force-pushed the agent-messaging branch from a85a8d4 to ec598cb Compare July 8, 2026 21:19
@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot closed this Jul 13, 2026
@github-actions github-actions Bot added the automated-pr-cleanup label Jul 13, 2026
@iceteaSA

iceteaSA commented Jul 25, 2026

Copy link
Copy Markdown
Author

Still active — requesting reopen.

Rebased onto dev@5e2a625 today, conflict-free. The stack this anchors gates clean at its tip: 3322 tests, 0 failures, typecheck clean.

Worth flagging for the cleanup pass: this is the base of a five-PR stack — #32425 → #32517 → #32693 → #35400 all build on it. #32425 and #35400 are still open, so the chain now has open PRs sitting on a closed base.

It has been kept current with dev on a roughly weekly cadence since it was opened. Happy to split or squash it if that makes review easier.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Jul 26, 2026
feat(opencode): add message tool for agent-to-agent communication #38942
Closed
feat(opencode): coordinator-messaging — sibling/coordinator subagent communication #38943
Closed
randomvariable added a commit to randomvariable/opencode that referenced this pull request Aug 3, 2026
@randomvariable @claude
feat(opencode): add message tool for agent-to-agent communication
9e80f3d
Add an experimental `message` tool (behind OPENCODE_EXPERIMENTAL_AGENT_MESSAGING)
for agent-to-agent communication: a subagent can message its parent (blocking
for a reply by default, or fire-and-forget) and a parent can reply to a parked
subagent. Adds a Messaging service (round-trip caps, anti-abuse, parent-authz,
timeouts), a BackgroundJob message channel to wake a foreground-parked parent,
a `message` permission, XML-escaped transcript markers surfaced in the TUI, and
task-tool parentage authorization on task_id resume.

Ported from anomalyco#32192 (adapted for the Effect layer; merged with the prior
task.ts model-override and slug-resume changes).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
randomvariable added a commit to randomvariable/opencode that referenced this pull request Aug 3, 2026
@randomvariable @claude
feat(opencode): interrupt a running subagent — steer / cancel / abort
cd4f0a2
Add an experimental subagent-interrupt capability (behind
OPENCODE_EXPERIMENTAL_SUBAGENT_INTERRUPT): an Interrupt service with
pending/terminal state, task_steer/task_cancel/task_abort tools (gated by a
new `interrupt` permission), a POST /session/:id/interrupt endpoint, and a
turn-boundary consume in the prompt loop that injects an escaped steer/cancel
frame plus a visible transcript marker. Cancel records a terminal reason and
force-breaks after a grace window; abort writes a marker, records the
terminal, and cancels the BackgroundJob immediately. The TUI gains an
esc-with-reason flow, footer button, and distinct interrupt markers.

Ported from anomalyco#32425 (adapted for the Effect layer; merged with the prior
task.ts/registry.ts/prompt.ts changes from anomalyco#29447/anomalyco#32122/anomalyco#12520/anomalyco#32192/anomalyco#19961).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This was referenced Sep 28, 2026
[FEATURE]: A subagent cannot ask the agent that spawned it a question #38963
Closed
[FEATURE]: Sibling subagents cannot talk to each other without routing through the parent #38964
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

automated-pr-cleanup

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@iceteaSA
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.