Understanding how AI agents execute in your workflows helps you choose the right configuration for your specific use case.
Agents generally operate in one of two modes:
Interactive
Async
Interactive mode (chat agents)
This mode is ideal for scenarios where you need real-time, back-and-forth communication, such as a customer support chat interface.
How it works: When a request is sent through the agent's route, the system holds the connection open. The agent completes the entire turn in a single step run, looping internally to make as many model requests as needed to finish the task.
Key features: It streams progress back to the user in real-time, including text updates, tool usage, and reasoning steps.
Best for: Conversations where a user expects immediate, continuous interaction.
Async mode (headless agents)
This mode is designed for background tasks triggered by webhooks, scheduled jobs (cron), or automated upstream steps.
How it works: Instead of staying connected, the agent makes exactly one model request per run. It uses a "self-loop" mechanism, where the workflow links the step back to itself. Each run writes a status update (running, done, or error) that determines whether the next loop should trigger.
Key benefits:
Durability: Because each run is separate, it isn't limited by platform timeouts. If a process takes a long time, it doesn't risk being cut off.
Resilience: If a specific run fails, it can resume from the last completed request rather than starting over from the beginning.
Reliability: The transcript is saved after each request, ensuring you don't lose progress.
Best for: Complex, multi-step automation, like reviewing a GitHub pull request, where the agent needs to analyze code, fetch files, and run checks over several iterations.
The execution loop
Regardless of the mode, the agent follows a consistent process during every run:
Configuration: It loads system instructions, model settings, and required tools.
Transcript: It retrieves the conversation history from storage.
Limits: It checks that the task remains within budget constraints, such as token limits, step caps, and time limits.
Message building: It adds the new user message or resumes from previous tool results.
Model interaction: It calls the language model with the system prompt, history, and tools.
Tool execution: If the model requires tools, the agent executes them and records the results.
Persistence: It saves the full interaction history, including tool calls and usage data, to disk.
Output: It delivers the result - streaming events for interactive mode or writing a structured status result for async mode.
Summary
Every agent run is designed to be stable and predictable:
Streaming: Provides real-time updates for interactive callers.
Persistence: Keeps a durable audit trail of the transcript for debugging and cost tracking.
Boundaries: Enforces strict limits on token usage, time, and steps to prevent runaway processes.
Security: Keeps all conversations isolated by authenticated user.
