# InstructionLoader

**Kind:** Class

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

## Methods

| Method | Signature | Returns |
|---|---|---|
| `addPersistent` | `addPersistent(layer: InstructionLayer)` | `void` |
| `removePersistent` | `removePersistent(id: string)` | `void` |
| `addTurn` | `addTurn(layer: InstructionLayer)` | `void` |
| `getInstructions` | `getInstructions(_context: RunContext<TContext>)` | `string` |
| `createDynamicInstructions` | `createDynamicInstructions()` | `(context: RunContext<TContext>) => string` |
| `addConditional` | `addConditional(layer: ConditionalLayer)` | `void` |
| `removeConditional` | `removeConditional(id: string)` | `void` |
| `setActiveTools` | `setActiveTools(toolNames: string[])` | `void` |
| `hasActiveTool` | `hasActiveTool(name: string)` | `boolean` |
| `addToZone` | `addToZone(zone: InstructionZone, layer: Omit<InstructionLayer, 'priority'>, offset: undefined)` | `void` |
| `discover` | `discover(rootDir: string, options: DiscoveryOptions)` | `DiscoveredInstruction[]` |
| `loadFromDirectory` | `loadFromDirectory(rootDir: string, options: DiscoveryOptions)` | `DiscoveredInstruction[]` |

## Where it refuses work

- `InstructionLoader` stops the work with an early return when `allLayers.length === 0`.
- `InstructionLoader` stops the work with an early return when `depth > opts.maxDepth`.

## When something fails

- `InstructionLoader` handles failure in 1 place: it turns it into a return value in all 1.
