Skip to content

fix(cloudflare): sync reasoning controls from model schemas - #5563

Closed
opencode-agent[bot] wants to merge 2 commits into
devfrom
fix/workers-reasoning-sync-aiden
Closed

opencode-agent[bot] wants to merge 2 commits into
devfrom
fix/workers-reasoning-sync-aiden

Conversation

@opencode-agent

@opencode-agent opencode-agent Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fetch each Cloudflare Workers AI model's input schema and sync the reasoning controls it declares.

The format=openrouter catalog advertises reasoning as a feature but currently contains no per-model reasoning objects. Simply retaining the shared translator's computed options is not enough: the sync needs the separate model-schema endpoint to discover the controls.

  • Fetch every listed model's schema in batches of four, with a 30-second timeout per schema request. Fail the sync on failed or malformed schema responses rather than writing a partial catalog.
  • For catalog-tagged reasoning models, read explicit reasoning_effort / reasoning.effort enums and the chat_template_kwargs.enable_thinking boolean through request-schema anyOf / oneOf alternatives.
  • Preserve curated fallback options when the schema has no usable controls. Do not infer reasoning capability from generic schema fields, invent effort levels from null, or treat completion-token limits as reasoning budgets.
  • Keep explicit catalog reasoning metadata when supplied instead of unconditionally overwriting it with stale authored options.
  • Refresh schema-derived reasoning comments, including toggle wire paths, while preserving unrelated notes and source links. Header-only updates are idempotent, and other providers retain their existing header behavior.

No catalog TOMLs or credentials are included in this change. Schema declarations describe the provider's advertised API surface; this does not claim inference-tested behavioral differences between effort levels.

Live verification

Read-only API checks on 2026-08-26:

  • The marketplace catalog returned 26 models, 15 tagged as reasoning, and no reasoning objects.
  • All 26 model-schema requests succeeded through the updated fetch/parse/translate path.
  • GLM-5.3-Flash's schema declares reasoning_effort = low|medium|high and chat_template_kwargs.enable_thinking = true|false. GPT-OSS declares nested reasoning.effort without that toggle.
  • The full dry run reports 1 create, 11 updates (including comment-only refreshes), 0 deletions, and 14 unchanged entries. No inference calls or catalog writes were performed.

Sources: Cloudflare model search and model-schema endpoint.

Validation

  • Regression tests reproduced discarded metadata, missing per-model schema fetches, and missing schema-derived controls before their fixes.
  • bun test packages/core/test/cloudflare-workers-ai-sync.test.ts: 24 pass, including fetch failures, schema extraction, curated fallback, serialized header preservation, and repeat-sync idempotence.
  • bun test packages/core/test/sync.test.ts --test-name-pattern 'OpenRouter|reasoning options|reasoning efforts|reasoning metadata|reasoning controls|header': 32 pass.
  • bun models:sync cloudflare-workers-ai --dry-run --no-issues: passes against the live API.
  • bun validate and git diff --check: pass.
  • The broader sync suite still fails DeepInfra preserves live modalities for new base models; this was reproduced without the Cloudflare fix and is outside this change.
  • Package-wide typecheck remains blocked by existing diagnostics, including the shared runner's SyncedMetadata.reasoning_options access. No diagnostics in the changed Cloudflare provider or its tests.

Requested by: @rekram1-node (Aiden via Slack)

@github-actions

Copy link
Copy Markdown
Contributor

No actionable findings.

@github-actions github-actions Bot added the reviewer: ready Automated review found no actionable items label Aug 26, 2026
@opencode-agent opencode-agent Bot changed the title fix(cloudflare): sync explicit API reasoning controls fix(cloudflare): sync reasoning controls from model schemas Aug 26, 2026
@github-actions github-actions Bot removed the reviewer: ready Automated review found no actionable items label Aug 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Action items

  • [high] [violation] packages/core/test/cloudflare-workers-ai-sync.test.ts:66 - Check: Temp dirs in tests must be created under an existing parent (repo convention: path.join(tmpdir(), …)). Why: mkdtemp("/tmp/opencode/workers-schema-") requires /tmp/opencode to already exist; on a clean runner that path is missing, so the header-refresh/idempotence test throws ENOENT instead of validating sync behavior. Action: Create the temp dir with path.join(tmpdir(), "workers-schema-") (and import tmpdir from node:os), matching the other sync tests.

@superhighfives

superhighfives commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Got an MR to fix this, @rekram1-node: #7920

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.

2 participants