fix(cli): preserve session agent for headless prompts - #13102
Conversation
Fall back to the agent selected during session creation when a headless prompt does not specify one. This preserves custom agent models and permissions instead of resetting the session to the default code agent. Fixes Kilo-Org#13027
Code Review SummaryStatus: No Issues Found | Recommendation: Merge The previous CRITICAL finding (wrong endpoint path in the regression test) was resolved in Files Reviewed (3 files)
Previous Review Summary (commit c1a6c3f)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit c1a6c3f)Status: 1 Issue Found | Recommendation: Address before merge Overview
The one-line fix in However, the new regression test targets a non-existent route ( Fix these issues in Kilo Cloud Issue Details (click to expand)CRITICAL
Files Reviewed (3 files)
Reviewed by kimi-k3 · Input: 141.5K · Output: 10.7K · Cached: 1.2M Review guidance: REVIEW.md from base branch |
Send the regression test request through the v1 session message endpoint so it reaches the synchronous prompt handler. Addresses review feedback on Kilo-Org#13102.
|
Thanks for pushing this fix! |
* fix(cli): preserve session agent for headless prompts Fall back to the agent selected during session creation when a headless prompt does not specify one. This preserves custom agent models and permissions instead of resetting the session to the default code agent. Fixes Kilo-Org#13027 * test(cli): use the correct headless prompt endpoint Send the regression test request through the v1 session message endpoint so it reaches the synchronous prompt handler. Addresses review feedback on Kilo-Org#13102.
Omitting the frontend default left session.agent=ask in place after #13102, so Code turns still used Ask. Persist a permission-neutral Ask-to-Code reminder so prior Ask replies no longer override the current agent. Co-authored-by: Cursor <cursoragent@cursor.com>
Omitting the frontend default left session.agent=ask in place after #13102, so Code turns still used Ask. Persist a permission-neutral Ask-to-Code reminder so prior Ask replies no longer override the current agent.
* fix: keep Code agent after switching from Ask Omitting the frontend default left session.agent=ask in place after #13102, so Code turns still used Ask. Persist a permission-neutral Ask-to-Code reminder so prior Ask replies no longer override the current agent. * test(vscode): cover explicit Ask to Code agent send Extract resolvePromptAgent and assert Code after Ask, pending Code, and omitted selection.
Issue
Fixes #13027
Context
Headless sessions created with an explicit agent lost that selection when the first prompt omitted the
agentfield. The prompt fell back to the defaultcodeagent, so the custom agent's model and permissions were not applied.This change preserves the agent selected during session creation when a later headless prompt does not explicitly override it.
Implementation
Agent resolution for user messages now falls back to the agent stored on the session when
input.agentis absent. Explicit prompt-level agent selections continue to take precedence, and sessions without a selected agent continue to use the configured default agent.The regression test exercises the public headless HTTP flow by creating a session with a custom
test-engineeragent, sending a prompt without an agent, and verifying that both the custom agent and its configured model remain selected.Screenshots / Video
N/A — this change has no visual impact.
How to Test
Manual/local verification
git diff --check; it completed successfully.bun run script/check-opencode-annotations.ts --worktree; all shared OpenCode changes were correctly annotated.Reviewer test steps
packages/opencode/, runbun test ./test/kilocode/headless-session-agent.test.ts.agent: "test-engineer"and sends the first prompt without anagentfield.test-engineerandmock/custom-modelrather than the defaultcodeagent.bun run typecheckfrompackages/opencode/.Blocked checks and substitute verification
bun test ./test/kilocode/headless-session-agent.test.tscould not start because the current workspace dependencies are incomplete (@opentui/solid/preloadis missing). Substitute verification consisted of reviewing the test setup and HTTP route schemas, runninggit diff --check, and running the OpenCode annotation guard.bun run typecheckfrompackages/opencode/could not start becausetsgois missing from the current workspace dependencies. The diff and annotation checks above completed successfully, but the target test and typecheck should be rerun after installing dependencies.Checklist