Skip to content

fix(acp): pick thought levels from the session's own menu, and honor graded levels - #39

Merged
Harold Hunt (huntharo) merged 2 commits into
mainfrom
fix/acp-per-session-capabilities
Sep 18, 2026
Merged

Harold Hunt (huntharo) merged 2 commits into
mainfrom
fix/acp-per-session-capabilities

Conversation

@huntharo

@huntharo Harold Hunt (huntharo) commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Why

After #37, a PwrSnap review found that model selection now works but reasoning: "low" still does nothing on Kimi. Chasing that turned up three separate bugs. Each one alone leaves the symptom in place:

  1. Graded thought levels never match. reasoningValueForThoughtLevel only maps a low-effort token onto an off-like value. Kimi's K3 offers low / high / max / on and no off, so "low" → undefined. K2.7 Coding offers only on. So reasoning: "low" was a no-op on every Kimi model, whichever model was selected.
  2. One option menu for the whole pooled client. AcpAgentClient serves many sessions but kept one runtimeCapabilities, overwritten by every session/new and option write. applyReasoning(threadId) and setModel(threadId) read that shared copy. Before fix(acp): route model selection to the config option ACP 1.3 defines #37 every session ran the default model, so the shared menu was always right. Now sessions can run different models, and on Kimi the model decides which thought levels exist, so one session gets matched against another session's menu.
  3. The ACP 1.3 config_option_update is dropped. ACP 1.3 defines it as the full configOptions set, but the parser only reads a single changed option (update.configOption). Kimi sends the full set after every model change, and it's the only report you get from session/set_model, which replies {}.

The fix

  • Graded fallback: low-effort → off if the agent has one, otherwise the low level (low / minimal / min / minimum). High-effort is unchanged.
  • Per-session menus: AcpSessionState.runtimeCapabilities, taken from that session's session/new / session/load result and refreshed by its own option writes. setModel, applyReasoning and the session's capability notifications read it. A session's menus are built on what initialize reported, never on the client-wide snapshot, and a session with no menu of its own reads initialize's menus too. captureRuntimeCapabilities takes base as a required argument, so nothing falls back to the shared copy by default. The client-wide copy stays only for agent-level questions (session load, MCP transport support). An option write's reply updates the session's runtime state as well as its menus, so options the write reshaped report where the agent actually put them.
  • Full-set config_option_update: recognized in one place (configOptionUpdateSet) however the update is keyed (sessionUpdate, session_update, kind, type). It replaces the session's menus and its current values, including currentModelId, so if the agent changes the model, thread_settings shows the new one rather than the model originally requested.

Verified against Kimi Code CLI 2.0.0

Two sessions on one client, the pooled shape PwrSnap uses. session/prompt is refused locally, so the thinking write reaches Kimi but no model turn runs and no tokens are spent: startThread({ model: "kimi-code/k3" }), then a chat thread on the default model, then startTurn({ reasoning: "low" }) on the first.

thinking writes sent Kimi's reply
published 0.16.0 none — (K3 keeps thinking on)
this branch low model=kimi-code/k3 thinking=low

Tests

Six new tests. I ran them against the old code, and against partial versions of the fix, to make sure each one checks something:

test fails on old code fails with graded mapping but without per-session menus
graded fallback picks low when there's no off ✗ —
off still wins over low passes (pins existing behavior) —
session's own menu, not the last one opened ✗ ✗
no level the session's own model lacks passes: the old mapping never produced low, which hid the bug ✗
full-set update refreshes the menu ✗ —
full-set update's model wins in thread_settings ✗ —

The fake transport in per-session-capabilities.test.ts models Kimi as measured: each session has its own model, and a thought level that model doesn't offer is refused.

pnpm typecheck, pnpm test (agent-acp 174 passing, workspace 363), lint:boundaries, lint:licenses, lint:deps: all clean.

Review follow-up (ff9e695)

