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

# Agents

> Define model steps, dependencies, loops, context continuation, and structured outputs.

An agent is one LLM step in the workflow graph.

```wire theme={"languages":{"custom":["/languages/wire.tmLanguage.json"]}}
agent summarize_task {
    model: model.fast
    instruction: "Summarize task {{ input.task_id }}."

    output {
        summary: string
        next_action: string
    }
}
```

## Agent properties

| Property      | Purpose                                                                    |
| ------------- | -------------------------------------------------------------------------- |
| `model`       | Selects a named model profile, such as `model.fast`.                       |
| `uses`        | Makes tools, prompts, and resources available to the agent.                |
| `context`     | Continues from another agent's message history.                            |
| `instruction` | The instruction appended for this agent step.                              |
| `file`        | Uploads content before the agent call and injects it as a file attachment. |
| `output`      | The required structured output contract.                                   |

## Uses

`uses` declares external capabilities and context available to the agent. It can include tools, prompts, and resources.

```wire theme={"languages":{"custom":["/languages/wire.tmLanguage.json"]}}
agent writer {
    model: model.fast

    uses: [
        prompt.writer_instructions,
        resource.project_readme,
        tool.create_draft,
    ]

    instruction: "Create a draft for {{ input.topic }}."

    output {
        draft: string
    }
}
```

## File directive

`file` uploads content before the agent executes and injects the resulting file attachment into the agent's chat history. The content expression is positional and required; an optional block sets `name` and `purpose`.

```wire theme={"languages":{"custom":["/languages/wire.tmLanguage.json"]}}
agent reviewer {
    model: model.fast
    instruction: "Review the uploaded file."

    file agent.summarizer {
        name: "report.json"
    }

    output {
        feedback: string
    }
}
```

### File syntax

```wire theme={"languages":{"custom":["/languages/wire.tmLanguage.json"]}}
file <content> {
    name: "filename.ext"
    purpose: "file-extract"
}
```

The block `{ ... }` is optional. When omitted, defaults apply.

### File properties

| Property               | Required | Default          | Purpose                                                   |
| ---------------------- | -------- | ---------------- | --------------------------------------------------------- |
| `content` (positional) | Yes      | —                | An expression whose rendered value becomes the file body. |
| `name`                 | No       | `"file.txt"`     | The filename exposed to the model.                        |
| `purpose`              | No       | `"file-extract"` | A label describing the file's role in the workflow.       |

The content expression accepts references (`agent.summarizer`, `dynamic.data`), string literals (`"manual content"`), and number literals (`132`).

### Content from an agent

```wire theme={"languages":{"custom":["/languages/wire.tmLanguage.json"]}}
file agent.summarizer {
    name: "report.json"
}
```

### Inline content

```wire theme={"languages":{"custom":["/languages/wire.tmLanguage.json"]}}
file "manual content" {
    name: "notes.txt"
}
```

### Multiple files

Multiple `file` directives are allowed on a single agent:

```wire theme={"languages":{"custom":["/languages/wire.tmLanguage.json"]}}
agent compare {
    model: model.fast
    instruction: "Compare the two files."

    file agent.step_one {
        name: "before.json"
    }

    file agent.step_two {
        name: "after.json"
    }

    output {
        differences: string
    }
}
```

## Agent loops

Use `for ... in` when each item in a collection should be processed with the same agent.

```wire theme={"languages":{"custom":["/languages/wire.tmLanguage.json"]}}
agent summarize_each for task in input.tasks {
    model: model.fast
    instruction: "Summarize {{ task.title }}."

    output {
        title: string
        summary: string
    }
}
```

Loop headers may destructure object-shaped items:

```wire theme={"languages":{"custom":["/languages/wire.tmLanguage.json"]}}
agent summarize_each for { a, b } in input.something {
    model: model.fast
    instruction: "Summarize A={{ a }} and B={{ b }}."

    output {
        summary: string
    }
}
```

The output of a looped agent is an array of that agent's output objects.

## Context continuation

Use `context: agent.some_agent` when a later agent should continue from an earlier agent's message history.

```wire theme={"languages":{"custom":["/languages/wire.tmLanguage.json"]}}
agent investigate_task {
    model: model.fast
    instruction: "Investigate task {{ input.task_id }} and identify the main issue."

    output {
        issue: string
        evidence: [string]
    }
}

agent propose_solution {
    model: model.fast
    context: agent.investigate_task
    instruction: "Continue from the investigation and propose a concrete solution."

    output {
        solution: string
        steps: [string]
    }
}
```

A structured reference such as `agent.investigate_task.issue` reads an output value. `context: agent.investigate_task` passes the prior conversation/message history so the next agent can append a new instruction and continue the work.
