Skip to content

fix: support real thinking capability catalog shapes - #278

Merged
hffmnnj merged 6 commits into
mainfrom
feat/thinking-capability-shapes
Aug 3, 2026
Merged

hffmnnj merged 6 commits into
mainfrom
feat/thinking-capability-shapes

Conversation

@hffmnnj

@hffmnnj hffmnnj commented Aug 3, 2026

Copy link
Copy Markdown
Owner

Summary

  • extract supported thinking levels from reasoning_options and object-map variants
  • preserve existing array-variant and legacy capability behavior
  • return a variant identifier when the host owns request encoding
  • retain exact fallback warnings and no-downgrade behavior

Verification

  • 33 thinking tests passed with 0 failures
  • TypeScript typecheck passed
  • lint passed

hffmnnj and others added 6 commits August 2, 2026 21:08
resolveCapabilities only recognized array-form variants and V1
capabilities.reasoning + options. The live OpenCode catalog publishes
top-level reasoning:true plus reasoning_options[{type:"effort",
values:[...]}] with no variants field, so extraction returned EMPTY and a
genuinely-supported level (e.g. "high") triggered the preserve-default
warning.

Teach extraction the real id-only shapes while leaving existing paths
intact:

- reasoning_options: prefer entries with type==="effort"; fall back to
  string values across all entries only when no effort entry exists.
  Numeric fields (e.g. budget_tokens) are ignored.
- object-map variants (e.g. {high:{...}}): collect keys as supported ids,
  including headerless entries. No request headers/bodies are fabricated.
- id-only results carry raw={source:"v2", variants:[]} so source
  discrimination is preserved without inventing request encodings.
- array-variants and V1 paths, EMPTY fallback, and try/catch degradation
  are unchanged.

Tests authored red first; the focused run bailed after 3 failures
(supported=[] for the reasoning_options shape) before this change and
passes 18/18 after.
resolveThinkingValue returned preserve-default whenever a V2 capability
source had no full ThinkingVariant object for the requested id, even
when extraction (from reasoning_options or object-map variants) had
already confirmed the id is genuinely supported. On the live openai
catalog a level like "high" therefore triggered the preserve-default
warning and never reached the provider.

Smallest coherent fix: for a V2-source supported candidate with no
matching full variant, return {apply: candidate, source: "v2"} (the
honest string id). The full-variant object path returns the exact
stored variant unchanged; the V1 path, preserve-default warning,
never-downgrade semantics, none-as-a-real-value handling, and
THINKING_LABEL_CANDIDATES identity are all untouched. No variants are
synthesized and no request headers/bodies are fabricated.

Tests authored red first; the focused run bailed with 2 failures
(id-only "high" and id-only "none" returned preserve-default) before
this change and passes 33/33 after.
…ordering

- applyThinkingLevelsToAgents now sets agent.model.variant for honest
  string resolutions (id-only V2 matches) instead of silently discarding
  them. No headers/body are fabricated for a string apply.
- captureCatalogCapabilities builds a fresh Map per refresh and the shared
  reference is swapped only after full population, replacing the previous
  clear-then-repopulate-in-place pattern. A reentrant agent transform
  racing a catalog refresh now always observes a complete snapshot.
- registerThinkingLevelAgentTransform deduplicates the initial-registration
  and reload code paths through a shared refresh() closure; behavior is
  unchanged (catalog transform before agent transform, in both paths).

Tests: 3 new cases covering the string-apply path, the unsupported-level
warning path, and reentrancy/capture-ordering safety. All prior hooks-v2
coverage (full-variant merge, live reload rerun) passes unchanged.
Add a redacted real-shape parity fixture to dual-contract.test.ts asserting
that equivalent V1 (capabilities.reasoning + options) and real-shape V2
(reasoning + reasoning_options effort) host payloads produce the same
supported thinking-level set through the shared resolveCapabilities
extractor, and that every canonical label resolves on both contracts.

Add a defensive V1 chat.params test to agent-registration.test.ts
documenting the precise posture when the catalog exposes only the
real-shape effort options: resolveCapabilities classifies it as a V2
id-only match, getVerifiedV1RequestOption returns undefined, and the
hook emits the documented 'no unambiguous V1 request option' diagnostic
while preserving the provider default. The V2 adapter handles the same
shape via the string apply path.

agent-registration.ts is deliberately untouched: the new V1 test passes
green on first run, proving the Wave 1 shared extraction change does
not break V1. No speculative source edit (ADL Rule 4).

Verification:
- dual-contract.test.ts: 15 pass, 0 fail, 66 expect() calls
- agent-registration.test.ts: 13 pass, 0 fail, 23 expect() calls
- features/setup/: 93 pass, 0 fail, 259 expect() calls (non-regression)
- typecheck: clean; lint: 0 warnings in edited files
…real-shape catalog

Add the Pattern 4 wiring proof for the live host capability shape that
caused the original defect: a catalog publishing reasoning:true +
reasoning_options (no variants). A configured agentThinkingLevels value
for a goop-* role reaches the V2 consumer, sets agent.model.variant
without a preserve-default warning and without fabricated headers/body,
and changing the configured level changes the applied variant on reload.

Document the reasoning_options-vs-variants catalog gotcha in AGENTS.md.
fix: apply configured thinking levels through V2
@hffmnnj
hffmnnj merged commit 18b6346 into main Aug 3, 2026
0 of 2 checks passed
@hffmnnj
hffmnnj deleted the feat/thinking-capability-shapes branch August 3, 2026 10:28
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