fix(session): preserve active agent and model on prompt_async without explicit fields#21729
fix(session): preserve active agent and model on prompt_async without explicit fields#21729sjawhar wants to merge 1 commit into
Conversation
CI Failure AnalysisThe This occurs during The same Re: Potential DuplicatesThe bot flagged #18615 and #13456 as potential duplicates. These are related but not duplicates:
This PR fixes the server-side root cause that #18615 describes. #13456 is a separate client-side issue. |
96358b9 to
3eb6178
Compare
|
CI update after direct comparison with
Because of that overlap, I am not documenting the Linux failure away as unrelated. I have re-run the failed e2e jobs to distinguish a flaky timeout from a real regression before changing code. |
|
Additional investigation on the Linux e2e failure: The failing spec is Spec helper evidence:
PR behavior change:
Conclusion:
I don’t have permissions to rerun the failed jobs from this environment, so I can’t prove flakiness by re-run here. But the changed code path and the failing test input path do not intersect. |
844b341 to
5ce8560
Compare
5ce8560 to
3550fd9
Compare
|
Rebased onto current dev. Branch |
|
Reopen was blocked by GitHub's force-push protection. Resubmitted as #29357. |
Issue for this PR
Closes #21728
Type of change
What does this PR do?
When
prompt_async(orcommand()) arrives without explicitagentormodelfields, the session now preserves the active agent and model from the most recent user/assistant message instead of falling back to the default agent's configured defaults.Before: Omitted
agent/modelonprompt_asyncdefaults to config, silently overriding the session's active state. Envoy notifications could redirect a session's agent and model.After: Omitted fields inherit from the current session prompt state. If the caller explicitly sets
agent, model falls through to that agent's config (correct behavior). If both are omitted, both are preserved from the session's current state.Changes:
currentAgent()helper with a broadercurrent()helper that returns both agent and model from the most recent messagecreateUserMessage()now usescur?.agentandcur?.modelas fallbacks before agent config defaultsagentis also omitted (if caller explicitly sets agent, model defaults to that agent's config)How did you verify your code works?
cd packages/opencode && bun test test/session/prompt.test.ts— 9 pass, 0 failcd packages/opencode && bun typecheck— passNotes
unknown command throws typed error with available namesis unrelated — fails on dev as well{ "parts": [...] }, no agent/model/variant fieldsChecklist