fix(mcp): stop the model restating results a chart already renders - #96020
Draft
GeneralistDev wants to merge 2 commits into
Draft
fix(mcp): stop the model restating results a chart already renders#96020GeneralistDev wants to merge 2 commits into
GeneralistDev wants to merge 2 commits into
Conversation
Inline-exec UI-app hosts (PostHog Desktop, Claude Code, Cowork) mount an interactive chart from a tool result's `_meta.ui.resourceUri` entirely on the client side. The model never learns whether that mount succeeded, so it still writes its own final answer from the compact formatted table it was handed — duplicating, in prose, the same data the chart already shows. Appends a short footer to that response's text telling the model a chart is already visible and to summarize instead of repeating the full results. Scoped to exactly the case where a chart will actually render (gated on the same flag the exec wrapper sets only for that branch), so it can't tell a client with no chart that one exists. Generated-By: PostHog Desktop Task-Id: 7a47c916-8e28-4157-9782-3ed394d68232
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
Contributor
🤖 CI report✅ Trunk lane — non-backend lane (
|
The exec wrapper now appends UI_RESOURCE_RENDERED_HINT to the text channel when a chart renders, which the three suppressStructuredContentForFormattedResults assertions didn't account for. Generated-By: PostHog Desktop Task-Id: 7a47c916-8e28-4157-9782-3ed394d68232
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
People using an inline-exec UI-app host (PostHog Desktop, Claude Code, Cowork) see a query's chart render, then get a final reply that repeats the same numbers as a table underneath it.
The chart mounts entirely on the client. The model that writes the final reply never learns it rendered, so it answers from the same compact table it was handed and duplicates the chart in prose.
Changes
execwrapper sets only for that case) — a client with no chart mounted sees no new text.How did you test this code?
Added two assertions to
services/mcp/tests/unit/build-tool-result.test.ts, in the existingbuildToolResultPayloadtest blocks:includeUiResponseMeta) — guards a false "chart is shown" claim reaching a client that never mounts one.Ran
npx vitest run tests/unit/build-tool-result.test.ts(23 passed) andpnpm run fix(lint + format, clean). Not run: a full monorepo typecheck — this checkout'stsgofails on missing@posthog/quilltypes in several unrelated MCP UI-app files that predate this change; confirmed none of the reported errors reference the two files this PR touches. Not run: an end-to-end check against a live MCP client.Automatic notifications
Docs update
None. Internal server-side prompt behavior with no documented setting.
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Split out from #95878, which fixed a PostHog Desktop-only bug where a chart never rendered for Codex-driven sessions. Once that chart started rendering, the reporting user noticed the model's final answer still duplicated the chart's data as text — this PR addresses that follow-on report. Opened separately because it touches
services/mcp, the production MCP server every client connects to, rather than Desktop's own code.Skills invoked:
/writing-tests,/writing-pr-descriptions.