> For the complete documentation index, see [llms.txt](https://docs.palliora.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.palliora.org/ai/learn/concepts/tool-calls-and-agent-runs.md).

# Tool calls and agent runs

An agent rarely answers from one model call alone. It searches the web, fetches a page, runs a calculation, calls another API, then folds the result back into the conversation before answering. In Palliora AI, each of those steps, the model call and every tool call, runs as its own [Compute Contract](https://github.com/palliora-org/palliora-docs-with-ai/tree/main/learn/concepts/compute-contracts.md). An agent run is a sequence of them, not a single opaque request.

## How a run is built

1. The model receives the conversation so far and decides it needs a tool: a web search, for example.
2. That tool call runs as a Compute Contract of its own: what tool, what input, what came back.
3. The tool's result goes back into the conversation, and the model is called again, same pattern as the first call.
4. This repeats until the model has what it needs to answer, then produces the final response.

Nothing about this needs a separate "agent" primitive. It's the same [Compute Contract](https://github.com/palliora-org/palliora-docs-with-ai/tree/main/learn/concepts/compute-contracts.md) mechanism used once per step, coordinated by whatever is driving the conversation, your own service if you built one with [Build a chat-completions-compatible service](/ai/build/chat-completions-service.md), or the Palliora AI demo app itself.

## Why this matters

Because every step is its own contract, a multi-step run isn't a black box. Each tool call and each model call is independently recorded, with its own inputs, outputs and Guardian group. Chaining those records together is what produces a [provenance](/ai/learn/concepts/provenance.md) record for the whole run: which models ran, which tools were called, and in what order.

## What stays private

Privacy is chosen per contract, the same way it is for a single model call. A tool call can run plaintext or threshold-encrypted, see [Encrypted compute](https://github.com/palliora-org/palliora-docs-with-ai/tree/main/build/guides/encrypted-compute.md), and under a TEE if the tool itself handles sensitive data, see [Confidential compute](https://github.com/palliora-org/palliora-docs-with-ai/tree/main/learn/concepts/confidential-compute.md). Nothing about running multiple steps changes what privacy options are available for any one of them.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.palliora.org/ai/learn/concepts/tool-calls-and-agent-runs.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
