Skip to content

fix(cli): identify Kilo in LLM user agent - #11347

Merged
markijbema merged 3 commits into
mainfrom
mark/fix-llm-user-agent-main
Jun 17, 2026
Merged

fix(cli): identify Kilo in LLM user agent#11347
markijbema merged 3 commits into
mainfrom
mark/fix-llm-user-agent-main

Conversation

@markijbema

Copy link
Copy Markdown
Contributor

What

Fix provider request User-Agent headers emitted by the CLI LLM streaming path so they identify Kilo instead of OpenCode.

The LLM request code now uses the existing Kilo installation USER_AGENT value instead of hardcoding opencode/${InstallationVersion}. This covers both the Kilo-provider branch and the general provider branch before the AI SDK appends its own suffixes.

Why

We observed provider/request logging with a header like:

opencode/7.3.46 ai-sdk/provider-utils/4.0.23 runtime/bun/1.3.14

The ai-sdk/provider-utils/... runtime/bun/... suffix is appended by the AI SDK via its withUserAgentSuffix helper. The incorrect opencode/<version> prefix came from our code in packages/opencode/src/session/llm.ts, where two branches passed:

"User-Agent": `opencode/${InstallationVersion}`

There is already a Kilo-specific installation helper in packages/opencode/src/installation/index.ts that returns the canonical Kilo user-agent value. The bug was that the LLM path bypassed that helper.

Regression Analysis

This does not appear to be a new 7.3.46 regression. Git history shows the hardcoded LLM header was introduced by:

fc6d4b4010 core: Add User-Agent header to identify client version in HTTP requests

That commit dates to Apr 25, 2026, and is contained by many later tags. The later Kilo compatibility refactor:

6ecaaab48a refactor: kilo compat for v1.14.51

updated the installation helper to return Kilo branding, but did not update this session/llm.ts call site. So the bad prefix survived specifically on paths where DEFAULT_HEADERS does not overwrite it, such as Anthropic and Kilo-provider requests.

Testing

  • bun test ./test/session/llm.test.ts from packages/opencode/
  • bun run script/check-opencode-annotations.ts from repo root

@markijbema
markijbema marked this pull request as ready for review June 17, 2026 09:45
@kilo-code-bot

kilo-code-bot Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • .changeset/fix-llm-user-agent.md
  • packages/opencode/src/session/llm.ts
  • packages/opencode/test/session/llm.test.ts

Reviewed by deepseek-v4-pro-20260423 · 263,855 tokens

Review guidance: REVIEW.md from base branch main

@markijbema
markijbema enabled auto-merge June 17, 2026 11:30
@markijbema
markijbema merged commit fb6b5ed into main Jun 17, 2026
23 checks passed
@markijbema
markijbema deleted the mark/fix-llm-user-agent-main branch June 17, 2026 11:32
t7tran pushed a commit to t7tran/kilocode that referenced this pull request Aug 14, 2026
…nt-main

fix(cli): identify Kilo in LLM user agent
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