Skip to content

fix(acp): recover dropped T3 MCP tool results including send_to_user - #41314

Closed
sheetsync wants to merge 1 commit into
pingdotgg:mainfrom
sheetsync:t3/fix-send-to-user-display
Closed

sheetsync wants to merge 1 commit into
pingdotgg:mainfrom
sheetsync:t3/fix-send-to-user-display

Conversation

@sheetsync

Copy link
Copy Markdown
Contributor

Problem

On ACP providers such as Antigravity and Kiro, calling send_to_user returns "Shown to the user. Don't repeat it." to the model, yet nothing is displayed to the user on web, desktop, or mobile.

The underlying root cause affects every T3 Code MCP tool on ACP runtimes:

  • Antigravity omits rawOutput completely (agy 1.5.8+) or replaces it with a plain summary string (agy 1.3/1.4), and Kiro replaces rawOutput with { response, imageBase64Urls, message }.
  • Because send_to_user renders by reading item.output.sentMessage via sentMessageFromToolItem, every ACP t3-code.send_to_user item arrives with no sentMessage and falls into the collapsed work log instead of rendering inline.
  • The same dropped output breaks sibling T3 MCP tools on ACP runtimes: delegate_task loses taskId (so web and mobile fail to deduplicate it against its child subagent card), preview_recording_stop loses its recording id (breaking attachment retention), thread/batch tools lose summary IDs and counts, and server-side MCP errors (isError: true) look like silent successes. Previously only html_render had a per-tool workaround in McpProviderSessions.
  • In OpenCode 2 Code Mode (execute), nested send_to_user calls whose results are not returned by the script are also dropped even though nested html_render calls are recovered from metadata.toolCalls.

Change

Capture compact T3 MCP tool results once at the MCP server boundary and recover them generically in the ACP adapter (plus nested send_to_user in OpenCode 2 Code Mode), rather than adding another per-tool special case:

  • packages/shared/src/toolOutput.ts: Add compactT3McpToolOutput(toolName, value) returning the existing bounded compactDynamicToolOutput metadata (sentMessage, taskId, threadId, messageId, scheduledTaskId, status, thread, threads, linkedCount, unlinkedCount, isError) plus preview_recording_stop's id.
  • packages/provider-core/src/server/McpProviderSessions.ts: Add bounded per-thread recordToolResult / takeToolResult (capped at 64 entries per thread, cleared on session change/clear) alongside the existing html_render path/hash buffer. Matches by canonical tool name and canonical input hash (stripping Antigravity's synthetic toolSummary field that is never forwarded to T3's MCP server) with [Earlier output truncated]\n\n tail matching for truncated long string arguments such as delegate_task.task.
  • apps/server/src/mcp/McpHttpServer.ts: Add withToolResultCapture to toolkitRegistration and imageToolRegistration (skipping html_render, which keeps its own publish/cleanup lifecycle in HtmlRender). Records each thread-scoped T3 MCP call's compact output — including { isError: true } on declared, validation, or unexpected failures — synchronously in Effect.onExit before the MCP response returns to the provider.
  • packages/provider-acp/src/server/adapter.ts: Recover missing or replaced results for all resolveT3McpToolId(toolName) tools across ACP providers (Antigravity, Kiro, Grok, Fx, ACP Registry):
    • Preserves provider-reported structured output whenever present.
    • Tracks per-turn claimedToolResults and drainedToolResultIds by toolCallId so repeated completions, interleaved in_progress replays, and late-confirmed outputs followed by summary replays neither lose confirmed outputs nor steal a sibling call's recorded result.
    • Gates recovery on projectedStatus === undefined so unfinished calls synthesized at turn end do not claim unverified outputs.
    • Preserves { isError: true } when acpMcpToolCallOutput unwraps { result: { isError: true, content: [] } }.
  • packages/provider-opencode/src/server/toolItems.ts & packages/provider-opencode/src/server/v2/adapter.ts: Recover nested send_to_user calls from Code Mode metadata.toolCalls via mcpSessions.takeToolResult, deduplicating against any sentMessage already returned directly by the execute script.

Scope

Bug fix for one underlying problem: T3 MCP tool outputs lost when ACP runtimes strip or replace rawOutput (observed directly on a live Antigravity 0.1.12-nightly thread where t3-code.send_to_user and every sibling t3-code.* item persisted with output: undefined and mobile reported "t3code-sendtouser didn't work").

