Repository navigation
acpmux: Claude Code's /context breakdown and MCP reconnect - #24223
Conversation
|
cmux status (one comment, edited in place; each line is updated by the job that owns it) Review App of this head (app.zip, kept 1 day)
Probably yours: CI failed on
Failures:
Matched log linesNot re-run automatically: Written by red: cmux-next checks (god files, concurrency, crash safety, l10n); no finished base run on 1894a48 to compare; do not merge until green; see lane-rules Gallery before/after for
States
Pick other states with a |
|
Owned by hb-acpmux on big-red · took over from session 01a16a59 · session |
|
Found 48 test failures on Blacksmith runners: Failures
...and 38 more test failures. View all on Blacksmith: run 40244236342, run 40244236327
|
|
Bead |
|
|
direct.ts, model.ts and the session-start test now match #24223 at 2ac8840 (its review fixes): an info update keeps its title and Claude Code's facts when it also carries the breakdown, and the update's breakdown goes through contextBreakdownOf. reconnectMcp stays with #24223. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Agent-Session: https://cmux.com/deeplink/agent?harness=claude&session=01a16037-16c2-7a73-b063-2e37ed40b9c4&host=cosmic-gray
|
|
|
|
After each Claude Code turn acpmux asks get_context_usage and sends the trimmed answer as session_info_update _meta.acpmux.contextBreakdown, kept in the session detail's contextBreakdown (the shape #24303's Context card reads). A failover or a replaced agent's late answer drops or ignores it. _acpmux/mcp/reconnect sends Claude Code's mcp_reconnect for a server the chat lists; the agent pane may relay it for a chat in its scope. Rebased onto feat-cmux-next as one commit: the web plumbing #24303 already landed is not repeated; this carries the daemon side, reconnectMcp and the pane's failover drop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Agent-Session: https://cmux.com/deeplink/agent?harness=claude&session=01a16c8c-54ec-71b2-a0fa-125d1404dd72&host=big-red
7c547e9 to
d4f6e8e
Compare
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Agent-Session: https://cmux.com/deeplink/agent?harness=claude&session=01a16c8c-54ec-71b2-a0fa-125d1404dd72&host=big-red
|
Review (codex gpt-6-astra xhigh, hb-orphan-context-review): SHIP at 7ed6a0d. Fleet app compile-check passed at this head (job a37490bb8aca4e7ef735ffe2); remaining reds match base. |
|
base-red-watch: |
![Fix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/fix-with-codesmith-light-3x.png)
Adopted and rebased (2026-10-25). The lane that opened this died on cmux16; hb-acpmux adopted it. The branch is now one squashed commit on feat-cmux-next plus a rustfmt-only commit. #24303 had already landed the web side (the
AcpmuxContextBreakdowntype,contextBreakdownOf, and the session-start test it reads), so that part is dropped here. What stays is the daemon side that producescontextBreakdownand_acpmux/mcp/reconnect. The daemon's output matches the type #24303 reads:categories[{id?, name, tokens, kind}],memoryFiles,mcpTools, optionalskills,totalTokensandmaxTokens. Base had changed some of the same code, so four conflicts were resolved by hand:hub/permissions.rskeeps base'sgoal_write/mark_clearedand saves ongoal_write || breakdown_changed.hub/views.rskeepsgoalbesidecontextBreakdown.server/requests.rs: initialize lists base's extensions plusMUX_MCP_RECONNECT.docs/acpmux-schema.json: base's SessionDetail plus thecontextBreakdowntext.The earlier "SDK schema drift checker" red was the stale merge. At this head,
test_check_sdk_schema.pyandcheck-sdk-schema.pyboth pass, andbun run acpmux-protocol:checkis clean.Tests at this head (fleet,
cmux-ci test)cargo fmt --checkis clean andcargo clippy -p acpmux --all-targets -D warningspasses. The first run caught three rustfmt lines; commit 7ed6a0d fixes them.cargo test -p cmux-agent-pane-policypasses (Swift and TypeScript parity included).cargo test -p acpmux: all of the PR's tests pass (claude_stdio::context_usage_tests,hub_integrationcontext_window and claude_failover,local_app_trust_gate). Three tests fail, and each fails the same way on base 337d37c:daemon_chat_openfails its open-read budget (5.3 MB against a 4 MB budget).session_pool::pooled_sessions_end_with_the_daemon_and_after_a_crashfails 3 of 3 runs on base and on head.harness_login::codex_bridge_statusis flaky: it passed 3 of 3 on rerun at both base and head.agent-pane-session-start.test.tspasses 4 of 4, andbun run typecheckfinds no errors.Review
A fresh Codex (gpt-6-astra, xhigh) reviewed this head and said SHIP. It checked:
Stop conditions: no new timer or observer. The reconnect request has a 30 s bound (
RECONNECT_TIMEOUT), and its pending entry is removed when that bound runs out.The agent pane's Inspector needs Claude Code's
/contextbreakdown for its Context card and a way to reconnect a failed MCP server. acpmux now supplies both for Claude Code chats.Context breakdown. When a turn ends (its
result), acpmux sends Claude Codeget_context_usagewithdetail: "summary". That mode uses the last response's usage, so it makes no token-count API calls. The request goes out after the turn's answer, so the turn never waits on it. acpmux trims the reply and keeps it on the session._acpmux/infoand attach return it ascontextBreakdown. It also goes out as asession_info_updatewith_meta.acpmux.contextBreakdown, so an attached pane gets it live. The shape:{"categories": [{"id": "system_prompt", "name": "System prompt", "tokens": 3000, "kind": "used"}], "memoryFiles": [{"path": "/repo/CLAUDE.md", "type": "Project", "tokens": 120}], "mcpTools": [{"name": "mcp__cmux__a", "serverName": "cmux", "tokens": 40}], "skills": [{"name": "pdf", "tokens": 30}], "totalTokens": 3900, "maxTokens": 200000}idappears only when Claude Code gives one.kindisused,free,bufferordeferred.skillsappears only when skills take context.When Claude Code refuses the request (older CLIs answer "not supported"), the field stays null.
MCP reconnect. The new
_acpmux/mcp/reconnect {sessionId, server}sends Claude Code'smcp_reconnect(serverName) to the chat's running process.{}on success, or with Claude Code's own error.connectedinmcpServers. Watchers getsession_changedkindtools.data.reason: mcp.unsupported.tools.remote, the same rule asset_tools, because reconnecting restarts the server's configured command.mcp-reconnect-v1.Web pane. The
contextBreakdowntype and its reading indirect.tsalready landed with the Context card in #24303, so this PR no longer carries them. It addsdirect.tsreconnectMcp(server)and clears the breakdown on a failover record.cmux-agent-pane-policyandAcpmuxPaneMethods.swiftlist_acpmux/mcp/reconnectas a session-scoped request, so the app's pane relay forwards it.Observed / Not run
scripts/web-lint.shpassed andscripts/cmux-next/prepush-gate.pyreported no new violations. Claude Code 2.1.307's own control schema shows theget_context_usagereply shape and themcp_reconnectrequest it parses.claude_stdio/context_usage_tests.rsand three tests intests/hub_integration/context_window.rs) run on the fleet against this head and in PR CI.No capture: acpmux protocol change, no UI
Changelog
none
Agent session: big-red
🤖 Generated with Claude Code