feat: mirror mode for MCP result-artifact rules#228
Merged
Conversation
Replacement compaction breaks hosts whose MCP server is stateless — each tool
call takes the current document as input and returns the updated one, so the
model must keep the full value inline for the next call. Those hosts had to
disable resultArtifacts and hand-extract the outcome from raw tool results.
A manual rule can now set `mode: 'mirror'`: the artifact is persisted exactly
as before (including setCurrent), but the value stays inline and untouched.
The host then reads the turn's outcome via engine.artifacts.current(...)
instead of spelunking tool-result JSON. `replacePaths` is ignored in mirror
mode; default behavior ('replace') is unchanged.
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CjFdZgZhov8wdwFinVTfjz
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.
Why
Result-artifact capture normally replaces captured values with compact references. That is appropriate for context compaction, but it breaks stateless MCP servers where each tool call must receive the full document returned by the previous call.
Without a non-replacing capture mode, hosts must disable result artifacts and manually inspect raw tool-result JSON to recover the final document.
What
A manual result-artifact rule can now declare
mode: 'mirror':Mirror mode:
setCurrentbehavior;replacePaths, because no result path is replaced;engine.artifacts.current(sessionId);The default
'replace'behavior is unchanged.Safety
This captures tool results; it does not expose model-generated private output. The host still decides which artifact content becomes user-visible.
Verification
yarn lintyarn build