# AgentFactory

**Kind:** Type

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

Factory function that creates sub-agent configs on demand.
Domain layers implement this to control what instructions, model,
and tools sub-agents receive.

The `model` in options is already resolved by the router — factory
should use it as-is when provided.

## Definition

```ts
(
  name: string,
  task: string,
  tools?: string[],
  options?: { rootDir?: string; model?: string },
) => import('../runtime/types').AgentConfig<TContext>
```
