-
-
Notifications
You must be signed in to change notification settings - Fork 79.1k
[Feature]: Structured Callback Actions and Thread Context Inheritance for Agent Handoffs #33478
Copy link
Copy link
Open
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.enhancementNew feature or requestNew feature or requestimpact:message-lossChannel message delivery can be lost, duplicated, or misrouted.Channel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.enhancementNew feature or requestNew feature or requestimpact:message-lossChannel message delivery can be lost, duplicated, or misrouted.Channel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Summary
Harden the Agent-to-Agent handoff lifecycle by replacing fragile string-based REPLY_SKIP logic with structured tool
parameters and ensuring thread context (Reply-Chains/Topics) is preserved during the automatic "Announce" turn.
Problem to solve
Current "Autonomous Mesh" workflows (using sessions_send + REPLY_SKIP + announce) suffer from two critical failure modes:
for REPLY_SKIP to be the entire conversational response is extremely fragile. Many LLMs naturally include status
confirmations or emojis (e.g., "🎯 Result received", "Success", "Delegation complete") before or after the keyword.
Any leading or trailing text causes the gateway to treat the response as a standard message, delivering "REPLY_SKIP"
to the user or the sub agent and killing the internal "Announce" loop entirely.
Agent-to-agent announce step. turn is treated as a fresh internal turn. It loses the reply_to_message_id metadata,
resulting in synthesized reports being delivered to the "All Messages" chat base instead of the active thread.
Proposed solution
sessions_sendCallbacks: Add an optional action parameter to the sessions_send tool.agent to output a magic string. This bypasses the fragility of conversational acknowledgments.
message_thread_id (or reply_to_message_id) of the session that originally called sessions_spawn.
agents (or the system) definitive control over where the final synthesis is delivered.
Alternatives considered
as models naturally attempt to be "helpful" by confirming data receipt.
requires the agent to parse its own session key for metadata, and duplicates logic already intended for the "Announce"
step.
Impact
Evidence/examples
Observed log during context loss:
1 2026-03-03T19:18:44.161Z info [agent:nested] session=agent:main:main:thread:XXXXX:16782 channel=webchat ✅ K0RE-2
Handoff — SUCCESS
2 // Gateway missed the thread ID and defaulted to webchat/base chat because the turn originated internally.
1 Agent: 🎯 Result received. REPLY_SKIP
2 // Gateway fails to detect SKIP due to leading status text and emoji.
Additional information
This improvement would directly support the goals of the multi-agent/sub-agent workflow discussed in related issues
(e.g., #27445). Preserving backward compatibility for the legacy REPLY_SKIP string is recommended while prioritizing the
structured action parameter.