A high-effort review of the first commit found that a new session could still inherit another session's menus and current values via the client-wide snapshot (and skip a write it thought was already applied). It also found that an option write's reply refreshed the menus but not the current values, that the full-set check ignored the kind / type keys, and that a live refresh relabeled menus as session-load. It also found that a value like "On (minimal budget)" could be reclassified from on to low. All fixed. Each correctness fix has a test that fails on the first commit.

Release

This is a patch. PwrSnap pins ^0.16.0, so it picks this up with a lockfile refresh and no pin bump.

🤖 Generated with Claude Code

…graded levels

Three fixes that only work together.

Graded levels: reasoningValueForThoughtLevel mapped a low-effort token only
onto an off-like value, so an agent offering graded levels and no off got
nothing. Kimi's K3 offers low/high/max/on, so reasoning "low" was a no-op
on every Kimi model. Fall back to the `low` level when there is no off;
off still wins where both exist.

Per-session menus: a pooled AcpAgentClient serves many sessions but kept
one client-wide runtimeCapabilities, overwritten by every session/new and
option write. applyReasoning and setModel read it. With per-session models
real since 0.16.0, and the model deciding which thought levels exist, a
session was matched against whichever menu was written last: K3 enrichment
with a K2.7 chat opened after it sent no thinking write; the reverse sent
thinking=low to K2.7, which the agent refuses. Each session now keeps its
own menus. The client-wide snapshot remains for agent-level questions and
as the fallback for a session with none yet.

config_option_update: ACP 1.3 defines it as the full configOptions set, but
the parser read a single changed option, so the spec shape was dropped.
Kimi emits it after every model change, and it is set_model's only report
(that call answers {}). The full set now refreshes the session's menus and
current values, currentModelId included.

Verified against Kimi Code CLI 2.0.0 with two sessions on one client and
the prompt refused locally: 0.16.0 sends no thinking write; this sends
thinking=low and Kimi confirms model=kimi-code/k3 thinking=low.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
- Build a session's menus on what `initialize` reported, never on the
  client-wide snapshot. That snapshot is whichever session wrote last, so a
  fresh session inherited another session's menus and current values and
  could skip a write it believed was already applied.
  `captureRuntimeCapabilities` now takes `base` as a required argument, so an
  explicit `undefined` can no longer fall back to the shared snapshot.
- Apply an option write's reply to the session's runtime state as well as its
  menus, so options the write reshaped (Kimi moves thinking when the model
  changes) report where the agent actually put them.
- Recognize the ACP 1.3 full-set `config_option_update` in one place
  (`configOptionUpdateSet`). It honors every kind key (`sessionUpdate`,
  `session_update`, `kind`, `type`), so menus and runtime state agree on
  which updates carry the set.
- A live full-set refresh keeps the source the session's menus were opened
  with, and no longer relabels them `session-load`.
- Classify a thought level as "low" only after checking for on, so a value
  that already read as on ("On (minimal budget)") keeps doing so.

Each correctness fix has a test that fails on the previous commit.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@huntharo
Harold Hunt (huntharo) merged commit 384493a into main Sep 18, 2026
2 checks passed
@huntharo
Harold Hunt (huntharo) deleted the fix/acp-per-session-capabilities branch September 18, 2026 20:10
Harold Hunt (huntharo) added a commit to pwrdrvr/PwrSnap that referenced this pull request Sep 18, 2026
0.16.0 routed the model write correctly, but `reasoning: "low"` still did
nothing on any Kimi model. The low-effort token only mapped onto an off-like
thought level: K2.7 Coding offers only `on`, and K3's graded `low` never
matched. The pooled client also kept one option menu for all its sessions,
so an enrichment on K3 could be matched against a chat session's K2.7 menu.

0.16.1 (pwrdrvr/agent-kit#39) falls back to a graded `low` when the agent
offers no off, keeps option menus per session, and reads ACP 1.3's full-set
`config_option_update`. Measured against Kimi Code 2.0.0: K3 +
`reasoning: "low"` now sends `thinking=low`, and Kimi confirms it.

Raises the floor to ^0.16.1 so a fresh resolve cannot land on 0.16.0.
THIRD_PARTY_LICENSES regenerated.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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