Skip to content

injectInterrupt synthesizes tool results for interrupts whose agent emits the real ToolCallResult on resume #6201

Closed

Description

@manfredsteyer

@copilotkit/[email protected] / @copilotkit/[email protected]

ɵInterruptState builds toolResults for every standard interrupt carrying a toolCallId; the Angular controller adds them via agent.addMessage() before resuming. That's right for executor-less interrupt tools (defineTool({ interrupt: true }): reason "tool_call", interrupt.id === toolCallId, human response = result) — but it conflicts with the AG-UI interrupt spec for suspend/resume backends: "The agent does not re-emit ToolCallStart/ToolCallArgs/ToolCallEnd in the resumed run — it emits ToolCallResult against the original toolCallId." (e.g. Mastra resumeStream).

Result: two tool messages for one toolCallId. RenderToolCalls#getToolMessage uses find(), so the synthetic resume payload permanently shadows the real result (booking card shows {"selection":"creditCard"} → "Failed" despite success).

Proposal: gate the synthesis on interrupt.reason === "tool_call" (or interrupt.id === toolCallId). Backward-compatible: on resume the runtime already synthesizes the result server-side from input.resume when no client tool message exists (alreadyAnswered path). Alternatively an opt-out on InjectInterruptOptions. Happy to PR either.

Activity

  1. copilotkit-outpost-bot commented on Jul 28, 2026

    @copilotkit-outpost-bot

    ⚠️ This is an AI-generated response. We've escalated this to our engineering team — someone will follow up in this thread shortly.

    Thanks for the detailed report

    This is a well-structured analysis — the version numbers, the reproduction path, the spec reference, and the proposed fix are all exactly what the maintainers need. Let me be transparent about what I can and can't confirm here.

    What I can say from the docs:

    The injectInterrupt / useInterrupt docs confirm the general shape you're describing:

    What I cannot confirm:

    I haven't read the internals of ɵInterruptState, RenderToolCalls#getToolMessage, or the Angular controller's agent.addMessage() path — those identifiers don't appear verbatim in the documentation I have access to. So I can't verify the exact synthesis logic or confirm the shadowing behavior you're describing.

    On your proposal:

    One possibility is that gating toolResults synthesis on interrupt.reason === "tool_call" (or the interrupt.id === toolCallId equivalence check) would be the right scope — but whether that's the correct fix, and whether the alreadyAnswered path on the server side is a safe fallback in all runtime configurations, is a call for the engineering team to make after they've looked at the actual code paths.

    What's useful about your report as-is:

    • ✅ Specific versions pinned
    • ✅ AG-UI spec citation with the exact conflicting behavior
    • ✅ Concrete reproduction: Mastra resumeStream + defineTool without interrupt: true
    • ✅ Two concrete fix options with backward-compat reasoning
    • ✅ Offer to PR

    One thing that would strengthen it further: if you can share a minimal repro (even a stripped-down agent + component), that would let the team verify the double-message behavior directly without needing to reconstruct your Mastra setup.

    The team will need to verify the internal behavior and decide on the right gate condition — your PR offer is a great path forward once they've confirmed the approach.

    Was this helpful, or is there anything about the injectInterrupt API surface I can clarify from the docs?


    🤖 Generated by CopilotKit AI Support · Documentation


    Was this helpful? React with 👍 or 👎

  2. coderabbitai commented on Jul 28, 2026

    @coderabbitai
    Contributor
    🔗 Related PRs

    #1861 - fix: synchronously execute renderAndWaitForResponse [merged]
    #2031 - fix: use active interrupt from thread instead of saving to global state [merged]
    #2488 - fix: interrupt persistence [merged]
    #2638 - Feat/cpk 1.5 [merged]
    #5869 - docs(deepagents): add agentId parameter to useInterrupt and document state access [open]


    📝 Issue Planner

    Check the box below or use the @coderabbitai plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.

    • Create Plan

    🧪 Issue enrichment is currently in open beta.

    You can configure auto-planning by selecting labels in the issue_enrichment configuration.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord!

  3. self-assigned this
    on Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions