Skip to content

fix(opencode): set KimiCLI/1.5 User-Agent for kimi-for-coding provider#27903

Open
bzqzheng wants to merge 2 commits into
anomalyco:devfrom
bzqzheng:fix/kimi-for-coding-user-agent
Open

fix(opencode): set KimiCLI/1.5 User-Agent for kimi-for-coding provider#27903
bzqzheng wants to merge 2 commits into
anomalyco:devfrom
bzqzheng:fix/kimi-for-coding-user-agent

Conversation

@bzqzheng
Copy link
Copy Markdown

@bzqzheng bzqzheng commented May 16, 2026

Issue for this PR

Closes #27902

Type of change

  • Bug fix

What does this PR do?

The built-in kimi-for-coding provider uses @ai-sdk/anthropic, which sends Anthropic/JS x.x.x as the default User-Agent. Kimi's /coding gateway intermittently 429s requests from non-whitelisted agents — setting User-Agent: KimiCLI/1.5 significantly reduces these errors in practice.

The fix sets User-Agent: KimiCLI/1.5 in model.headers inside fromModelsDevModel. This is the correct layer because llm.ts spreads input.model.headers at line 382, after the hardcoded opencode/${InstallationVersion} UA at line 380, so model-level headers win.

Setting it in custom() via options.headers (the pattern used by Cloudflare/GitLab) does not work here — options.headers only reaches the SDK constructor level and is overridden by the call-level headers in llm.ts. This was broken by the revert in #12072 and is tracked as open issue #24594.

How did you verify your code works?

Observed significantly fewer 429 "engine overloaded" errors after applying the User-Agent: KimiCLI/1.5 override. bun turbo typecheck passes clean.

Checklist

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

bzqzheng added 2 commits May 16, 2026 12:31
Set via model.headers so it spreads after the default opencode UA
in llm.ts streamText headers, ensuring it takes precedence.
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.

fix: kimi-for-coding provider gets 429 engine overloaded due to missing User-Agent header

1 participant