Skip to content

fix(rql): keep image blocks next to structured content; screenshot image tests in both data layers - #1213

Merged
IvanMurzak merged 4 commits into
mainfrom
fix/unity-image-results
Nov 28, 2026
Merged

IvanMurzak merged 4 commits into
mainfrom
fix/unity-image-results

Conversation

@IvanMurzak

Copy link
Copy Markdown
Owner

What

A. RQL layer dropped non-text blocks next to structured data. RqlToolBinding.Result replaced the whole Content of a ResponseCallTool that has StructuredContent with one text block, so an image, audio or resource block returned with data never reached the agent. Now only McpPlugin's JSON copy of the data (the text/json block, or text equal to it) is replaced by the rendered RQL text. Every other block (image, audio, resource, a caption) is kept, as it is in the Json layer.

  • Today no shipped tool returns an image and structured content. Screenshots return ResponseCallTool.Image without StructuredContent, which passes through unchanged in both layers. So this closes a latent case rather than a live screenshot bug.
  • Tests: RunToolRqlResultTests runs an image + structured content result and an image-only result through RunTool with the RQL binding, which exercises ProcessInvokeResult.

B. Screenshot tools return an MCP image block in both data layers. New ScreenshotImageResultTests ([RequiresGraphicsDevice], CI Graphics leg) calls screenshot-camera and screenshot-isolated through the plugin tool manager with the Json and the Rql layer. It switches the layer via RqlToolBinding.Apply, so both layers run in every suite run. It asserts one image block, image/png, PNG data. Nothing is added to battery.json, because the chain recorder runs with -nographics.

C. screenshot-isolated description. "Returns a base64-encoded PNG" becomes "Returns the rendered PNG image", in both the description and the skill body. The other screenshot tools already say they return an image. The chain fixtures of all four Unity versions are re-recorded (see below).

D. script-execute (DEV-314): no code change needed, it is already not in tools/list. Unity already registers it the way Godot does: a hidden alias ([AiTool(Visible = false)], UnityMcpPlugin.RenamedTools) that still answers tools/call with csharp-exec's code. GameDev-MCP-Server leaves every Visible = false tool out of tools/list (its ToolVisibilityTests, server ≥ 9.3.0; the plugin pins 9.6.4). The alias has no SKILL.md and is not in unity-tool-list. The tests/chain-fixtures/*/tools.jsonl files list it because the in-process recorder records the whole registry (RunListTool), hidden tools included (screenshot-camera, script-read and others too). They are not what an MCP client receives. CSharpExecResultTests.OldNameRunsTheSameCodeHidden now also asserts that the listed Visible flag (the one the server filters on) is false for script-execute.

Chain fixtures

Re-recorded in-process by ChainRecordTests on 2022.3.62f3, 6000.0.85f1, 6000.3.27f1 and 6000.6.7f1. Each project was prepared with commands/extensions.py prepare and the output canonicalized with chain_fixture.py. Against the old fixtures the only tool change is screenshot-isolated's description; the meta line carries the new versions. A final recording on 6000.6.7f1 with the reviewed code diffs identical (exit 0).

Verification (local Unity, Windows)

Unity Leg Result
6000.6.7f1 -nographics -toolDataLayer Rql 84 passed, 0 failed (4 Graphics skipped)
6000.6.7f1 -nographics -toolDataLayer Json 84 passed, 0 failed
6000.6.7f1 -toolDataLayer Rql -testCategory Graphics 38/39: all 4 ScreenshotImageResultTests cases (Json and Rql) pass; 1 failure, see below
6000.6.7f1 -toolDataLayer Json -testCategory Graphics 38/39, same failure
2022.3.62f3 -nographics 84 passed, 0 failed
6000.0.85f1, 6000.3.27f1 -nographics 74/74 (before the review fixes)

Filter: RunToolRqlResultTests, CSharpExecResultTests, RunToolStructuredContentTests, RqlToolBindingTests, RunToolTests, ScreenshotImageResultTests, plus the Isolated, Camera and SavePathCapture screenshot fixtures for Graphics.

  • Graphics failure. The one failure is ScreenshotSavePathCaptureTests.ScreenshotGameView_NoSavePath_IsUnchanged: "The Game View had not drawn yet". This is the first Game View capture in a local batchmode editor; the next Game View test in the same fixture passes. screenshot-game-view is not touched here. I expect CI's Graphics leg to show whether it happens there too.
  • First-open failures. On the first editor open after a code change, the csharp-exec tests failed locally with "Scripts are compiling and reload next". The second open of the same code passed every time (the rows above). Like the Game View failure, this comes from the local environment, not from this change.

Not changed (out of scope, for follow-up)

  • Godot-MCP's addons/godot_mcp/Editor/Rql/ToolFormat/RqlToolBinding.cs has the same pattern and drops non-text blocks next to structured content.
  • A more general fix would be in McpPlugin's RunTool.ProcessInvokeResult: keep a replaced response's non-text blocks, so no binding has to.

🤖 Generated with Claude Code

IvanMurzak and others added 4 commits November 28, 2026 01:15
…age tests

- RqlToolBinding.Result: a ResponseCallTool with StructuredContent kept only one text block, so an
  image/audio/resource block returned with data never reached the agent. Only the text blocks are
  replaced by the rendered RQL text now.
- Tests: RunToolRqlResultTests covers an image next to structured content and an image alone through
  RunTool with the RQL binding; ScreenshotImageResultTests (Graphics) calls screenshot-camera and
  screenshot-isolated through the tool manager in the Json and Rql layers and checks the image/png
  content block.
- screenshot-isolated says it returns the PNG image, not "a base64-encoded PNG".
- script-execute (DEV-314): already a hidden alias (Visible = false, left out of tools/list by the
  server); the test now also checks the listed Visible flag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…olated wording

Recorded in-process by ChainRecordTests on 2022.3.62f3, 6000.0.85f1, 6000.3.27f1 and 6000.6.7f1
(prepared with commands/extensions.py, canonicalized with chain_fixture.py); against the committed
fixtures the only tool change is screenshot-isolated's description. Also: the RQL image test checks
the rendered text instead of parsing it, and the Unity-generated .meta of ScreenshotImageResultTests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the new tests

- RunToolRqlResultTests: one RqlTool/Call helper replaces three copies of the RunTool setup; the
  test PNG is ScreenshotSavePathTests.TinyPng; ImageWithData builds on ImageOnly.
- ToolResults.PngImage: the one image/png block of a response, used by both image tests.
- ScreenshotImageResultTests calls through BaseTest.RunTool with JSON arguments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- RqlToolBinding.Result drops only McpPlugin's JSON copy of the structured content (text/json, or
  text equal to it); a caption or other text the tool returned still reaches the agent, as in the
  Json layer. The test expects the caption and checks the rendered values.
- ScreenshotImageResultTests switches the layer through RqlToolBinding.Apply, which prebuilds the
  RQL signatures on the main thread first.
- CSharpExecResultTests compares csharp-exec's listed Visible flag with IsToolVisible instead of
  assuming the project config shows it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@IvanMurzak
IvanMurzak merged commit 836884f into main Nov 28, 2026
35 checks passed
@IvanMurzak
IvanMurzak deleted the fix/unity-image-results branch November 28, 2026 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant