fix(session): preserve agent and model on async prompt without explicit fields#29357
Open
sjawhar wants to merge 1 commit into
Open
fix(session): preserve agent and model on async prompt without explicit fields#29357sjawhar wants to merge 1 commit into
sjawhar wants to merge 1 commit into
Conversation
When a prompt comes in without explicit agent/model fields (the common case for prompt_async), createUserMessage was falling back to the config's default agent and that agent's default model. This caused the session to silently switch agents/models mid-conversation. Fix: read the most recent user message in the session and prefer its agent and model as the fallback before going to defaults. Both fields fall through together because the user's previous choice was a coherent pairing. Replaces the dropped fix/prompt-async-agent-preserve branch with a minimal version. Loop continuation guard and 30-min timeout from the original branch are intentionally omitted; can be added later if needed.
6 tasks
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 #21728
Re-submission of #21729 (closed by automated cleanup), rebased onto current dev. The previous PR could not be reopened because the branch has been force-pushed since closure. The Linux e2e failure analyzed previously was traced to a different spec and unrelated to this PR.
Type of change
What does this PR do?
When
prompt_asyncis called withoutagentormodelfields, the session previously fell back to the default agent's model — clobbering the active agent/model the user had selected. This is the bug in #21728.Now
createUserMessagelooks at the most recent user message with an agent set and uses that as the fallback before falling back to defaults. Same fallback chain for the model.How did you verify your code works?
New test in
test/session/prompt.test.tsasserts that a no-agent/no-modelprompt_asyncafter an initial prompt-with-agent preserves the original agent and model on the new user message.Checklist