Skip to content

Discover selected ACP reasoning and preserve unset execution levels - #6486

Merged
ymichael merged 6 commits into
mainfrom
bb/4367-selected-reasoning-complete
Oct 29, 2026
Merged

ymichael merged 6 commits into
mainfrom
bb/4367-selected-reasoning-complete

Conversation

@ymichael

@ymichael ymichael commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

ACP's bounded catalog scan (five seconds) reaches only part of a large model list. For models it didn't reach, BB showed a fabricated single "Medium" reasoning choice and sent that setting to the agent, replacing the agent's own reasoning setting with a level the user never chose. Replaces #6477.

What changed

  • ACP catalog: models whose reasoning levels haven't been checked report an empty list instead of a fake Medium, so the picker shows no reasoning control for them.
  • Selected-model discovery: selecting such a model asks the agent for that one model's levels in a separate probe (30 s agent startup, 5 s probe; deduplicated). The picker shows the real choices when they arrive. Discovered levels survive later full refreshes and live-session catalogs. Failed probes retry after 30 s; a probe the agent answers without levels isn't repeated until the catalog is invalidated. Also available through bb provider models --selected-model and the SDK selectedModel query.
  • AvailableModel.reasoningDiscovery: "unknown" | "known": distinguishes "not checked yet" from "checked, no selectable levels". Defaults to "known", so only providers that mark models unknown (ACP) get probed. This flag only drives probing; it has no effect on what is sent.
  • Send rule (server-to-daemon command boundary): the stored reasoning preference stays required. BB sends it unless the cached catalog lists the model without that level, in which case it leaves reasoning out and the agent keeps its own setting. A model missing from the cache (cold or ephemeral-host catalogs) is sent as before. New worktree threads fall back to the project checkout's catalog, which is what the picker reads. The lookup is a synchronous in-memory/DB read with no plugin calls. Sending never waits for discovery.
  • Versions: Plugin SDK 0.6.98 (new reasoningDiscovery field and selectedModel model-list param); host-daemon protocol 258 (provider.list_models.selectedModel, and options.reasoningLevel may be absent).

No database migration. NewThreadRequest.reasoningLevel and queued-message reasoning stay required.

Behaviour changes

  • ACP models with unchecked levels: no fake Medium in the picker, and no reasoning level sent until the levels are known.
  • Any provider: a stored reasoning level the cached catalog doesn't list for the selected model is no longer sent.

How you verified

  • thread-command-reasoning.test.ts covers start and follow-up commands across unknown, unprobed-with-levels, confirmed-empty, unsupported, supported and uncatalogued models, plus host/workspace catalog scoping. Against the previous discovery-gated rule it fails (unprobed-with-levels: expected undefined to be 'high'); it passes with this change.
  • Catalog store regressions (each fails on the previous store code): discovered levels survive a full refresh and a live-session catalog; a probe settling after a concurrent full refresh is applied; an agent that answers without levels isn't probed again.
  • Full server suite: 3,735 passed, 1 skipped. App model-selection, picker and composer tests: 373 passed. ACP bridge, host daemon, host-daemon/server contracts, domain and template suites passed. Typecheck and lint passed for every changed package.
  • Earlier revision: live QA against an 836-model fake ACP agent showed real Low/Medium/High appearing for a late model after selection, and no effort setting on the wire for unknown models.

Fixes #4367

AGENT GENERATED

🤖 Generated with Claude Code

@ymichael
ymichael force-pushed the bb/4367-selected-reasoning-complete branch 2 times, most recently from 0902333 to 33eb9a8 Compare October 28, 2026 22:25
Port the complete approach from PR #4391 to current main, preserving current environment contribution, session catalog, service tier, and queued-message behavior. Probe a selected unadvertised ladder on demand and preserve absent inferred reasoning through server, runtime, queue, retry, and fork paths. Keep explicit CLI/SDK levels. Includes migration, protocol 258, and Plugin SDK 0.6.99.
@ymichael
ymichael force-pushed the bb/4367-selected-reasoning-complete branch from 5a8aa05 to d935791 Compare October 28, 2026 22:58
ymichael and others added 2 commits October 28, 2026 20:42
…eftovers

The provider boundary no longer requires reasoningDiscovery to be "known":
a level is sent when the cached catalog lists it, or when the model is not
in the cache (cold or ephemeral-host catalogs keep their existing behaviour).
reasoningDiscovery now only decides whether the picker probes a model.

Restore required ReasoningLevel types in the app, stop persisting an empty
reasoning preference, revert unrelated formatting churn, and bump the plugin
SDK and host-daemon protocol one step above main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…obes

- Full refreshes and live-session catalogs keep a model's discovered
  reasoning when they report it unknown; a selected-model probe that settles
  after a concurrent refresh is no longer discarded.
- A probe the agent answers without levels is not repeated until the catalog
  is invalidated; failures keep the 30 s cooldown.
- reasoningDiscovery defaults to "known", so only providers that mark models
  unknown (ACP) are probed.
- ACP selected-model discovery gets the normal 30 s startup budget and a full
  5 s probe.
- The send-time catalog lookup is synchronous, skips plugin env resolution,
  creates no cache entries, and falls back to the project checkout catalog
  for new worktrees.
- Declare selectedModel on the daemon listModels type and reuse the base
  catalog selection when no discovered catalog replaces it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit 9f7c6eb into main Oct 29, 2026
