# AgentRuntime

**Kind:** Class

**Source:** [`atloria-monorepo/libs/agent-core/src/runtime/agent-runtime.ts`](https://github.com/sherkety/atloria/blob/main/atloria-monorepo/libs/agent-core/src/runtime/agent-runtime.ts#L45)

AgentRuntime — the SDK-based agent loop implementation.
Wraps

**Implements:** `IAgentLoop`

## Methods

| Method | Signature | Returns |
|---|---|---|
| `run` | `run(config: AgentConfig<TContext>, input: string, options: RunOptions<TContext>)` | `Promise<RunResult>` |
| `runStreamed` | `runStreamed(config: AgentConfig<TContext>, input: string | AgentInputItem[], options: RunOptions<TContext>)` | `Promise<StreamedRunHandle>` |

## Where it refuses work

- `AgentRuntime` stops the work with an early return when `maxOutputRecoveries > 0 && this.wasOutputTruncated(sdkResult)`.
- `AgentRuntime` stops the work with an early return when `fo === undefined || fo === null`.
- `AgentRuntime` stops the work with an early return when `!sdkResult.rawResponses`.
- `AgentRuntime` stops the work with an early return when `!lastResponse`.
- `AgentRuntime` stops the work with an early return when `finishReason === 'length'`.
- `AgentRuntime` stops the work with an early return when `item?.status === 'incomplete'`.

## When something fails

- `AgentRuntime` handles failure in 5 places: it logs it and continues in 2, discards it silently in 2, and lets it reach the caller in 1. A failure discarded silently leaves no trace for whoever debugs this later.
