Skip to content

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

Closed
superhighfives wants to merge 1 commit into
anomalyco:devfrom
superhighfives:fix/workers-reasoning-sync-aiden-rebased
Closed

superhighfives wants to merge 1 commit into
anomalyco:devfrom
superhighfives:fix/workers-reasoning-sync-aiden-rebased

Conversation

@superhighfives

Copy link
Copy Markdown
Contributor

Supersedes #5563 with the Workers AI reasoning-control sync rebased onto current dev.

Agent notes

The conflict resolution preserves model-specific Search metadata first, uses input schemas as fallback, retains safer pagination, and refreshes generated comments without deleting authored rationale.

Verified with the focused Workers AI tests (27 passed) and bun validate. The PR contains one commit changing three files.

@github-actions

Copy link
Copy Markdown
Contributor

Action items

  • [critical] [violation] packages/core/src/sync/providers/cloudflare-workers-ai.ts:168 - Check: Sync provider must return a defined header value. Why: The fallback return { id, model: buildWorkersAiModel({ ...model, reasoning: undefined }, existing), header, } references header after the diff deletes const header/preservedHeader/hasToggleWire, so any existing toggle model with input_schema and no allowlisted toggleHeader throws ReferenceError instead of preserving catalogue reasoning. Action: Return header: undefined (or omit header) so syncProvider preserves currentHeader via updateHeader path, and verify TypeScript compiles.
  • [high] [violation] packages/core/src/sync/providers/cloudflare-workers-ai.ts:141 - Check: New reasoning models without concrete controls must fail closed with MissingReasoningOptionsError and must not get [] from uncertainty. Why: The new guard adds model.input_schema !== undefined to both the missing-controls throw and the unknown-toggle-wire check, so a new hasReasoning model with no input_schema skips the throw and the runner later stamps reasoning_options = [], and a toggle with no wire passes through with header: undefined. Action: Remove the input_schema !== undefined conditions so absent schemas still fail closed per-model.
  • [high] [possible mistake] packages/core/src/sync/providers/cloudflare-workers-ai.ts:111 - Check: Per-model schema failures must not abort the whole provider sync. Why: fetchModels now awaits fetchSchema for every model with no retry and throws on any non-ok/parse/missing-input, so one 403/404/transient rejects fetchModels and blocks all Workers AI updates, unlike search pagination which keeps successful pages and unlike cloudflare-ai-gateway which returns undefined on 404 and fails per-model via MissingReasoningOptionsError. Action: Catch per-model schema errors/404s to input_schema = undefined with retry, letting translateModel/runner preserve curated files or emit per-model notices.
  • [medium] [violation] packages/core/src/sync/providers/cloudflare-workers-ai.ts:95 - Check: Preserve hand-authored toggle wire paths and do not replace them with generic schema controls. Why: updateHeader strips every # Toggle:/# Effort:/# Budget: line and the new translateModel drops the old hasToggleWire check for thinking.type/chat_template_kwargs.thinking/enable_thinking, so curated DeepSeek/Kimi/Qwen split-line wire notes are deleted when a schema header arrives, and allowlisted-only toggleHeader logic warns/strips reasoning that was previously preserved. Action: Restore the curated-wire exemption before stripping/overwriting control comments, or scope updateHeader to only replace the exact generated Reasoning controls declared.../chat_template_kwargs.enable_thinking lines.

@superhighfives

Copy link
Copy Markdown
Contributor Author

Closing as superseded by #7453 and #7454.

@superhighfives
superhighfives deleted the fix/workers-reasoning-sync-aiden-rebased branch September 24, 2026 16:41
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