# Agents (calling a model like anything else you declared)

> An `agent` is a declaration — instructions, tools, model — and calling it is calling a name. The first-day mistake is treating the call as a chat: you hand it the turns you want it to see, so what it remembers is what you passed, and every run is recorded as a task with its cost and outcome whether you look or not.

<!-- id: agent-index · area: agent · stability: stable · html: https://osysharp.com/reference/agent/index/ -->

## Summary        {#summary}
**An agent is something you declare, and calling it is calling a name.** Its declaration supplies its
instructions, its tools and its model, so the call site stays about what you are asking rather than about how the
model is configured.

```osy title="the call is a call" test app=agent-index
using Osysharp.Agents;

[Principal] entity User {
  [Required, MaxLength(100)] string DisplayName;
  security { allow read when IsAuthenticated; allow create when IsAuthenticated || IsAnonymous; }
}

agent Support {
  Purpose   = "Answer questions about an order.";
  Prompt    = "You answer order questions from the context you are given.";
  Principal = new User { DisplayName = "Support" };
}

string Answer(string question) {
  var turns = new List<Turn>();
  turns.Add(Turn.User(question));
  return Support.Ask(turns).Text;
}
```

## Description    {#description}
**You hand it the turns it should see.** There is no hidden session: the question, the history worth replaying and
the context you assembled are the argument ([running an agent from your code](https://osysharp.com/reference/agent/ask/)). What it "remembers" is what you passed — see
[agent conversation memory (using Osysharp.Agents)](https://osysharp.com/reference/agent/conversation-memory/) for the shapes that are worth passing and the ones that are not.

**Every run is a task, recorded.** Cost, duration and outcome are captured whether or not you look
([the agent task log (AgentTask)](https://osysharp.com/reference/agent/task-log/)). [watching a task run (task.Watch)](https://osysharp.com/reference/agent/task-watch/) follows one in flight, [what the agent saw (task.Transcript)](https://osysharp.com/reference/agent/task-transcript/) reads what it actually
said and did, [what a task cost, and what it did (task.Calls)](https://osysharp.com/reference/agent/task-calls/) lists the tools it reached for, and [stopping work (task.Stop)](https://osysharp.com/reference/agent/task-stop/) ends one.

**The model is a declaration, not a call-site argument.** [app.Models — the models an app admits, each with a name](https://osysharp.com/reference/agent/models/) is how a model is named and
[default LLM model (app.DefaultModel)](https://osysharp.com/reference/agent/default-model/) what a call gets when it names none — so changing which model an agent uses is an edit in
one place, not a sweep of call sites.

**A long-running agent is a workflow, not a loop you write.** [the agent loop (app.Agent, Loop)](https://osysharp.com/reference/agent/loop/) is the shape for repeated turns, and
[an agent asking a person (the human slot)](https://osysharp.com/reference/agent/hitl/) is how a person is brought into one — which is a parking point, with everything the workflow area
says about surviving a deploy. [what an agent hands back (AgentDeliverable)](https://osysharp.com/reference/agent/deliverables/) is how a run's output becomes something the app holds.

## The pages      {#the-pages}
Run `osy docs agent` for the full listing.

- **Calling one** — [running an agent from your code](https://osysharp.com/reference/agent/ask/), [agent conversation memory (using Osysharp.Agents)](https://osysharp.com/reference/agent/conversation-memory/), [the agent loop (app.Agent, Loop)](https://osysharp.com/reference/agent/loop/)
- **Which model** — [app.Models — the models an app admits, each with a name](https://osysharp.com/reference/agent/models/), [default LLM model (app.DefaultModel)](https://osysharp.com/reference/agent/default-model/)
- **Turning it off** — [turning AI off (the runtime switch)](https://osysharp.com/reference/agent/ai-switch/), the operator's runtime disable
- **Capping it** — [LLM budgets (hard daily limits per organisation, app and user)](https://osysharp.com/reference/agent/llm-budget/), hard daily budgets per organisation, app and user, enforced before the call leaves
- **People in the loop** — [an agent asking a person (the human slot)](https://osysharp.com/reference/agent/hitl/), [what an agent hands back (AgentDeliverable)](https://osysharp.com/reference/agent/deliverables/)
- **Watching a run** — [the agent task log (AgentTask)](https://osysharp.com/reference/agent/task-log/), [watching a task run (task.Watch)](https://osysharp.com/reference/agent/task-watch/), [what the agent saw (task.Transcript)](https://osysharp.com/reference/agent/task-transcript/),
  [what a task cost, and what it did (task.Calls)](https://osysharp.com/reference/agent/task-calls/), [stopping work (task.Stop)](https://osysharp.com/reference/agent/task-stop/)

## See also   {#see-also}
- [running an agent from your code](https://osysharp.com/reference/agent/ask/) — the call, and what a turn list is for
- [the agent task log (AgentTask)](https://osysharp.com/reference/agent/task-log/) — what every run records, without being asked
- [an agent asking a person (the human slot)](https://osysharp.com/reference/agent/hitl/) — bringing a person in, and why that makes it a parking point
