Skip to content

fix(session): inline @agent mention uses agent's configured model#28816

Open
lexlian wants to merge 2 commits into
anomalyco:devfrom
lexlian:fix/inline-agent-mention-uses-configured-model
Open

fix(session): inline @agent mention uses agent's configured model#28816
lexlian wants to merge 2 commits into
anomalyco:devfrom
lexlian:fix/inline-agent-mention-uses-configured-model

Conversation

@lexlian
Copy link
Copy Markdown

@lexlian lexlian commented May 22, 2026

Issue for this PR

Closes #28809

Type of change

  • Bug fix

What does this PR do?

Single-line fix in packages/opencode/src/session/prompt.ts:689:

- const agentName = input.agent
+ const agentName = input.agent ?? input.parts.find((p): p is MessageV2.AgentPartInput => p.type === "agent")?.name

createUserMessage was only reading input.agent (top-level field set by the UI agent switch). When mentioning an agent inline like @other hello, the agent name lives in input.parts as AgentPartInput, so input.agent remains undefined. This caused the code to fall back to the default agent's model instead of using the mentioned agent's configured model.

How did you verify your code works?

  • Added test in test/session/prompt.test.ts: inline @agent mention uses the agent's configured model
  • bun typecheck passes (15/15 packages)
  • bun test ./test/session/prompt.test.ts --test-name-pattern "inline.*agent.*mention" passes
  • Full prompt test suite: 50/54 pass (4 pre-existing shell/cancel test failures, unrelated)

Screenshots / recordings

N/A — logic fix, no UI change.

Checklist

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

Closes anomalyco#28809

When mentioning an agent inline (e.g. "@other hello"), the agent name
lives in the parts array as AgentPartInput. createUserMessage was only
reading input.agent (top-level field set by UI agent switch), which
remains unset for inline mentions, causing a fallback to the default
agent's model instead of the mentioned agent's configured model.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels May 22, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@agent inline mentions in chat do not use the agent's configured model

1 participant