You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(agent): start new AI Agent chats on the active brand #913
The AI Agent doesn't know which brand the user is looking at. On the Brand B dashboard, "how is visibility this week?" gets a clarifying question or a list of brands, because:
the system prompt (web/src/lib/agent/system-prompt.ts, rule 2) tells the model to call list_brands and ask whenever the user doesn't name a brand.
Proposed behavior
A new chat is created with the active brand's id.
The chat route loads the conversation's brand_id and passes the brand's name and id into the system prompt as the default brand. The user can still ask about another brand by name.
Optionally, the conversation list shows a small brand badge.
Suggested approach
Send { brandId: activeBrandId } from both create calls, read brand_id in the chat route when building the prompt, and adjust rule 2 to "use the conversation's brand unless the user names another one". No migration is needed.
Run yarn lint and yarn build from web/ before opening the PR — see CONTRIBUTING.md.
I traced the current agent flow and noticed the conversations API already supports brandId and persists it on agent_conversations, while new chats from the agent page currently create the conversation without the active brand. The chat route also has the conversation available before the system prompt is built.
I’d like to connect those pieces so a new chat starts with the active brand as its default context, while still allowing the user to explicitly switch to another brand in the conversation. I’ll also cover the behavior with tests rather than only changing the frontend.
Activity
knockknock10 commentedon Oct 7, 2026
Thanks @gkhngyk — I’d like to take #913.
I traced the current agent flow and noticed the conversations API already supports
brandIdand persists it onagent_conversations, while new chats from the agent page currently create the conversation without the active brand. The chat route also has the conversation available before the system prompt is built.I’d like to connect those pieces so a new chat starts with the active brand as its default context, while still allowing the user to explicitly switch to another brand in the conversation. I’ll also cover the behavior with tests rather than only changing the frontend.
Please assign it to me if that works.
gkhngyk commentedon Oct 7, 2026
Assigned, thanks @knockknock10. The plan sounds right. Please keep the brand switch explicit, and reference #913 in the PR.