This is my first time contributing. I apologize if I fumbled anything, and I’m deeply grateful for patience and any advice if there’s a better way to do this.
For what little it’s worth, I am a Pro customer.
I needed a robust way to know which user is interacting with the AI agent. This is what I came up with. Thank you so much for your time to consider, and any advice.
Add {username} as a template param in AI persona system prompts
I submitted PR #41446 ( FEATURE: Add {username} template param to BotContext - Pull Request #41446 - discourse/discourse - GitHub ) adding {username} to BotContext::TEMPLATE_PARAMS.
The use case: a persona acting as a bridge to an external service needs the current user’s identity resolved on the server side, not inferred by the LLM from post text. Right now there is no clean way to do that. {participants} only populates for private messages, and asking the LLM to parse the username from topic metadata is fragile and has an injection surface.
The change is small (one new method, one string added to the allowlist) and additive. Existing prompts are unaffected unless they already contained the literal {username}.
Thanks again!