fix: support custom agent names for plan/build reminders
Summary
- Fix plan/build agent reminder triggers to work with custom agent names
- Replace exact string matching with word boundary regex pattern matching
- Ensures users with custom agents containing "plan" or "build" receive proper context reminders
Issue
The plan/build reminder system used exact string matching (input.agent.name === "plan" and input.agent.name === "build"), which completely bypassed important context for users with custom agents. Users with agents like "my-plan-agent" or "custom-build-helper" would never see the plan mode reminder or build-switch reminder, reducing the effectiveness of the agent switching system.
Solution
- Added
hasAgentType()helper function that uses word boundary regex matching - Changed triggers from exact string matches to pattern matching for any agent name containing "plan" or "build" as whole words
- Applied the same logic to both current agent detection and previous message mode detection
- Maintains backward compatibility while extending support to custom agent names
Impact
Users with custom plan/build agents will now correctly receive contextual reminders, improving the agent switching experience and ensuring important context is preserved across agent transitions.
if someone has a custom agent I would think that we should keep current behavior but have the option for them to register system reminders, it feels weird to use the same plan system reminder for any agent with plan in the name
This unlocks an OC feature otherwise gated. I recommend a minor adjustment to the current implementation to unlock it.
At the time, I wanted to avoid your suggestion of a dedicated agent's has_reminder=plan/build/false setting because I was unsure about the overall approach. A specific agent's mode setting is viable, but it leaves open the possibility that the prompt could contradict the tool's true/false, which defeats the purpose of the reminder. Shouldn't this be conditional based on tool settings in the agent? e.g. You are permitted to [if]make file changes[/if], [if]run shell commands[/if], and utilise your arsenal of tools as needed. and shoudnt the opening sentences "your in x mode" be a toggle rather than tied to a specific agent, or both. I'm sure there are people who have already modified the default plan agent tool settings and are unaware that there's a reminder that conflicts with what they set.
My lasting thought was - agent prompts and these reminders should be dynamic and generated. This, instead, was a reasonable plaster to offer in the meantime.
Yeah I didn't mean has_reminder I meant like just as any custom agent can specify a system prompt, you'd have the ability to specify a system reminder as well. So if you overrode the plan agent, possibly even introducing custom tools your system reminder could be entirely under your control
You do raise a good point regarding how can we best address / avoid the contradictions between tool settings & system reminder stuff.