Repository navigation
Studio MCP: Add the declared settings of core blocks to tool results - #5333
Merged
Merged
Conversation
… as Studio Code gets them
chubes4
marked this pull request as draft
October 23, 2026 12:20
chubes4
marked this pull request as ready for review
October 23, 2026 13:06
1 task
chubes4
added a commit
that referenced
this pull request
Oct 23, 2026
…all touches the theme file they replace (#5343) ## Related issues - Follows #5301, addressing the review there: the saved Site Editor copies were listed in every system prompt, though they matter only when the agent touches a theme file they replace. - Builds on #5333's shared result notes, so the notice reaches Studio Code and `studio mcp` the same way. ## How AI was used in this PR Claude (via the Pi coding agent in a Roadie session) wrote the change and the test and ran the evals below. I reviewed the diff and the results. ## Proposed Changes When someone saves a template, template part or Global Styles in the Site Editor, WordPress renders that saved copy instead of the theme file. An agent that edits `parts/header.html` then changes nothing the visitor sees. #5092 told the agent this in `edit-manage-site`; #5301 moved it into Active site facts, which listed every saved copy in every prompt. - The notice moves into tool results, stated when a call or its result names a theme file a saved copy replaces, for example: > WordPress renders the template part header from its copy saved in the Site Editor (post 12), not from wp-content/themes/twentytwentyfive/parts/header.html. - `cli/ai/saved-copies.ts` reads the copies from the site's SQLite database when a theme file is named, so copies saved earlier in the turn count. Each copy is stated once per tracker. - It is registered in `cli/ai/result-notes.ts` (#5333). The notes now see the call's arguments with its result (a Write names the file in its arguments), on both surfaces. - Active site facts keep the WordPress version; saved copies leave them. Limits: - MCP clients read and write theme files with their own tools, which never pass through Studio, so for them the notice fires only when a Studio tool names the file. - Like every result note, a notice stated early in a turn can be lost if the context is compacted later in that turn. ## Testing Instructions - `npx vitest run apps/cli/ai/tests/saved-copies.test.ts`: a real SQLite database with a saved template part and Global Styles; notices for the theme files they replace, none for other files, and each copy once; run with `wp_` tables and with another prefix, as imported sites can have. - Eval (`/tmp` override kit, 6 runs per case, Studio's default model): a site whose header part and Global Styles were saved in the Site Editor; the task edits the header, then the styles. Scored from the rendered site. | Case | #5301 (facts in prompt) | This PR | |---|---|---| | Template part saved in the Site Editor | 6/6 | 6/6 | | Global Styles saved in the Site Editor | 4/4 | 6/6 | The notice appeared in all 12 transcripts. An earlier run of this change scored 5/6 on Global Styles; the miss was broken JSON the agent wrote to a file and saved with `post update`, which the inline `--post_content` JSON check (#5310) does not cover. - Eval on site edits with no saved copies (8 cases from the routing eval: contact form, carousel, newsletter, heading font, testimonials, header search block, hero, spacing; each run stops at its first write). Before #5301, `edit-manage-site` told the agent to check for saved copies first; #5092's review asked what that costs. | | Sessions that queried saved copies | Queries | Tool calls before the first write | |---|---|---|---| | Before #5301 (Oct 22 runs) | 38/126 | 43 | 14.3 | | This PR | 0/32 | 0 | 14.1 | The queries are gone, but calls before the first write are unchanged: the agent spends them on other reading. Tokens (median 134k before, 136k now) and wall time (median 38.6s on trunk, 36.4s now) are at parity too. ## Pre-merge Checklist - [ ] Have you checked for TypeScript, React or other console errors?
1 task
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.
Related issues
studio mcp.How AI was used in this PR
Claude (via the Pi coding agent in a Roadie session) wrote the change and the test and ran the end-to-end check below. I reviewed the diff and the results.
Proposed Changes
#5307 adds the declared settings of each core block a tool result shows (read from the site's own
wp-includes/blocks/<block>/block.json). The notes are wired up in the Pi runtime'stoToolDefinition, which the MCP server bypasses: it callstool.rawHandlerdirectly. So Claude Code, Codex, and the AI plugins never got them.cli/ai/result-notes.ts.createResultNotes()returns( sitePath, text ) => notes: the facts read from that site about what the result shows, each stated once per tracker. Block settings are the only kind today; a new kind is added there and reaches every surface.studio mcp: one per MCP session, with the site the call names (nameOrPath). A call that names no site, or one that isn't found, gets no notes.runtimes/mcp/served-tool.ts(runServedTool); pending work reports and error handling are unchanged.Limits:
wp_cliand the like), not for files the client reads itself.createStudioAgentSession, whichrunAgentSessionTurncalls, so it is per turn, not per session), and within an MCP session, whose compaction Studio can't see.Testing Instructions
npx vitest run apps/cli/ai/runtimes/mcp:served-tool.test.tsresolves a real site from acli.json(no mocks): no notes for a call without a site or with an unknown one, the settings for the named site, then none on a repeat call in the same session.studio mcpover stdio, and calledwp_cliwithpost get 2 --field=post_contenttwice, thenoption get blogname. The first result had the page content plus:option get blognamehad no notes.Pre-merge Checklist