52 checks passed
@ymichael
ymichael deleted the bb/4367-selected-reasoning-complete branch October 29, 2026 04:50
mistakeknot added a commit to mistakeknot/aleph that referenced this pull request Nov 3, 2026
Sync Aleph to upstream bb 9f7c6eb (get-bb#6486, resolves plugin-api-docs surfaces.ts)
ymichael added a commit that referenced this pull request Nov 17, 2026
… selected-model probe (#7646)

## Human comments

## What was wrong

To read each model's reasoning levels, ACP-native model discovery
switched the agent through every model in its `model` config option with
`session/set_config_option` (`discoverAcpNativeModelSupport` in
`packages/provider-bridge-acp/src/bridge/bridge.ts`), and never switched
back. ACP has no read-only way to ask about another model, so a catalog
refresh became up to one settings write per model. Agents that save each
switch as the user's default, as Prime Agent documents, ended every
refresh on the last model probed. A reasoning level clamped during a
switch was saved too. The 5 s sweep budget also meant large catalogs
were only partly probed, so models beyond the budget already relied on
the selected-model discovery added in #6486.

T3 Code never switches models to discover them. It reads the session's
initial configuration, takes per-model levels from model metadata when
present, and otherwise learns them from real sessions.

This supersedes #7503 by @lanjak. That PR restores the model after the
sweep, but the restore is skipped when the 5 s timeout fires (the
reporter's bursts reached it), and the clamped reasoning level is not
restored. Their commit is kept on this branch.

## What changed

- `packages/provider-bridge-acp/src/bridge/bridge.ts`:
- Listing models reads only the levels the agent reports for its current
model and sends no `session/set_config_option`. Other models report
`reasoningDiscovery: "unknown"`, which the server and picker already
handle: selecting such a model triggers selected-model discovery.
- Selected-model discovery switches to that one model (same 5 s budget,
and the same one retry for an unconfirmed reply). It then sets the
session's starting model back, followed by every other option whose
value changed (reasoning level, Fast). This runs after success, failure
and timeout, within a 10 s restore budget, before the existing session
teardown.
- Removed `reasoningProbePriorityModelIds`, which only ordered the
removed sweep. It is gone from the Cursor and Grok known-agent profiles,
the plugin's bridge options and the bridge option schema. The bridge
schema is passthrough, so an older plugin that still sends the field is
accepted.
- `plugins/provider-acp/skills/acp-provider/SKILL.md` describes the new
discovery and restore behavior.
- Model picker (`apps/app`): this change sends more models through
selected-model discovery. While it ran, the picker hid the Reasoning
section and the trigger's level label, so the model looked like it had
no reasoning, and the popup grew when the levels arrived.
`useThreadCreationOptions` now returns `isLoadingReasoning` while that
query is pending (false once it settles, including when it returns no
levels). `ExecutionControls` and `PluginProviderModelPicker` pass it to
`ModelReasoningPicker`, which keeps the Reasoning heading with three
skeleton toggles of the buttons' height and shows a skeleton in place of
the trigger's level label.

No server/daemon wire change: `selectedModel` already exists (protocol
258), and provider options are opaque to the daemon.

Behavior change: right after a catalog refresh, only the agent's current
model shows reasoning choices. Other models show them once selected,
after one short probe. Models past the old 5 s budget already worked
this way.

## How you verified

- New bridge tests, which fail against `origin/main`'s `bridge.ts` and
pass with this change:
- listing a 3-model catalog sends no `session/set_config_option`, and
only the current model's levels are known;
- after a selected probe that changes the model and clamps the reasoning
level, the bridge sends `model=<starting>` then `effort=<starting>`;
  - the model is restored after a failed probe;
  - the model and effort are restored after a timed-out probe.
- Sweep-only tests removed. The stale-reply, Cursor and
empty-thought-level tests now use selected-model discovery.
- `pnpm exec turbo run lint lint:type-aware typecheck test
--filter=@bb/provider-bridge-acp --filter=bb-plugin-provider-acp`: 590
passed / 4 skipped, and 85 passed; 0 lint warnings. `oxfmt --check` is
clean.
- Live in a `pnpm start:worktree` instance with a custom ACP agent that
saves each model switch and clamped reasoning level to a settings file,
as Prime does:
- Before (main): one `bb provider models acp-saver` changed the saved
default from `acme/alpha` to `acme/delta`.
- After: server start and `bb provider models` sent no switches, and
settings were unchanged.
- `--selected-model acme/delta` logged `set model acme/delta`, `clamped
effort high`, `set model acme/alpha`, `set effort medium`. It ended at
`alpha/medium` with delta's levels `["high"]`.
- `--selected-model acme/gamma` restored only the model, because nothing
was clamped.
- Picker skeleton: `useThreadCreationOptions.test.tsx` now checks that
`isLoadingReasoning` is true while selected-model discovery is pending,
false once the levels arrive, and false when discovery returns no
levels. `turbo run typecheck lint --filter=@bb/app` passes, and the 17
affected app test files pass (378 tests). In the worktree instance, with
an agent that takes 3 s per change, picking an unchecked model showed 3
menu skeletons and 1 trigger skeleton with no reasoning radios. About 9
s later it showed the 3 real radios and no skeletons, and the popup kept
its height.
- Known limit: with an agent that takes 5.5 s per setting change, the
model was restored but the reasoning-level restore exceeded the 10 s
budget.

Fixes #4478

> AGENT GENERATED

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: rufi <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

ACP reasoning discovery covers ~80 models, so most omp models show a fake single "Medium" that is then sent to the agent

1 participant