AG-UI: I'm fairly certain I've found a bug in the AgentFrameworkEventBridge, but I have limited time to grok the entire setup, write a failing test, then a fix.
I'm developing an agent using CopilotKit in the frontend, and noticed that the CopilotKit consistently fails with:
Agent execution failed: Error: Cannot send 'TOOL_CALL_START' event: A tool call with ID 'call_kJ1AwU3ES6oTmODaKsreNKfM' is already in progress. Complete it with 'TOOL_CALL_END' first.
I enabled debug logging in agent_framework_ag_ui and noticed that my backend always emit a ToolCallStartEvent when it's emitting a ToolCallArgsEvent:
❯ grep 'Emitting ToolCall' debug.log
2026-01-09 14:33:14 - agent_framework_ag_ui._events - INFO - Emitting ToolCallStartEvent with name='query_space_01f0d113ac6b1e0db27651b323107a2a', id='call_kJ1AwU3ES6oTmODaKsreNKfM'
2026-01-09 14:33:14 - agent_framework_ag_ui._events - INFO - Emitting ToolCallArgsEvent with delta_length=2, id='call_kJ1AwU3ES6oTmODaKsreNKfM'
2026-01-09 14:33:14 - agent_framework_ag_ui._events - INFO - Emitting ToolCallStartEvent with name='query_space_01f0d113ac6b1e0db27651b323107a2a', id='call_kJ1AwU3ES6oTmODaKsreNKfM'
2026-01-09 14:33:14 - agent_framework_ag_ui._events - INFO - Emitting ToolCallArgsEvent with delta_length=5, id='call_kJ1AwU3ES6oTmODaKsreNKfM'
…
The protocol expects only one tool start event per call, which is why the frontend craps out.
Seems like the _handle_function_call_content doesn't correctly identify/distinguish start events vs args events. It will indeed always emit start events as long as the function call content has a name: