Skip to content

[AISAGE-734] fix(ai-gateway): strip message names for OpenCode Go chat completions - #7770

Merged
chrarnoldus merged 1 commit into
mainfrom
fix/opencode-go-strip-message-names
Oct 16, 2026
Merged

chrarnoldus merged 1 commit into
mainfrom
fix/opencode-go-strip-message-names

Conversation

@chrarnoldus

@chrarnoldus chrarnoldus commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Problem

OpenCode Go BYOK requests to glm-5.3-flash fail with a 400:

[BYOK] Upstream request failed: [unsupported_parameter] messages[3]: "name" is not supported by this endpoint

Production errors are all for opencode-go/glm-5.3-flash, starting 2026-10-16. The logged messageFields include name.

Tested directly against https://opencode.ai/zen/go/v1/chat/completions: glm-5.3-flash rejects name on user, assistant, and tool messages. glm-5.3 and kimi-k2.6 accept it.

Fix

The OpenCode Go provider now strips name from every Chat Completions message, alongside the user-tracking fields it already removes. The OpenCode Go transform handles all of its models, so a strict upstream for a new model won't hit the same error.

Verification

  • New unit test in opencode-go.test.ts. Direct BYOK provider suites pass (7 suites, 74 tests).
  • pnpm --filter @kilocode/web-shared typecheck passes, and oxlint passes on the changed files.
  • Live check: the same glm-5.3-flash tool-call conversation without name succeeds upstream.

Failure UX: requests that used to fail with a non-retryable 400 now succeed. No new waiting or retry behavior.

Root cause

This is a regression from #7586 (merged 2026-10-16 08:02 UTC). Before that change, the catalog told clients to use the openai-compatible AI SDK provider for OpenCode Go models. The catalog now sends no ai_sdk_provider, so clients fall back to @openrouter/ai-sdk-provider. That provider adds name: toolName to every tool message, and openai-compatible never did. The first error was at 12:06 UTC.

Why it's intermittent

OpenCode Go pins each x-opencode-session to one backend. glm-5.3-flash (and omen-alpha, which is also routed to perplexity-glm5.3flash) is served by several backends: zai, relace, particle, pareto-glm, pearlresearch, and perplexity-glm5.3flash. Only the Perplexity backend rejects name. A session pinned to Perplexity fails on its first tool result (messages[3..5] in every prod error) and keeps failing for the rest of that session. Sessions pinned to other backends work.

@chrarnoldus chrarnoldus self-assigned this Oct 16, 2026
@kilo-code-bot

kilo-code-bot Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

The OpenCode Go transform change correctly and unconditionally strips OpenAI name from Chat Completions messages, and the added unit test covers user, assistant, and tool message roles without regressions in the surrounding behavior.

Files Reviewed (3 files)
  • packages/web-shared/src/lib/ai-gateway/providers/direct-byok/opencode-go.ts
  • packages/web-shared/src/lib/ai-gateway/providers/openrouter/request-helpers.ts
  • packages/web-shared/src/lib/ai-gateway/providers/direct-byok/opencode-go.test.ts

Notes

  • The new removeChatCompletionsMessageNames is a strict superset of the existing removeChatCompletionsToolNames; the removal is scoped to chat_completions only and mutates the request body in place, matching neighboring direct-BYOK providers (e.g. nvidia-byok.ts). Blanket stripping is the documented, intentional trade-off.
  • No .md documentation or new HTML <img> usage is introduced, so the markdown image guidance does not apply.
  • No new timers, listeners, caches, or unbounded allocations are introduced, so no memory-leak concern.

Reviewed by deepseek-v4.1-flash · Input: 46.1K · Output: 8.2K · Cached: 453.8K

Review guidance: REVIEW.md from base branch main

@joshburt
joshburt self-requested a review October 16, 2026 16:36
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