Skip to content

fix(session): preserve agent and model on async prompt without explicit fields - #35195

Closed
sjawhar wants to merge 2 commits into
anomalyco:devfrom
sjawhar:feat/prompt-async-agent-preserve
Closed

fix(session): preserve agent and model on async prompt without explicit fields#35195
sjawhar wants to merge 2 commits into
anomalyco:devfrom
sjawhar:feat/prompt-async-agent-preserve

Conversation

@sjawhar

@sjawhar sjawhar commented Jul 3, 2026

Copy link
Copy Markdown

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

  • Bug fix

What does this PR do?

When prompt_async is called without agent or model fields, 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 createUserMessage looks 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.ts asserts that a no-agent/no-model prompt_async after an initial prompt-with-agent preserves the original agent and model on the new user message.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Closes #21728

Supersedes #29357 (closed by the inactivity bot). Rebased onto latest dev with all merge conflicts resolved; typecheck and targeted tests pass on the fork branch.

opencode and others added 2 commits July 27, 2026 07:32
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.
@sjawhar
sjawhar force-pushed the feat/prompt-async-agent-preserve branch from 678c337 to f9e5527 Compare July 27, 2026 14:59
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: prompt_async notifications override session's active agent and model

1 participant