fix(cli): prefix environment_details block with a textual separator - #13131
fix(cli): prefix environment_details block with a textual separator#13131santhiprakash wants to merge 2 commits into
Conversation
| @@ -0,0 +1,5 @@ | |||
| --- | |||
| "kilo-code": patch | |||
There was a problem hiding this comment.
WARNING: Changeset targets the wrong package
This PR only changes packages/opencode/ (published as @kilocode/cli), but the changeset bumps "kilo-code" (the VS Code extension package). Comparable CLI-only fixes in this repo (e.g. memory-sse-json.md, trim-inferred-variants.md) use "@kilocode/cli": patch. As written, the CLI package won't get a version bump or release note for this fix. Consider targeting @kilocode/cli (or both packages, if the extension release should also ship the note).
| "kilo-code": patch | |
| "@kilocode/cli": patch |
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
Code Review SummaryStatus: No Issues Found | Recommendation: Merge The previous finding (changeset targeted Files Reviewed (5 files)
Previous Review Summary (commit dd2384b)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit dd2384b)Status: 1 Issue Found | Recommendation: Address before merge Overview
The core fix is sound: the Issue Details (click to expand)WARNING
Files Reviewed (5 files)
Reviewed by kimi-k3 · Input: 45K · Output: 2.7K · Cached: 201.2K Review guidance: REVIEW.md from base branch |
Issue
Fixes #13110
Context
The user prompt and the auto-generated
<environment_details>block are sent as two separate text content parts in the same user message. When the second part immediately follows a write-tool argument, some OpenAI-compatible providers can interpret the<environment_details>block as a continuation of that argument, leaking it into tool arguments.The issue already reproduced this leak 6/6 times; prefixing the block with
\n\nreduced it to 0/6.This is a core CLI/provider prompt-construction change, not a visible UI change.
Implementation
packages/opencode/src/kilocode/editor-context.ts: prefix the generated<environment_details>block with\n\nso it is clearly separated from the preceding text.packages/opencode/src/provider/transform.ts: usetrimStart().startsWith(...)when skipping the trailing block for prompt-cache breakpoint placement, so the detection still matches the new leading whitespace.packages/opencode/test/kilocode/system-prompt.test.tsandpackages/opencode/test/provider/transform.test.ts.Screenshots / Video
N/A — this is a non-visual CLI/provider change.
How to Test
cd packages/opencode && bun run typecheckcd packages/opencode && bun test ./test/kilocode/system-prompt.test.tscd packages/opencode && bun test ./test/provider/transform.test.tsbun run script/check-opencode-annotations.ts --worktreeAll passed locally on this branch. Targeted
oxlinton the four changed files reported 0 errors (only pre-existing warnings).Checklist