Skip to content

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

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

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

Conversation

@bzqzheng

@bzqzheng bzqzheng commented May 16, 2026 •

Copy link
Copy Markdown

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.
@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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.

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

1 participant