Skip to content

acpmux: Claude Code's /context breakdown and MCP reconnect - #24223

Merged
teamleaderleo merged 2 commits into
feat-cmux-nextfrom
session-panel-acpmux-context
Oct 26, 2026
Merged

teamleaderleo merged 2 commits into
feat-cmux-nextfrom
session-panel-acpmux-context

Conversation

@teamleaderleo

@teamleaderleo teamleaderleo commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

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 AcpmuxContextBreakdown type, contextBreakdownOf, and the session-start test it reads), so that part is dropped here. What stays is the daemon side that produces contextBreakdown and _acpmux/mcp/reconnect. The daemon's output matches the type #24303 reads: categories[{id?, name, tokens, kind}], memoryFiles, mcpTools, optional skills, totalTokens and maxTokens. Base had changed some of the same code, so four conflicts were resolved by hand:

  • hub/permissions.rs keeps base's goal_write/mark_cleared and saves on goal_write || breakdown_changed.
  • hub/views.rs keeps goal beside contextBreakdown.
  • server/requests.rs: initialize lists base's extensions plus MUX_MCP_RECONNECT.
  • docs/acpmux-schema.json: base's SessionDetail plus the contextBreakdown text.

The earlier "SDK schema drift checker" red was the stale merge. At this head, test_check_sdk_schema.py and check-sdk-schema.py both pass, and bun run acpmux-protocol:check is clean.

Tests at this head (fleet, cmux-ci test)

  • cargo fmt --check is clean and cargo clippy -p acpmux --all-targets -D warnings passes. The first run caught three rustfmt lines; commit 7ed6a0d fixes them.
  • cargo test -p cmux-agent-pane-policy passes (Swift and TypeScript parity included).
  • cargo test -p acpmux: all of the PR's tests pass (claude_stdio::context_usage_tests, hub_integration context_window and claude_failover, local_app_trust_gate). Three tests fail, and each fails the same way on base 337d37c:
    • daemon_chat_open fails its open-read budget (5.3 MB against a 4 MB budget).
    • session_pool::pooled_sessions_end_with_the_daemon_and_after_a_crash fails 3 of 3 runs on base and on head.
    • harness_login::codex_bridge_status is flaky: it passed 3 of 3 on rerun at both base and head.
  • Webviews: agent-pane-session-start.test.ts passes 4 of 4, and bun run typecheck finds 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 /context breakdown 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 Code get_context_usage with detail: "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/info and attach return it as contextBreakdown. It also goes out as a session_info_update with _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}
  • id appears only when Claude Code gives one.
  • kind is used, free, buffer or deferred.
  • skills appears only when skills take context.
  • Each list holds at most the 50 largest rows.
  • Grid rows and colors are dropped. The raw reply is not logged; only the trimmed update is.

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's mcp_reconnect (serverName) to the chat's running process.

  • It answers {} on success, or with Claude Code's own error.
  • On success, the server's row reads connected in mcpServers. Watchers get session_changed kind tools.
  • It never starts a process. A chat without a running Claude Code is refused, because its servers connect when it starts.
  • Other harnesses are refused with data.reason: mcp.unsupported.
  • Remote browsers are refused with tools.remote, the same rule as set_tools, because reconnecting restarts the server's configured command.
  • New capability: mcp-reconnect-v1.
  • Also updated: the docs schema, the protocol IR and the generated web method list.

Web pane. The contextBreakdown type and its reading in direct.ts already landed with the Context card in #24303, so this PR no longer carries them. It adds direct.ts reconnectMcp(server) and clears the breakdown on a failover record. cmux-agent-pane-policy and AcpmuxPaneMethods.swift list _acpmux/mcp/reconnect as a session-scoped request, so the app's pane relay forwards it.

Observed / Not run

  • Observed: scripts/web-lint.sh passed and scripts/cmux-next/prepush-gate.py reported no new violations. Claude Code 2.1.307's own control schema shows the get_context_usage reply shape and the mcp_reconnect request it parses.
  • Not run locally: cargo, per the no-local-build rule. The acpmux Rust tests (new: claude_stdio/context_usage_tests.rs and three tests in tests/hub_integration/context_window.rs) run on the fleet against this head and in PR CI.
  • Not run: a live Claude Code session through the pane.

No capture: acpmux protocol change, no UI

Changelog

none

Agent session: big-red
🤖 Generated with Claude Code

@teamleaderleo
teamleaderleo temporarily deployed to cmux-tui-merge-tree October 22, 2026 05:32 — with GitHub Actions Inactive
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

cmux status (one comment, edited in place; each line is updated by the job that owns it)

