Insert navigation messages when agent finishes working (after tool execution)

- Track agent busy state: isStreaming OR pendingToolCalls.size > 0
- When agent transitions from busy to idle, check for URL changes
- Extract checkAndInsertNavMessage() helper function
- Call helper from both onBeforeSend (user submit) and agent state subscription (post-tool)
- Fixes issue where browser_javascript tool navigates page but no nav message inserted
- Navigation messages now appear after tools that change window.location.href
This commit is contained in:
Mario Zechner 2025-10-06 16:56:51 +02:00
parent d0cbca52b3
commit 6295025787
2 changed files with 43 additions and 21 deletions

View file

@ -293,10 +293,10 @@ export class Agent {
this.patch({ isStreaming: false, streamMessage: null, pendingToolCalls: new Set<string>() });
this.abortController = undefined;
}
{
/*{
const { systemPrompt, model, messages } = this._state;
console.log("final state:", { systemPrompt, model, messages });
}
}*/
}
private patch(p: Partial<AgentState>): void {