The Core Loop
An agent alternates between model calls and tool execution. The model can answer directly or request tools to gather information and perform actions.
A typical request
For a request such as “Investigate the failed payment”:
- The model receives the user's message, agent instructions, and available tools.
- It chooses a connection tool to retrieve the payment details.
- The runtime executes the tool and adds the result to the conversation.
- The model can load a relevant skill, query another system, or call a configured subagent.
- It returns an answer when it has enough information, or asks the user for missing input.
“Explore, plan, execute” describes possible activities during this process. These are not mandatory runtime stages. The model chooses the sequence; the runtime does not guarantee a separate planning phase or a particular number of tool calls.
Stopping conditions
- The model finishes its response without requesting more tools.
- The user cancels the request or disconnects from the ordinary chat stream.
- The configured model-turn limit is reached.
- The session token budget is reached. This is checked between transitions, so an in-flight model call can exceed it.
- Optional loop detection finds repeated tool calls with similar parameters.
- An unrecoverable error ends the turn.
See State Machine for the states and completion reasons.
Retaining information
Conversation history is available within a session. The runtime can summarize older messages when context grows too large; see Context Management.
Cross-session information must be saved explicitly. An agent can write to a store when permitted, or use memory when enabled. Reading a document or completing a task does not update source files, train the model, or guarantee better answers in later sessions.