This demo shows agent execution mode with multi-turn loops and tool calling. The agent uses Exa web search to build a travel itinerary across staged iterations.
Set config.agent with a model, system prompt, and loop config. The widget sends this to the dispatch API and handles agent-specific SSE events: agent_start, agent_turn_delta, tool_* (with optional agentContext), agent_iteration_*, and agent_complete.
Control how multiple iterations appear in the chat with iterationDisplay:
separate: Each iteration creates its own message bubble.
merged: All iterations stream into a single message.
The widget handles these agent-specific SSE events:
agent_start → agent_iteration_start → agent_turn_start → agent_turn_delta (text/thinking) → agent_turn_complete → tool_start/tool_delta/tool_complete (with agentContext) → agent_iteration_complete → agent_complete
When contentType: 'thinking' is received in agent_turn_delta, it appears as a reasoning bubble (same as extended thinking in flow mode).
Agent mode is opt-in. Without config.agent, the widget uses flow dispatch as before. Both modes share the same SSE streaming infrastructure.