Hi CopilotKit team! We're experiencing an infinite loop when our LangGraph workflows call frontend actions. Here's a concrete example:
We're experiencing an infinite loop when LangGraph workflows call frontend actions. Here's our setup:
Architecture:
- LangGraph supervisor → workflow pattern
- Workflows fetch data then display via frontend actions
Example Flow:
- User: "Show me billing"
- Supervisor calls transfer_to_billing_workflow()
- Billing workflow:
- Calls get_billing_info() → gets data
- Calls show_billing_summary(data) → frontend action
- Calls copilotkit_exit() - Problem: After copilotkit_exit(), agent restarts with full history including all tool calls. Supervisor sees "billing" in history, routes to workflow again → infinite loop.
Message history after exit:
User: "Show me billing"
AI: [tool: transfer_to_billing_workflow]
AI: [tool: get_billing_info]
Tool: {data}
AI: [tool: show_billing_summary]
Tool: {empty}
Tried:
- State flag before exit - workflow runs before check
- Filter messages - causes tool/response mismatch errors
- Check if action already called - works but needed in every workflow
Questions:
- Why does agent re-run with full history after copilotkit_exit()?
- How to complete workflow+frontend action without re-execution?
- Is there a different exit pattern for workflows with frontend actions?
Works fine with backend-only tools, breaks with frontend actions. Using render property, not handler.