mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 20:03:05 +00:00
fix(hooks): fix ContextEventResult.messages type to AgentMessage[]
- Was incorrectly typed as Message[] which caused filtered messages to be ignored - Context event filter in plan-mode hook should now properly remove stale [PLAN MODE ACTIVE] messages
This commit is contained in:
parent
650d8f2615
commit
274d4a6247
2 changed files with 8 additions and 12 deletions
|
|
@ -293,19 +293,15 @@ export default function planModeHook(pi: HookAPI) {
|
|||
|
||||
// Filter out stale plan mode context messages from LLM context
|
||||
// This ensures the agent only sees the CURRENT state (plan mode on/off)
|
||||
(pi as any).on("context", async (event: { messages: Array<{ role: string; content: unknown }> }) => {
|
||||
// Remove any previous plan-mode-context or plan-execution-context messages
|
||||
// They'll be re-injected with current state via before_agent_start
|
||||
pi.on("context", async (event) => {
|
||||
// Only filter when NOT in plan mode (i.e., when executing)
|
||||
if (planModeEnabled) return;
|
||||
|
||||
// Remove any previous plan-mode-context messages
|
||||
const filtered = event.messages.filter((m) => {
|
||||
if (m.role === "user" && Array.isArray(m.content)) {
|
||||
// Check for our custom message types in user messages
|
||||
const hasOldContext = (m.content as Array<{ type: string; text?: string }>).some(
|
||||
(c) =>
|
||||
c.type === "text" &&
|
||||
c.text &&
|
||||
(c.text.includes("[PLAN MODE ACTIVE]") ||
|
||||
c.text.includes("[PLAN MODE DISABLED") ||
|
||||
c.text.includes("[EXECUTING PLAN]")),
|
||||
const hasOldContext = m.content.some(
|
||||
(c) => c.type === "text" && c.text.includes("[PLAN MODE ACTIVE]"),
|
||||
);
|
||||
if (hasOldContext) return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue