fix(opencode): set KimiCLI/1.5 User-Agent for kimi-for-coding provider#27903
Open
bzqzheng wants to merge 2 commits into
Open
fix(opencode): set KimiCLI/1.5 User-Agent for kimi-for-coding provider#27903bzqzheng wants to merge 2 commits into
bzqzheng wants to merge 2 commits into
Conversation
Set via model.headers so it spreads after the default opencode UA in llm.ts streamText headers, ensuring it takes precedence.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #27902
Type of change
What does this PR do?
The built-in
kimi-for-codingprovider uses@ai-sdk/anthropic, which sendsAnthropic/JS x.x.xas the defaultUser-Agent. Kimi's/codinggateway intermittently 429s requests from non-whitelisted agents — settingUser-Agent: KimiCLI/1.5significantly reduces these errors in practice.The fix sets
User-Agent: KimiCLI/1.5inmodel.headersinsidefromModelsDevModel. This is the correct layer becausellm.tsspreadsinput.model.headersat line 382, after the hardcodedopencode/${InstallationVersion}UA at line 380, so model-level headers win.Setting it in
custom()viaoptions.headers(the pattern used by Cloudflare/GitLab) does not work here —options.headersonly reaches the SDK constructor level and is overridden by the call-level headers inllm.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.5override.bun turbo typecheckpasses clean.Checklist