Skip to content

feat(acp): expose model selection as a session config option - #6189

Open
2BAB wants to merge 7 commits into
apache:mainfrom
2BAB:feat/acp-model-config-option
Open

2BAB wants to merge 7 commits into
apache:mainfrom
2BAB:feat/acp-model-config-option

Conversation

@2BAB

@2BAB 2BAB commented Oct 20, 2026 •

Copy link
Copy Markdown

ACP already lets an agent advertise a list of per-session choices and lets the client change one of them (configOptions + session/set_config_option). Model was the one choice missing from that list.

So this doesn't add a new method. It adds a model entry to the existing list, plus handling for changing it:

  • the entry lists the models the session's connection can actually run, using the Host's own ids and names;
  • selecting one switches the session to that model.

The spec reserves the category name model for the model picker, so a client that already understands ACP config options shows it correctly without knowing anything about Maka.

Behaviours worth calling out:

  • A locked connection still lists that connection's models. The lock binds the session to its connection, not to one model: the Host accepts a same-connection switch after the lock is set, so narrowing the picker to the current model would leave a single entry for the rest of the session.
  • Only enabled models are offered, plus the one the session already runs. The picker and the request validation share one rule, so a listed value is a value the Host accepts.
  • A model the session can't run is rejected, not silently swapped. The same goes for a request we can't check, e.g. when the catalogue can't be read.
  • A Session without an LLM connection advertises no model option. It has no catalogue to choose from, and validation would refuse every pick.
  • Switching models clears the thinking level; re-selecting the current model does not. A level belongs to the model it was chosen for, and the Host refuses a target that cannot honour it.
  • There is always a current value (the session's own model), because the spec requires every option to have one.

Tests cover the listing, the locked case, the same-model re-selection, the resulting session update, and the rejections above.

References:

  • Session config options — the option list, the reserved model category, and how changing a value works
  • Session setup — resuming a session can also return mode/model/config state

No protocol changes: this rides on the existing session/set_config_option surface.

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Claude (Anthropic) authored the implementation, tests and commit messages in this branch; the contributor reviewed the design, ran the verification and owns the change. Every commit carries a Generated-by: Claude trailer.

@github-actions github-actions Bot added the effort/M Under 500 readable lines label Oct 20, 2026

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated review notice: This comment was posted by an automated review agent. It is not an independent human review and does not replace one.

First review of a78901e9..c31560b6 (4 commits, 3 files, all in packages/cli/src/acp). No prior findings.

The option shape matches the spec: a select with id model, the reserved model category, the Host's model ids as values, display names as labels, and a currentValue that is always set. A model change goes through the same session.configuration.update path as the other options. The Host persists it, and the committed projection is re-projected into the response and into config_option_update, so thinking levels follow the new model. I found three defects in how a change is accepted.

P2: the picker freezes after the first prompt and after the first switch. modelValues returns only [currentModel] when connectionLocked is true (session-configuration.ts:74). validateAcpSessionConfigOptionRequest then rejects every other value. In the Host, connectionLocked means "the first user message is durable" (core/session.ts:311, one-way). #mergeConfigurationPatch also sets it to true on any modelTarget patch (session-catalog-coordinator.ts:1490). The Host does not refuse a modelTarget on a locked session, and the TUI's setModel (runtime-host-session-driver.ts:781) switches models mid-session without a lock check. As a result, an ACP client can change the model only before its first prompt, and only once. After that the dropdown shows a single entry. The stated reason ("listing the rest and refusing every one of them") does not hold, because the Host does not refuse them. Every value offered here is on the session's own connection, so the lock (which guards account identity) does not restrict it. Suggest dropping the locked branch, or adding a test that proves the Host refuses a same-connection switch on a locked session.

P2: switching to a model without the session's current thinking level is rejected. The patch carries only modelTarget (session-configuration.ts:255). The Host keeps current.thinkingLevel and #resolveModel throws invalid_request "Session model does not support thinking level X" when the target model lacks that level (session-catalog-coordinator.ts:1323-1336). So a session at high cannot switch to a non-reasoning model that is listed in the dropdown. The client has to reset thinking_level to default first. The TUI path sends thinkingLevel: null together with the model target (runtime-host-session-driver.ts:798). Suggest doing the same here, or keeping the level only when the target model supports it.

P2: a rejected model value surfaces as an internal error, not invalid_params. The entry-point pre-check now only checks that the value is a string. The real validation runs inside the updateRuntimeHostSession callback (createAcpSessionConfigPatch(params, modelContext), session-registry.ts:2447). The AcpSessionConfigInputError it throws reaches requestErrorFromSessionUpdate, which handles neither that class nor RequestError-wrapped input errors. It falls through to requestErrorFromRuntimeHost and becomes RequestError.internalError with code: 'internal_failure', source: 'runtime_host'. This applies to an unoffered value, a locked-session change, and a session with no llmConnectionId. The new tests call createAcpSessionConfigPatch directly, so they do not cover this. Suggest catching AcpSessionConfigInputError (via requestErrorFromConfigInput) around the callback, plus a registry-level setConfigOption test for a rejected model. That test would also have caught the bug fixed in a967f9b, where every model change was rejected at the entry point.

P3s:

  • The validation context in #modelConfigContext (session-registry.ts:2552) uses every catalogEntries item, while the projection filters by enabledModelIds. A disabled model passes the CLI check and is refused by the Host (invalid_request "Session model is not enabled"). Use the same filter in both places.
  • If the session's current model is no longer in the connection catalogue but other models are, currentValue is not among options. The schema does not forbid this, but clients render an empty or unknown selection. Appending the current model when it is missing would keep the "always a current value" claim true in the dropdown too.
  • Sessions with no llmConnectionId (plugin-executor, legacy) still get a model option, with the executor id as its only value. Any selection, even of that value, is rejected as configId: unsupported. Omit the option for those sessions, as thinking_level is omitted when there are no levels.
  • A Host catalogue change (models enabled or disabled) does not trigger config_option_update. The list updates only on the next session snapshot. This is acceptable for now; noting it.

Protocol/epoch: no runtime-host protocol files touched. This is an additive ACP config option on the existing session/set_config_option, so there is no epoch impact.

Tests: not run locally. A full build is needed for dist tests, and memory is constrained. The findings above come from code traces on the head.

CI/mergeability: no checks are reported on c31560b6 (fork PR; workflows have not run), so there is no CI signal. GitHub reports MERGEABLE/BLOCKED (awaiting review). The branch merges cleanly into current main. The two main commits since the base do not touch these files.

currentModel: string,
locked: boolean,
): string[] {
if (locked) return [currentModel];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: connectionLocked becomes true at the first durable user message and on any modelTarget patch (session-catalog-coordinator.ts:1490), and the Host does not refuse a same-connection switch on a locked session. This branch leaves ACP clients with a one-entry picker after the first prompt or the first switch.

// Non-null: validation above rejects a model request without a context.
const context = modelContext as AcpSessionModelConfigContext;
return {
modelTarget: {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: the patch keeps the session's current thinkingLevel. #resolveModel rejects a target model that doesn't support it, so listed models can be refused. The TUI's setModel sends thinkingLevel: null together with the target.

expectedRevision: current.revision,
patch: createAcpSessionConfigPatch(params),
}),
patch: createAcpSessionConfigPatch(params, modelContext),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: an AcpSessionConfigInputError thrown here reaches requestErrorFromSessionUpdate and is mapped to internalError (internal_failure, source runtime_host), not invalid_params. Map it with requestErrorFromConfigInput.

connectionSlug: session.llmConnectionSlug,
currentModel: session.model,
connectionLocked: session.connectionLocked,
models: (entry?.catalogEntries ?? []).map(({ id, displayName }) => ({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P3: the projection filters by enabledModelIds but this validation context doesn't, so a disabled model passes here and is refused by the Host.

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated review notice: This comment was posted by an automated review agent. It is not an independent human review and does not replace one.

Incremental review of c31560b6..696943ea. The base did not change (merge-base is still a78901e9). git range-diff shows the four earlier commits unchanged, so the whole delta is one author commit, 696943ea ("keep the model picker and the thinking level honest"). It touches session-configuration.ts, session-registry.ts and four test files.

Prior findings

  • P2, picker frozen once connectionLocked is set: fixed. modelValues no longer takes a locked argument. connectionLocked is gone from AcpSessionModelConfigContext, so the picker and validation both offer the connection's models on a locked session. The test now uses connectionLocked: true and expects both models.
  • P2, thinking level kept across a model switch: fixed. createAcpSessionConfigPatch now sends thinkingLevel: null with the modelTarget, as the TUI's setModel does (runtime-host-session-driver.ts:798). In #mergeConfigurationPatch, null becomes undefined before #resolveModel, so the support check no longer fires.
  • P2, rejected value surfaced as an internal error: fixed. The #setConfigOption catch now maps AcpSessionConfigInputError through requestErrorFromConfigInput before the general mapping. updateRuntimeHostSession rethrows callback errors unchanged (runtime-host-session-update.ts:67-91), so the error reaches the catch with its class intact. There is still no registry-level test for this path (see P3 below).
  • P3, validation context not filtered by enabledModelIds: fixed. The picker and the validation context now both go through offerableModelChoices.
  • P3, current model missing from the options: partly fixed. offerableModelChoices keeps the current model when it is in catalogEntries but not enabled. It still drops a current model that is missing from catalogEntries. If other models remain, currentValue is still not among options.
  • P3, sessions without llmConnectionId still show a model option that always rejects: open. The registry fixture (DEFAULT_CONFIG_OPTIONS, value default) now asserts this behaviour.
  • P3, a catalogue change does not emit config_option_update: open. This is still acceptable as a follow-up.

New delta

  • P3: re-selecting the current model clears an explicit thinking level. The patch always carries thinkingLevel: null, even when value === currentModel. The Host then commits the session with no level, so a client that re-sends the current model value silently drops the session from high to default. The TUI has the same behaviour, but ACP clients send set_config_option more freely. Suggest sending thinkingLevel: null only when the model actually changes. Better still, keep the level when the target model supports it.
  • P3: no test drives setConfigOption with a rejected model value through the registry to assert -32602. The fixed mapping is checked only by code reading. One such test would guard the catch.
  • The fixture updates (four to five options in the child-process, registry and stdio tests) match the real projection.

Protocol/epoch: no runtime-host protocol files are touched, and the change stays inside the existing session/set_config_option. There is no epoch impact.

Tests: I built core, storage, mcp, runtime, runtime-host, eval and cli at the head and ran acp-session-configuration, acp-session-registry, acp-stdio-server and acp-child-process from dist. All 211 tests passed, 0 failed.

CI/mergeability: no checks are reported on 696943ea (fork PR; workflows have not run), so there is no CI signal. GitHub reports MERGEABLE/BLOCKED (review required). git merge-tree against current main is clean, and the three main commits since the base do not touch these files.

No P0-P2 findings remain.

// A thinking level belongs to the old model: the TUI's `setModel` sends
// the same `null` (runtime-host-session-driver.ts), and keeping it here
// makes the Host refuse any target model that does not support it.
thinkingLevel: null,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P3: this also clears an explicit thinking level when the requested model is the current one (a client re-sending currentValue), so the session drops from e.g. high to default. Consider sending thinkingLevel: null only when request.value !== context.currentModel, or keeping the level when the target model supports it.

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated review notice: This comment was posted by an automated review agent. It is not an independent human review and does not replace one.

Reviewed all six changed files at 36c1bc5c64730fd5936a88249077e2eb2c11ea28, including the increment from 696943eaacfefe15d5ed08417fbfd64c72d662cb. The advertised-but-unusable model option for sessions without an LLM connection is fixed. I found no new P0–P2 issue.

The new guard in packages/cli/src/acp/session-configuration.ts:179 omits the model selector when llmConnectionId is null, matching the rejection already enforced by #modelConfigContext in session-registry.ts. Through the real ACP child process, SDK and Runtime Host, I restored a persisted plugin-executor session with no LLM connection: session/load returned only permission, collaboration and orchestration options, and a forced model request returned -32602. Replacing only the projection module with the preceding version makes the same client assertion fail because it advertises model again.

The same client probe verified the ordinary LLM path: two enabled models remain selectable; a third declared but disabled model is omitted and rejected with -32602; changing from a reasoning model to a basic model clears the old thinking level; and switching back on the now-locked connection succeeds. I checked the committed Host state as well as the returned option lists. The use of the existing configuration selector has an independent protocol basis in the ACP session configuration specification.

Validation: 212 original tests across session configuration, registry, stdio server and child-process suites passed, along with fresh dependency installation/patching, the normal clean root test build, CLI type checking, Biome checks for all six files and git diff --check. No Runtime Host protocol files change; the epoch guard accepts 225. The trial merge with main dc4515cd6e7637e8267d59cd4f71ad53f403f9e7 is clean. At this check, exact-head Windows ACP CI succeeds and main test CI is still running.

Two P3 documentation items remain: the PR description still says a locked connection exposes only its current model, whereas the implementation permits same-connection model changes; and the description lacks the required declaration of whether generative tools made a material contribution. Please update that declaration, and add Generated-by: attribution if applicable rather than inferring tool use from the code.

The plugin case restores a real persisted session; it does not launch an external executor. I did not exercise a third-party editor UI, paid model service or Windows locally. The successful local tests do not establish the outcome of the still-running CI job.

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated review notice: This comment was posted by an automated review agent. It is not an independent human review and does not replace one.

Incremental review of 36c1bc5c64730fd5936a88249077e2eb2c11ea28 → bf337224e8b4357d7d090f49478046e94ba16ef8. The single appended commit changes two files: model selection now clears the thinking level only when the selected model actually changes. The same-model side effect is fixed; I found no new P0–P2 issue.

At packages/cli/src/acp/session-configuration.ts:288, re-sending the current model now omits thinkingLevel from the patch, preserving the Host's explicit setting. Through the actual ACP CLI child process, official SDK and Runtime Host, I set high, selected that same model again and confirmed high remained in the response. Switching to a different basic model still cleared the old level, and switching back on the locked connection remained valid. Replacing only the configuration module with its preceding version makes the same client check fail because high becomes default.

The previous controls also pass on this head: a persisted plugin-executor session without an LLM connection advertises no model selector; forced model selection there returns -32602; enabled native models remain offered and a declared-but-disabled model is omitted and rejected.

Validation passed: fresh dependencies and patches, the normal clean root test build, 213 original tests across configuration/registry/stdio/child-process suites, CLI type checking, changed-file Biome checks and git diff --check. The unchanged Host protocol epoch 225 passes the guard; the trial merge with current main dc4515cd6e7637e8267d59cd4f71ad53f403f9e7 is clean. Exact-head Windows ACP CI succeeds; test CI is still queued at handoff.

The P3 description issues remain: the locked-connection explanation is stale, and the required declaration about material generative-tool use is absent. I did not launch an external executor, use a paid model service, test a third-party editor UI or run Windows locally. CI completion remains outstanding.

@2BAB
2BAB force-pushed the feat/acp-model-config-option branch from bf33722 to abf76e7 Compare October 21, 2026 03:34

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated review notice: This comment was posted by an automated review agent. It is not an independent human review and does not replace one.

Reviewed abf76e76ddf6092fea2d3e1446ccf13749a2254b. Its complete source tree is byte-for-byte identical to the previously reviewed bf337224e8b4357d7d090f49478046e94ba16ef8 (tree a0035c06571bd3fe459a152e311f3f58a3cfc281). All seven rewritten commits retain their patches; their changes add AI attribution to commit messages. The PR description now also describes same-connection model switching correctly and declares Claude's contribution. The earlier attribution and description notes are resolved.

No new P0–P2 findings. The unchanged tree retains the previous 213 passing tests and the actual ACP CLI/SDK/Host checks: reselecting the current model preserves high, changing models clears the old thinking level, a locked connection accepts another enabled model from that connection, and unavailable models or Sessions without an LLM connection are rejected. I did not repeat builds or runtime tests for this metadata-only rewrite.

The current windows_acp check passes; test was queued when checked. This review does not treat the old head's green checks as the current head's result. Public third-party executors and paid providers were not exercised.

2BAB and others added 7 commits October 21, 2026 15:24
ACP sessions could change permission, thinking level, collaboration and orchestration modes, but not the model, even though the runtime already accepts an explicit model target.

Adds a select config option, id 'model', projected from the session's own connection catalogue and applied through session/set_config_option as { modelTarget: { kind: 'explicit', connectionId, connectionSlug, model } }.

Two deliberate constraints:

- A locked connection projects only the model the session already has. Listing the rest and refusing every one of them would advertise choices a client cannot take.
- Validation is session-scoped: a value the session's connection does not offer is rejected, and a request with no resolvable catalogue is refused rather than guessed. Option ids stay the Host's; the CLI does not re-derive them.

Generated-by: Claude
setConfigOption pre-validates the request against CONFIG_SPECS before the
per-session work. The model option is not in that static list (its values come
from the session's connection catalogue), so every model change was rejected as
an unsupported configId before reaching the code that can validate it.

The pre-check now narrows the payload only, and the model value is validated in

Generated-by: Claude
#setConfigOption where the session context exists.
The model option listed every entry the connection resolves, including models it
has not enabled. Selecting one of those is refused by the Host (and, on this
build, surfaces as an internal failure), so the list advertised a dead choice.

The projection now keeps entries in the connection's enabledModelIds, plus the
session's current model so an existing selection stays visible even if it was
disabled afterwards.

Generated-by: Claude
Review findings on the model option:

- the picker collapsed to one entry once `connectionLocked` turned true, but
  the Host locks the connection, not the model: it still accepts a
  same-connection switch, and it records the lock on the first durable message
  and on every model change. Offer the connection's models regardless.
- a model change kept the session's thinking level, so the Host refused any
  target model that did not support it. Clear it, as the TUI's `setModel` does.
- an invalid model value reached the client as `internal_failure`: the patch
  builder throws inside the update callback, where the entry-point mapping does
  not run. Map it to `invalid_params` with `requestErrorFromConfigInput`.
- the selection context listed every catalog entry while the picker listed only
  enabled ones. Both now go through `offerableModelChoices`, so a value the
  client can see is a value the Host accepts.

The ACP fixtures never learned about the model option, so their snapshots still
asserted four entries; they now assert five and match the real projection.

Generated-by: Claude
A Session without an LLM connection (a plugin-executor Session) has no
catalogue, and `#modelConfigContext` refuses a model request for exactly that
reason. The projection advertised the option anyway, so the picker offered a
choice that could never be committed. Project it only when the Session has a
connection, and pin that with a test.

Generated-by: Claude
Clearing the level unconditionally also dropped an explicit `high` when a
client re-sent the `currentValue` it already had, which is a no-op selection
with a visible side effect. Clear it only when the selection actually switches
models, where the Host would refuse a target that cannot honour the carried
level.

Generated-by: Claude
@2BAB
2BAB force-pushed the feat/acp-model-config-option branch from abf76e7 to 74118e6 Compare October 21, 2026 07:25

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated review notice: This comment was posted by an automated review agent. It is not an independent human review and does not replace one.

Rebase review at 74118e6b00956dfc7ab52976ffdf8b4ad9588b6f, following abf76e76ddf6092fea2d3e1446ccf13749a2254b. All seven author patches are unchanged, and each of the six files modified by this PR is byte-for-byte identical to the previously reviewed version. The differences in the complete source tree come from main. I found no new P0–P2 issue in this rebase.

I nevertheless rebuilt this exact head with fresh dependencies and the normal root build:test, reran 213 ACP configuration/registry/stdio/child-process tests, and repeated the real ACP CLI/official SDK/Host configuration checks. Reselecting the current model preserves high; changing the model clears the previous thinking level; a locked connection can select another enabled model on that connection; disabled models and Sessions without an LLM connection remain unavailable. CLI type checking passes, and the protocol guard reports no protocol change against current main (epoch 226).

A trial merge with main ff74d21c8f1e2904bb85a00b3ffef98c7834792c is clean; I have not built that merged tree. Exact-head CI has just been approved and is now running. The earlier head's successful checks cannot establish readiness for this head. I did not test third-party editor interfaces or paid providers. This remains a model-selection feature requiring maintainer judgment and successful exact-head CI.

@jackwener jackwener left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed at 74118e6b00956dfc7ab52976ffdf8b4ad9588b6f against current main 5d3a0629a8c7297e968fcc217a0636b23f179712. I found no unresolved P0–P2 issue.

The model selector uses the existing ACP configuration surface and keeps projection and request validation on the same enabled-model rule. A same-model selection preserves the thinking level; a real model switch clears it, and sessions without an LLM connection do not advertise an unusable selector.

Validation completed locally: clean dependency installation with repository patches; Core, Storage, MCP, Runtime, ACP plugins, Runtime Host, Eval, and CLI builds; 13 configuration tests, 157 registry tests, and 26 stdio tests; changed-file Biome; and git diff --check. The full ACP child-process suite also completed after exercising real ACP/Runtime Host model configuration paths. Both exact-head checks (test, windows_acp) are successful, and the current-main merge tree is clean.

Automated review notice: This comment was posted by an automated review agent operated by jackwener. It is not an independent human review and does not replace one.

@github-actions github-actions Bot added the stale No qualifying activity within the lifecycle policy window label Nov 21, 2026
@github-actions

Copy link
Copy Markdown

This pull request has had no new commits for 30 days and has been marked stale. It will be closed in 7 days unless a new commit is pushed.

Comments do not reset this timer: only a new commit does. If the pull request is intentionally long-lived, a maintainer can apply the pinned label.

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

effort/M Under 500 readable lines stale No qualifying activity within the lifecycle policy window

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants