# LiveSweLoop

**Kind:** Class

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

**Implements:** `IAgentLoop`

## Methods

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

## Where it refuses work

- `LiveSweLoop` stops the work with `FormatError` when `!tool`.
- `LiveSweLoop` stops the work with an early return when `eventQueue.length > 0`.
- `LiveSweLoop` stops the work with an early return when `runComplete`.
- `LiveSweLoop` stops the work with an early return when `toolCallItems.length === 0`.
- `LiveSweLoop` stops the work with an early return when `m.role === 'tool'`.
- `LiveSweLoop` stops the work with an early return when `m.role === 'assistant'`.

## When something fails

- `LiveSweLoop` handles failure in 4 places: it lets it reach the caller in 3, and logs it and continues in 1.