Review 7ed6a0d: HQ feed card · gallery before/after runs · checks

App of this head (app.zip, kept 1 day)

gh workflow run reload-build.yml -R manaflow-ai/cmux --ref feat-cmux-next -f tag=pr24223 -f ref=session-panel-acpmux-context -f platform=macos -f backend_mode=local

Probably yours: accent-glass-invariants.test.ts, agent-pane-bottom-stack.test.ts, agent-pane-short-pane-composer.test.ts and 2 more fails here but not on main's latest full suite. Seen on other PRs too (likely flaky): claimPaint.test.tsx, claimPaint.test.tsx, agent-pane-agents-pill.test.ts and 8 more. This PR merged before its CI finished: fix forward on main.

CI failed on 7ed6a0d161 (run 40244236342 attempt 1): 2 code, 1 unknown.
macOS jobs did not run: compile and app tests were skipped: Fast static checks skipped.

Job Verdict Why
web / react-apps-base-check (4) code a web test failed
web / react-apps-base-check (2) code a web test failed
web / react-apps-check unknown no known signature; failed step: Check webview test shards

Failures:

  • seen on other PRs claimPaint.test.tsx a pooled Settings page claimed by the host reports its paint once its first screen is in: failed (job)
  • seen on other PRs claimPaint.test.tsx a Settings page loaded fresh reports its first paint once its first screen is in: failed (job)
  • new in this PR accent-glass-invariants.test.ts no orange or system accent and no opaque glass on 2095 gallery stages: failed (job)
  • seen on other PRs agent-pane-agents-pill.test.ts by default the running agents sit in the tray above the composer, not in the transcript: failed (job)
  • seen on other PRs agent-pane-background-tasks.test.ts the summary card lists the chat's background tasks: running ones first, the finished folded: failed (job)
  • seen on other PRs agent-pane-hairline-focus.test.ts composer at 1x: focus is the resting hairline a step brighter, no ring: failed (job)
  • seen on other PRs agent-pane-hairline-focus.test.ts newtab at 1x: focus is the resting hairline a step brighter, no ring: failed (job)
  • seen on other PRs agent-pane-hairline-focus.test.ts composer at 2x: focus is the resting hairline a step brighter, no ring: failed (job)
  • new in this PR agent-pane-bottom-stack.test.ts in a short pane the transcript keeps room and the queue scrolls inside its height: failed (job)
  • seen on other PRs agent-pane-queue-collapse.test.ts a long queue > an opened long queue keeps Show less and the focused row in sight, never a half row (...: failed (job)
  • ... 6 more in the job logs
Matched log lines
web / react-apps-base-check (4): (fail) a pooled Settings page claimed by the host reports its paint once its first screen is in [258.53ms]
web / react-apps-base-check (2): (fail) in a short pane the transcript keeps room and the queue scrolls inside its height [979.78ms]

Not re-run automatically: web / react-apps-base-check (4), web / react-apps-base-check (2), web / react-apps-check are not machine failures.

Written by scripts/ci/classify_failures.py (ci-failure-attribution.yml); signatures are its SIGNATURES table. A machine verdict is the runner's fault, not this PR's; yours means the failing file is one this PR changes, also red on main that main's latest full suite fails the same way, seen on other PRs that it failed on another pull request's run lately.

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
red: web / Web status; base red: the same failure on the base 1894a48; does not block
red: web / react-apps-base-check (2); no finished base run on 1894a48 to compare; do not merge until green; see lane-rules
red: web / react-apps-base-check (4); no finished base run on 1894a48 to compare; do not merge until green; see lane-rules
red: web / react-apps-check; base red: the same failure on the base 1894a48; does not block

Gallery before/after for 7ed6a0d: 16 states rendered, 9 images differ, 1877 more touched states not rendered. Images are in the run's artifact, not on this public PR.

gh run download 40244236256 -R manaflow-ai/cmux -n gallery-advisory-24223-7ed6a0d1610fcbf6c3a0b8506b4bb9b012749ae0 (then read gallery-review.json)

States
State Theme Status Diff Picked by
agent-pane.addressed-message/relayed Apple System Colors Light unchanged 0% imports model.ts (1 hops)
agent-pane.addressed-message/relayed Apple System Colors unchanged 0% imports model.ts (1 hops)
agent-pane.agent-message-row/sent Apple System Colors Light changed 0.0099% imports model.ts (1 hops)
agent-pane.agent-message-row/sent Apple System Colors changed 0.0094% imports model.ts (1 hops)
agent-pane.agent-message-row/sent-subagents Apple System Colors Light unchanged 0% imports model.ts (1 hops)
agent-pane.agent-message-row/sent-subagents Apple System Colors unchanged 0% imports model.ts (1 hops)
agent-pane.agent-message-row/sent-hover Apple System Colors Light changed 0.0105% imports model.ts (1 hops)
agent-pane.agent-message-row/sent-hover Apple System Colors changed 0.0092% imports model.ts (1 hops)
agent-pane.agent-message-row/sent-opened Apple System Colors Light changed 0.0112% imports model.ts (1 hops)
agent-pane.agent-message-row/sent-opened Apple System Colors changed 0.0099% imports model.ts (1 hops)
agent-pane.agent-message-row/sent-opened-long Apple System Colors changed 0% imports model.ts (1 hops)
agent-pane.agent-message-row/sent-opened-long Apple System Colors Light unchanged 0% imports model.ts (1 hops)
agent-pane.agent-message-row/outcomes Apple System Colors Light unchanged 0% imports model.ts (1 hops)
agent-pane.agent-message-row/outcomes Apple System Colors unchanged 0% imports model.ts (1 hops)
agent-pane.agent-message-row/both-directions Apple System Colors Light unchanged 0% imports model.ts (1 hops)
agent-pane.agent-message-row/both-directions Apple System Colors unchanged 0% imports model.ts (1 hops)
agent-pane.agent-message-row/both-directions-opened Apple System Colors Light unchanged 0% imports model.ts (1 hops)
agent-pane.agent-message-row/both-directions-opened Apple System Colors unchanged 0% imports model.ts (1 hops)
agent-pane.agent-pair-note/paused Apple System Colors Light unchanged 0% imports model.ts (1 hops)
agent-pane.agent-pair-note/paused Apple System Colors unchanged 0% imports model.ts (1 hops)
agent-pane.agent-pair-note/held-list Apple System Colors Light unchanged 0% imports model.ts (1 hops)
agent-pane.agent-pair-note/held-list Apple System Colors unchanged 0% imports model.ts (1 hops)
agent-pane.agent-pair-note/repeating Apple System Colors Light unchanged 0% imports model.ts (1 hops)
agent-pane.agent-pair-note/repeating Apple System Colors unchanged 0% imports model.ts (1 hops)
agent-pane.agent-pair-note/cap Apple System Colors Light unchanged 0% imports model.ts (1 hops)
agent-pane.agent-pair-note/cap Apple System Colors unchanged 0% imports model.ts (1 hops)
agent-pane.agent-pair-note/release-failed Apple System Colors Light unchanged 0% imports model.ts (1 hops)
agent-pane.agent-pair-note/release-failed Apple System Colors unchanged 0% imports model.ts (1 hops)
agent-pane.agent-pair-note/resumed Apple System Colors Light unchanged 0% imports model.ts (1 hops)
agent-pane.agent-pair-note/resumed Apple System Colors unchanged 0% imports model.ts (1 hops)
agent-pane.agent-runs/before Apple System Colors changed 0.0496% imports model.ts (1 hops)
agent-pane.agent-runs/before Apple System Colors Light changed 0.0062% imports model.ts (1 hops)

Pick other states with a Gallery: entry.id, entry.id/variant line in the PR body.

@teamleaderleo

teamleaderleo commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator Author

Owned by hb-acpmux on big-red · took over from session 01a16a59 · session

@github-actions github-actions Bot added the risk:high Risk tier (docs/ci/risk-tiers.md) label Oct 22, 2026
@blacksmith-sh

blacksmith-sh Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Found 48 test failures on Blacksmith runners:

Failures

Test View Logs
/tmp/tmp9v3fnf9w/summary-fail.json (live):/summary-fail.json (live): View Logs
/tmp/tmpjuf3kgx9/summary-missing.json (live):/summary-missing.json (live): View Logs
[new_workspaces] debug.new_workspace timed 0 of 50 new workspace rows/
[new_workspaces] debug.new_workspace timed 0 of 50 new workspace rows
View Logs
[new_workspaces] the window draws no frames/[new_workspaces] the window draws no frames View Logs
[tabs] debug.tab_switch timed 0 of 40 switches/
[tabs] debug.tab_switch timed 0 of 40 switches
View Logs
[tabs] the window draws no frames/[tabs] the window draws no frames View Logs
bench OTHER_SWIFT_FLAGS is 'OTHER_SWIFT_FLAGS=$(inherited) -DCMUX_BENCH_HOOKS -DCMUX_BL
OCKING_CHECKS'/
bench OTHER_SWIFT_FLAGS is 'OTHER_SWIFT_FLAGS=$(inherited) -DCMUX_BENCH_HOOKS -DCMUX_BL
OCKING_CHECKS'
View Logs
bench OTHER_SWIFT_FLAGS is 'OTHER_SWIFT_FLAGS=$(inherited) -DCMUX_BENCH_HOOKS -DCMUX_BL
OCKING_CHECKS'/
bench OTHER_SWIFT_FLAGS is 'OTHER_SWIFT_FLAGS=$(inherited) -DCMUX_BENCH_HOOKS -DCMUX_BL
OCKING_CHECKS'
View Logs
convention violations found (ERROR lines above)./
convention violations found (ERROR lines above).
View Logs
nightly.yml prepare-nightly-variant: 'Package prepared app for signing' is not in list/
nightly.yml prepare-nightly-variant: 'Package prepared app for signing' is not in list
View Logs

...and 38 more test failures. View all on Blacksmith: run 40244236342, run 40244236327

Fix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

Bead cx-vzcoo created for this PR by the cmux coordinator.

@teamleaderleo
teamleaderleo temporarily deployed to cmux-tui-merge-tree October 22, 2026 05:48 — with GitHub Actions Inactive
@teamleaderleo teamleaderleo added the risk:normal Risk tier (docs/ci/risk-tiers.md) label Oct 22, 2026
@github-actions github-actions Bot removed the risk:normal Risk tier (docs/ci/risk-tiers.md) label Oct 22, 2026
@teamleaderleo
teamleaderleo temporarily deployed to cmux-tui-merge-tree October 22, 2026 06:42 — with GitHub Actions Inactive
@teamleaderleo
teamleaderleo temporarily deployed to cmux-tui-merge-tree October 22, 2026 06:55 — with GitHub Actions Inactive
@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

cmux-next guards / nightly-guards / workflow-guard-tests / release-notary is red on 15 of 15 fresh feat-cmux-next PR heads in the last 2:00:00, so it is most likely a base red, not this PR's. The base-reds lane has it; a base merge picks up the fix once it lands.

@teamleaderleo
teamleaderleo temporarily deployed to cmux-tui-merge-tree October 22, 2026 07:44 — with GitHub Actions Inactive
teamleaderleo added a commit that referenced this pull request Oct 22, 2026
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
@teamleaderleo
teamleaderleo temporarily deployed to cmux-tui-merge-tree October 22, 2026 08:58 — with GitHub Actions Inactive
@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

cmux-next / cmux-next checks (god files, concurrency, crash safety, l10n) › Checks job structure is red on 12 of 13 fresh feat-cmux-next PR heads in the last 2:00:00, so it is most likely a base red, not this PR's. The base-reds lane has it; a base merge picks up the fix once it lands.

@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

cmux-next / cmux-next checks (god files, concurrency, crash safety, l10n) › No new SwiftUI (macOS UI is AppKit) is red on 12 of 13 fresh feat-cmux-next PR heads in the last 2:00:00, so it is most likely a base red, not this PR's. The base-reds lane has it; a base merge picks up the fix once it lands.

@teamleaderleo
teamleaderleo temporarily deployed to cmux-tui-merge-tree October 23, 2026 12:29 — with GitHub Actions Inactive
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
@teamleaderleo
teamleaderleo force-pushed the session-panel-acpmux-context branch from 7c547e9 to d4f6e8e Compare October 25, 2026 23:13
@teamleaderleo
teamleaderleo temporarily deployed to cmux-tui-merge-tree October 25, 2026 23:13 — with GitHub Actions Inactive
@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

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.

@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

base-red-watch: cmux-next / cmux-next Release compile (fleet fast check) went red on feat-cmux-next in https://github.com/manaflow-ai/cmux/actions/runs/40249733805 (first red at f08f46b, last green at 6af1ee1). Suspect: #24223 (commit f08f46b). If it is yours, fix forward on feat-cmux-next.

This branch had an error being deployed

1 failed and 3 inactive deployments
artifacts — 7ed6a0d1 Deployed Oct 25, 2026 by teamleaderleo via publish to R2 #52902
sentry-dsyms — 7ed6a0d1 Deployed Oct 25, 2026 by teamleaderleo via upload cmux-tui dSYMs to Sentry #52902
ci-routing-agent — 7ed6a0d1 Deployed Oct 25, 2026 by teamleaderleo via namespace autofix #2719
cmux-tui-merge-tree — 7ed6a0d1 Deployed Oct 25, 2026 by teamleaderleo via publish the merge tree #5793
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-land Reviewed at this head; next-autoland merges it into feat-cmux-next when its only reds are base reds risk:high Risk tier (docs/ci/risk-tiers.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant