Skip to content

feat(receipt): a Claude reply posted through the MCP tool names its model and effort (F546) - #4195

Open
lilyshen0722 wants to merge 2 commits into
mainfrom
swe/f546-claude-reply-receipt
Open

lilyshen0722 wants to merge 2 commits into
mainfrom
swe/f546-claude-reply-receipt

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

F546: a Claude reply posted through the MCP tool names its model and effort

What the walk showed. Growth's 11-16 D141 walk set Effort "low" in Settings on a BYO Claude Code seat. The spawned process ran with --effort low --model claude-haiku-5-5, but the reply's messages.receipt was null. A Codex reply names its model and effort (codex.js:1880).

Why it was null. The wrapper attaches its receipt only to a reply it posts itself (deliverChatReply in agent.js). A Claude Code seat usually answers with its own commonly_post_message call, which goes straight from the Commonly MCP server to the runtime route. That route accepts a receipt, but the server never sent one.

Can it carry one? Yes, partly. Adapter, model and effort are fixed before the spawn. Turns, tools and duration are only known after the turn, so a tool-posted reply can't carry those.

Change

  • cli, claude adapter. It builds the receipt from the same modelArgs the spawn runs with (controlsFromArguments), then hands it to our MCP server only as COMMONLY_REPLY_RECEIPT. It recognises our server the same way the ready-file code does: isShippedCommonlyMcpCommand, or describeMcpCommand(...).isCommonly. No other server sees it.
  • commonly-mcp.
    • loadConfig parses that env once at start and keeps only string adapter, model and effort.
    • A value that isn't a JSON object naming an adapter carries no receipt.
    • commonly_post_message attaches it as receipt. It isn't in the tool's input schema, so the model can't set it.
  • Backend. No change. byoReceipt.normalizeReceipt already accepts a partial receipt, re-checks every field and stamps it source: "self-reported".
  • Docs. ADR-004's receipt line now lists effort and says which fields a tool-posted reply carries.

Tests

  • cli. The new adapters.claude.reply-receipt.test.mjs checks three things: the commonly entry gets {adapter, model, effort}, an absent effort is left out, and another MCP server gets nothing. Two of these fail on main. One credential-channel assertion now compares the declaration with the receipt key excluded, because the receipt isn't a credential.
  • Full cli jest. 4,626 pass. The 3 failures are in seat-files.jail.smoke and seatbelt.commit-hooks.smoke, which fail the same way on main in this environment.
  • commonly-mcp. New loadConfig cases cover a valid receipt, extra fields dropped, five unusable values and an unset env. A new commonly_post_message case covers a receipt being attached and none when unset. All 324 tests in 16 suites pass.
  • Lint. npm run lint in cli is clean on src.

Release. This needs a cli publish and a @commonlyai/mcp publish. Until both reach a seat, nothing changes: an older server ignores the env, and an older cli doesn't set it. It's held for the next cli publish after Tue 11-17's batch.

🤖 Generated with Claude Code

https://claude.ai/code/session_01N4VWLEgKqoyJ97ffrijbor

…odel and effort (F546)

A Claude Code seat usually answers with its own commonly_post_message
call, which never goes through the wrapper's post, so its reply carried no
receipt while a Codex reply named model and effort. The claude adapter
now hands the spawn's controls (adapter, model, effort, from the same args
the spawn runs with) to the Commonly MCP server only, as
COMMONLY_REPLY_RECEIPT. The server parses it at start, keeps those three
string fields, and attaches them to commonly_post_message posts; the
backend already accepts a partial receipt and checks it again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N4VWLEgKqoyJ97ffrijbor
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 4 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 3a20811 and c66d091.

Files selected for processing: 9

  • cli/__tests__/adapters.claude.credential-channel.test.mjs
  • cli/__tests__/adapters.claude.reply-receipt.test.mjs
  • cli/src/lib/adapters/claude.js
  • cli/src/lib/reply-receipt.js
  • commonly-mcp/__tests__/client.test.mjs
  • commonly-mcp/__tests__/tools.test.mjs
  • commonly-mcp/src/client.js
  • commonly-mcp/src/tools.js
  • docs/adr/ADR-004-commonly-agent-protocol.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

…e L1)

A model id is free text, and Claude expands ${...} in an MCP entry's env;
one naming COMMONLY_AGENT_TOKEN would make the adapter hand the runtime
its credential and could store it in a receipt. A control holding a $ is
now left out. ADR-004 notes the tool-posted model is the requested one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N4VWLEgKqoyJ97ffrijbor

@lilyshen0722 lilyshen0722 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gate review: one subagent review on the stronger model (Opus, medium effort) on a817dfe, because the change touches public seats' MCP config. Tests at that head: adapters.claude 282 pass, commonly-mcp client and tools 149 pass.

No High or Medium.

  • Confinement: the receipt key is added after deliverSeatCredential and commonlyMcpReadyFile, so credential delivery and the ready-file decision see the same env as before. --strict-mcp-config, Seatbelt and bwrap are untouched.
  • Detection: it uses the same check as mcp-ready.js, and it needs a spawnCommand, so url/http servers are skipped. A lookalike @commonlyai/mcp-* command would get only adapter, model and effort, none of which is secret.
  • The model can't set it: the receipt comes from config, not tool args, and isn't in the inputSchema. The tools test asserts both. parseReplyReceipt keeps three string fields, and byoReceipt.ts re-validates each one.
  • Retry: the retry spawn reuses the same mcpConfig and modelArgs, so the receipt matches what ran.
  • Mixed versions: an old cli sets nothing, and an old or warm server ignores the env. Both are safe.
  • The credential-channel test edit: it excludes only the receipt key and still asserts the rest of the declaration exactly.

Low:

  • L1, fixed at c66d091. A free-text model id containing ${COMMONLY_AGENT_TOKEN} would have put a credential placeholder into the MCP env. That makes the adapter hand the runtime its token, and it could be stored in a receipt. A control holding $ is now left out. The new test checks that the placeholder never reaches the env. 294 claude tests pass, and lint is clean.
  • L2, documented. A tool-posted receipt names the model the spawn asked for, which may be an alias; the wrapper's receipt names the model the run reported. ADR-004 now says so.
  • L3, accepted. There's no test for the local-checkout server shape. Detection is shared with the ready-file code, which already covers it.

GATE: PASS

Written by Lily Shen, via Claude Code.

This branch has not been deployed

No deployments
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