Related to open PR #38956 (757 commits behind main), which special-cases only send_to_user on Antigravity; this PR generalizes result capture and recovery to all T3 MCP tools at the McpHttpServer / ACP adapter boundary, includes Kiro and OpenCode 2 Code Mode, and addresses the edge cases noted in #38956's review threads (interleaved in_progress replays, late-reported outputs before summary replays, turn-end projectedStatus gating, and unwrapped empty-content error markers). No client UI or contract changes were needed because web, desktop, mobile, and guest timelines already project sentMessageFromToolItem once output.sentMessage is present.

Verification

  • Live reproduction evidence: Inspected the persisted SQLite turn item for the failing Antigravity 0.1.12-nightly run (toolName: "t3-code.send_to_user", status: "completed", inline_work_output: 1, input: { message, toolSummary }, output: undefined), along with 30 sibling t3-code.* items in the same thread that all persisted with output: NULL.
  • Behavioral end-to-end & adapter tests:
    • apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts (36 passed): drives real send_to_user calls through McpHttpServer.layerMessageToolkit into AntigravityAdapterV2 and asserts on emitted turn items across agy 1.5.x output-less completions with toolSummary, back-to-back identical messages with interleaved in_progress + summary replays, unpublished calls, failed/retried calls, MCP validation errors (isError: true), unwrapped empty-content errors, late-confirmed outputs followed by summary replays, unfinished turn-end projected calls, truncated delegate_task prompts (taskId), and preview_recording_stop (id).
    • apps/server/src/orchestration-v2/Adapters/KiroAdapterV2.test.ts (22 passed): verifies @t3-code/send_to_user recovers sentMessage when Kiro replaces rawOutput with plain confirmation text.
    • apps/server/src/orchestration-v2/Adapters/OpenCode2AdapterV2.test.ts (195 passed): verifies Code Mode execute scripts sending two send_to_user messages (returning the first, discarding the second) render both without duplication.
    • apps/server/src/mcp/toolkits/core.test.ts (31 passed): verifies withToolResultCapture records compact outputs for send_to_user (matching with Antigravity's extra toolSummary) and records { isError: true } on InvalidParams.
    • packages/shared/src/toolOutput.test.ts (13 passed): verifies sentMessageFromToolItem across mcp__t3-code__send_to_user, t3-code.send_to_user, t3-code-thread_1_send_to_user, send_to_user, and execute.
    • apps/server/src/htmlRender/HtmlRender.test.ts (13 passed, 3 skipped without headless shell): confirms existing html_render recovery is unaffected.
  • Checks: vp run check:changed passed (format, lint, knip 1/2 & 2/2, graphql, typecheck across 37 packages, and 347/347 tests across 8 files).
  • Not shown: Live end-to-end Antigravity + mobile UI screenshot capture against a rebuilt nightly binary; web/mobile rendering of sentMessageFromToolItem is unchanged and covered by existing web/mobile timeline tests.

Written with Gemini 4 Neon in T3 Code (Antigravity harness).

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Nov 23, 2026
@juliusmarminge

Copy link
Copy Markdown
Member

Thanks for this. T3 Code's ACP Registry support follows the ACP spec: the code every agent shares takes no changes that are specific to one agent, and the special cases already there are not a precedent for more (how providers are integrated).

The result-capture mechanism is broadly reusable, but its shared input matcher also strips Antigravity’s synthetic toolSummary argument and expands Antigravity’s marked-tail truncation workaround beyond HTML. That carries provider-specific handling into the shared ACP recovery path, contrary to the integration policy.

Please report the altered arguments to Antigravity’s maintainer with a minimal transcript: ACP defines rawInput as the input actually sent to the tool in its Tool Calls section. The generic result capture and OpenCode recovery can come back without those conventions; any Antigravity normalization should stay in its existing dedicated driver.

If Antigravity is not following the ACP spec here, the fix belongs with Antigravity: please file an issue with its maintainers and include a minimal ACP transcript that shows the behaviour and the section of the spec it breaks. Once it follows the spec, T3 Code needs no special case.

Closing.

@sheetsync

Copy link
Copy Markdown
Contributor Author

Cheers, will do

@sheetsync

Copy link
Copy Markdown
Contributor Author

Hopefully Google will fix - this is an annoying one. Messages from agents to T3 during conversations get swallowed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants