# Visão geral

Canonical URL: https://developers.iagenify.com/pt/sdk/ref/local-agent/
Language: pt

Quale api.agents.create({ runtime: "local" }) restitue: il loop agente come un oggetto che sostende, run, stop, inspection e rebobina.

Status: 8 methods · the loop is here · read its state as it works

| Método | Função |
| --- | --- |
| [run(options)](/pt/sdk/ref/local-agent/run) | Un intercambio: il tuo messaggio dentro, la risposta. |
| [stop()](/pt/sdk/ref/local-agent/stop) | Fine la runtura corrente. |
| setMode(mode) | Cambia il modo, medio-run, subagentes inclusa. |
| [compact()](/pt/sdk/ref/local-agent/compact) | Resumis la conversazione ora. |
| [getHistory()](/pt/sdk/ref/local-agent/get-history) | La conversa, in forma di display. |
| [Punti di controllo()](/pt/sdk/ref/local-agent/checkpoints) | A qua pots retornar. |
| [rewind(n)](/pt/sdk/ref/local-agent/rewind) | Retorna a un messaggio. |
| [destroy()](/pt/sdk/ref/local-agent/destroy) | Rimueve la sessione. |

```javascript
const agent = api.agents.create({ runtime: "local", machine: pc, model, memory: true });

const result = await agent.run({
  message: "Read the notes and list what is unfinished.",
  onEvent: (e) => { if (e.type === "text_delta") process.stdout.write(e.delta); },
});

console.log(agent.usage, agent.context.tokens, result.stopReason);
```

## run() è un intercambio, non un task {#one-exchange}

Prende il vostro messaggio, loops fino che il modello cessa de chiedere utensili, e retorna. Calling-lo continua di nuovo la stessa conversa — l'oggetto detiene la historis.

## L'obiet è reutilizable, e non consistit {#reusable}

> **Un run per volta**
>
> Una seconda run() mentre uno è in volo condivide la stessa lista de messaggi e i medesime contadores d'uso. Aspetta il primo, o construir un second agente.

## Può lere il suo stato mentre funciona {#state}

`usage`, `context`, `todos`, `mode` e `messages` sono live. Una interface pode sondar-les, ou escuchar [events](/pt/sdk/agent/events), o que é mais barato e preciso.

- [Propriedades](/pt/sdk/ref/local-agent/properties): Tutto legìbile.
- [run()](/pt/sdk/ref/local-agent/run): Il metodo principale.
- [Mecanismo de agentes](/pt/sdk/agent): Come funciona la loop.

```python
agent = api.agents.create(runtime="local", machine=pc, model=model, memory=True)

result = agent.run(
    message="Read the notes and list what is unfinished.",
    on_event=lambda e: print(e["text"]) if e["type"] == "text" else None,
)

print(agent.usage, agent.context["tokens"], result["stopReason"])
```
