---
title: "Agent and tool flow"
description: "How ChatAgent owns the tool loop while applications retain execution control."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.cortavyn.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Agent and tool flow

<pre class="mermaid">{`
sequenceDiagram
    participant App as Application
    participant Agent as ChatAgent
    participant Model as ChatModel
    participant Tool as ChatTool
    App->>Agent: reply(conversation, user message)
    Agent->>Model: messages + tool definitions
    Model-->>Agent: assistant message + tool calls
    loop each tool round
        Agent->>Tool: execute(call, ToolRuntime)
        Tool-->>Agent: ToolExecutionResult
        Agent->>Model: tool-result messages
    end
    Agent-->>App: updated Conversation
`}</pre>

The application configures `ToolRuntime` once and owns its context, store, and progress writer. Providers only translate the portable model protocol; they never invoke application tools.

Source: https://docs.cortavyn.org/architecture/agent-tool-flow/index.mdx
