Skip to content

fix(provider): normalize cloudflare-workers-ai mixed message content#30589

Open
ulises-jeremias wants to merge 6 commits into
anomalyco:devfrom
ulises-jeremias:fix/30381-cloudflare-workers-ai-message-content-shape
Open

fix(provider): normalize cloudflare-workers-ai mixed message content#30589
ulises-jeremias wants to merge 6 commits into
anomalyco:devfrom
ulises-jeremias:fix/30381-cloudflare-workers-ai-message-content-shape

Conversation

@ulises-jeremias

@ulises-jeremias ulises-jeremias commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #30381

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Cloudflare Workers AI can reject requests when message content mixes string content with array content. This PR normalizes mixed payloads into a consistent string form only when it is safe:

  • detects mixed string + array message content for cloudflare-workers-ai
  • flattens text-only array messages into newline-joined strings
  • keeps tool messages and non-text array content unchanged
  • adds regression tests for the mixed-content path and non-regression cases

How did you verify your code works?

  • bun test test/provider/transform.test.ts (from packages/opencode)
  • bun typecheck (from packages/opencode)

Screenshots / recordings

N/A (no UI changes)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Jun 3, 2026
@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@ulises-jeremias

ulises-jeremias commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

Updated the PR description to match the required template sections (Issue, Type of change, What this PR does, verification, and checklist)

Re-verified locally from packages/opencode:

  • bun test test/provider/transform.test.ts
  • bun typecheck

…nt-shape

* upstream/dev: (715 commits)
  chore: update nix node_modules hashes
  feat(oauth): unify OAuth callback browser pages (anomalyco#34025)
  chore: generate
  refactor(app): replace tab drag handling with dndkit (anomalyco#33880)
  refactor(app): use dropdown for project selector (anomalyco#33984)
  chore: update nix node_modules hashes
  fix(app): bump ghostty-web to prevent terminal resize hangs (anomalyco#34020)
  chore: generate
  feat(sdk): expose active sessions (anomalyco#33991)
  fix(sdk): wake embedded session execution (anomalyco#33992)
  refactor(opencode): stop legacy v2 event emission (anomalyco#33993)
  fix(ui): normalize tooltip trigger layout (anomalyco#33979)
  fix(app): suspend hidden terminal renderer (anomalyco#33990)
  fix(app): enable auto-accept in session settings (anomalyco#33974)
  tweak: hide MCP access token prefix (anomalyco#33711)
  fix(core): refine small model defaults (anomalyco#33926)
  feat(core): split MCP timeout configuration (anomalyco#33977)
  fix(app): simplify question prompt (anomalyco#33968)
  feat(llm): pass strict through tool definitions for Codex parity (anomalyco#33392)
  chore: generate
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AiError: Bad input when using Cloudflare Workers AI — message content format mismatch

1 participant