Skip to content

Agent2@narko: feat(run): report a local model's context window in the result - #52

Merged
muxagent[bot] merged 2 commits into
mainfrom
agent2/report-context-window
Oct 6, 2026
Merged

muxagent[bot] merged 2 commits into
mainfrom
agent2/report-context-window

Conversation

@muxagent

@muxagent muxagent Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Summary

AgentMux's agent pane shows a context meter, "tokens in context / window". It already reads muxcode's per-call usage from message_start / assistant frames, but muxcode never reports a window, so a muxcode pane shows "N ctx" with no window and no fill band.

The result frame now carries Claude Code's own field when the window is known:

"modelUsage": { "<model>": { "contextWindow": 32768 } }
  • Local models: the window is the context size llama-server is started with. That is the model's context_window from its metadata, else 4096. A new contextSizeFor(modelPath) in llama-server/manager.ts is now shared by the server launch and LocalBackend.contextWindow, so the reported window is exactly the one in effect.
  • Model ids: the window is keyed by the backend's model id and by every id message_start carried, since a server may answer under another id. AgentMux matches the window to message.model.
  • Remote backends (OpenAI-compatible, Anthropic) report nothing, as before. muxcode doesn't know their windows, and AgentMux shows an unknown window as unknown.

AgentMux side, for context: the meter takes the window from result.modelUsage[*].contextWindow (agentmuxai/agentmux frontend/app/store/agent-pane-state/context-reading.ts).

Tests

  • New test/context-window.test.mjs exercises the built emitter:
    • no window: no modelUsage;
    • a local window under both ids;
    • an error result carries it too.
  • npm test: 81 pass, 1 skipped (as before).

Agent: Agent2@narko

🤖 Generated with Claude Code

The result frame now carries Claude Code's `modelUsage[<model>].contextWindow`
when the backend knows the window: a local model's, the context size
llama-server runs it with (its metadata's context_window, else 4096;
`contextSizeFor`, now shared with the server launch). It is keyed by the
backend's model id and every id message_start carried, since a server may
answer under another id. AgentMux's context meter reads that field, so a
muxcode pane on a local model shows "tokens / window" instead of
"tokens ctx". Remote backends report nothing, as before.

Agent: Agent2@narko

@muxreview muxreview Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude

ReAgent Diagnostics
Field Value
ReAgent Version 5.34.5+gad210a0
Trigger PR opened
Tier STANDARD
Project Context No CLAUDE.md
Model claude-sonnet-5-5
Effort high
Ref Repos Enabled (dev-tools, shared-infrastructure)
Merge Safety No recent-code deletions
Review Time 8s
Timestamp 2026-10-06T23:29:29Z
Repository agentmuxai/muxcode
PR #52

Issues:

  • [P1] package.json:3 - Missing version bump for code changes (new feature in src/, no diff found for the "version" field; the repo has no changeset directory, so each source PR carries its own minor bump)

@muxreview muxreview Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude

ReAgent Diagnostics
Field Value
ReAgent Version 5.34.5+gad210a0
Trigger Re-review (new commits)
Tier VERSION_CRITICAL
Project Context No CLAUDE.md
Model claude-sonnet-5-5
Effort high
Ref Repos Enabled (dev-tools, shared-infrastructure)
Merge Safety No recent-code deletions
Review Time 5s
Timestamp 2026-10-06T23:30:13Z
Repository agentmuxai/muxcode
PR #52

LGTM

@a5af

a5af commented Oct 6, 2026

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@muxagent
muxagent Bot merged commit e92a09f into main Oct 6, 2026
3 checks passed
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