> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bijection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Module: agents

> Reference for the bijection/agents entry point.

## Type Aliases

### AgentLanguageModel

Ƭ **AgentLanguageModel**: `Object`

The part of an AI SDK `LanguageModelV4` a run uses: one generation step
with function tools.

#### Type declaration

| Name | Type |
| :- | :- |
| `doGenerate` | (`options`: \{ `prompt`: `unknown`\[] ; `tools`: \{ `type`: `"function"` ; `name`: `string` ; `description`: `string` ; `inputSchema`: `unknown`  }\[] ; `toolChoice`: \{ `type`: `"auto"`  }  }) => `Promise`\<\{ `content`: \{ `[field: string]`: `unknown`; `type`: `string`  }\[]  }> |

***

### AgentModels

Ƭ **AgentModels**: `Object`

Where an agent's runs get their model: the program's language models,
metered per run (`new LanguageModels(component, catalog)` from
`@bijectionhq/language-models`).

#### Type declaration

| Name | Type |
| :- | :- |
| `open` | (`ctx`: `any`, `session`: \{ `consumer`: `string` ; `subject`: `string` ; `key`: `string`  }) => `Promise`\<\{ `model`: (`key`: `string`, `requires?`: readonly `string`\[]) => [`AgentLanguageModel`](/api/modules/agents#agentlanguagemodel) ; `close`: (`failure?`: `any`) => `Promise`\<`unknown`>  }> |

***

### AgentDefinition

Ƭ **AgentDefinition**: `Object`

One agent: what it reads, what it may propose, and its model.

#### Type declaration

| Name | Type | Description |
| :- | :- | :- |
| `description` | `string` | - |
| `sessions` | [`IssuedSessionPolicy`](/api/modules/sessions#issuedsessionpolicy) | Each run receives this service-issued authority on one object. |
| `tools` | [`Toolset`](/api/modules/tools#toolset) | Public queries the run may read. Operations belong in `proposes`. |
| `proposes?` | `Record`\<`string`, [`ToolDeclaration`](/api/modules/tools#tooldeclaration)> | Operations a run may propose, by tool name. A proposal changes nothing: a person submits it, invoking the operation under their own authority, or rejects it. |
| `model` | `string` | A key of the program's language models catalog. |
| `instructions` | `string` | What this agent does, which the model reads before every run after tools. |
| `maxSteps?` | `number` | Model steps one run takes at most, 1 to 16. Default 8. |

***

### AgentDeclaration

Ƭ **AgentDeclaration**: `Readonly`\<\{ `name`: `string` ; `description`: `string` ; `sessions`: [`IssuedSessionPolicy`](/api/modules/sessions#issuedsessionpolicy) ; `tools`: [`Toolset`](/api/modules/tools#toolset) ; `proposes`: `Readonly`\<`Record`\<`string`, [`ToolDeclaration`](/api/modules/tools#tooldeclaration)>> ; `model`: `string` ; `instructions`: `string` ; `maxSteps`: `number`  }>

A validated agent declaration.

***

### AgentRun

Ƭ **AgentRun**: `Object`

What one run is for.

#### Type declaration

| Name | Type | Description |
| :- | :- | :- |
| `for` | `string` | The object of the session policy's resource type the run acts for. |
| `input?` | `string` | What the run is asked; by default, to act for its object. |

***

### AgentsModuleOptions

Ƭ **AgentsModuleOptions**: `Object`

Configuration of the independent agent module.

#### Type declaration

| Name | Type | Description |
| :- | :- | :- |
| `access` | [`AccessModel`](/api/interfaces/server.AccessModel) | - |
| `agents` | readonly [`AgentDeclaration`](/api/modules/agents#agentdeclaration)\[] | - |
| `models` | [`AgentModels`](/api/modules/agents#agentmodels) | - |
| `module?` | `string` | Default `agents`. Must match the deployed module path. |

## Functions

### startAgent

▸ **startAgent**(`_ctx`, `agent`, `run`): `Promise`\<`void`>

Start a run of the agent `agent` from a mutation; it starts once the
mutation commits. The run carries what the mutation read, so a run whose
starter read protected rows decides them for the sessions it starts.

#### Parameters

| Name | Type |
| :- | :- |
| `_ctx` | `any` |
| `agent` | `string` |
| `run` | [`AgentRun`](/api/modules/agents#agentrun) |

#### Returns

`Promise`\<`void`>

***

### defineAgent

▸ **defineAgent**(`name`, `definition`): [`AgentDeclaration`](/api/modules/agents#agentdeclaration)

Declare an agent the deployment runs. Throws on an inconsistent
declaration.

#### Parameters

| Name | Type |
| :- | :- |
| `name` | `string` |
| `definition` | [`AgentDefinition`](/api/modules/agents#agentdefinition) |

#### Returns

[`AgentDeclaration`](/api/modules/agents#agentdeclaration)

***

### agentsModule

▸ **agentsModule**(`options`): `Record`\<`string`, `unknown`> & \{ `isFunctionBundle`: `true`  }

Install agents and their proposal review functions. An agent needs no
MCP server, route, or HTTP origin.

#### Parameters

| Name | Type |
| :- | :- |
| `options` | [`AgentsModuleOptions`](/api/modules/agents#agentsmoduleoptions) |

#### Returns

`Record`\<`string`, `unknown`> & \{ `isFunctionBundle`: `true`  }

***

### agentTables

▸ **agentTables**(): `Object`

The table of the operations agents' runs propose, for an application
that declares agents: spread it into the application schema.
It is retained custody keyed by the object each run acted for, so a reader
sees a proposal only while they may read what its run read, and removing
it takes a custody migration.

#### Returns

`Object`

| Name | Type |
| :- | :- |
| `agentProposals` | [`TableDefinition`](/api/classes/server.TableDefinition)\<[`VObject`](/api/classes/values.VObject)\<\{ `contract`: `string` ; `arguments`: `Record`\<`string`, `any`> ; `operation`: `string` ; `invocation`: `null` \| `string` ; `review_id`: `null` \| `string` ; `state`: `"pending"` \| `"rejected"` \| `"submitted"` ; `decided_at`: `null` \| `number` ; `session`: `string` ; `reason`: `string` ; `for`: `string` ; `agent`: `string` ; `tool`: `string` ; `proposed_at`: `number` ; `decided_by`: `null` \| `string`  }, \{ `agent`: [`VString`](/api/classes/values.VString)\<`string`, `"required"`> ; `for`: [`VString`](/api/classes/values.VString)\<`string`, `"required"`> ; `session`: [`VString`](/api/classes/values.VString)\<`string`, `"required"`> ; `tool`: [`VString`](/api/classes/values.VString)\<`string`, `"required"`> ; `operation`: [`VString`](/api/classes/values.VString)\<`string`, `"required"`> ; `contract`: [`VString`](/api/classes/values.VString)\<`string`, `"required"`> ; `arguments`: [`VRecord`](/api/classes/values.VRecord)\<`Record`\<`string`, `any`>, [`VString`](/api/classes/values.VString)\<`string`, `"required"`>, [`VAny`](/api/classes/values.VAny)\<`any`, `"required"`, `string`>, `"required"`, `string`> ; `reason`: [`VString`](/api/classes/values.VString)\<`string`, `"required"`> ; `state`: [`VUnion`](/api/classes/values.VUnion)\<`"pending"` \| `"rejected"` \| `"submitted"`, \[[`VLiteral`](/api/classes/values.VLiteral)\<`"pending"`, `"required"`>, [`VLiteral`](/api/classes/values.VLiteral)\<`"submitted"`, `"required"`>, [`VLiteral`](/api/classes/values.VLiteral)\<`"rejected"`, `"required"`>], `"required"`, `never`> ; `proposed_at`: [`VFloat64`](/api/classes/values.VFloat64)\<`number`, `"required"`> ; `decided_by`: [`VUnion`](/api/classes/values.VUnion)\<`null` \| `string`, \[[`VNull`](/api/classes/values.VNull)\<`null`, `"required"`>, [`VString`](/api/classes/values.VString)\<`string`, `"required"`>], `"required"`, `never`> ; `decided_at`: [`VUnion`](/api/classes/values.VUnion)\<`null` \| `number`, \[[`VNull`](/api/classes/values.VNull)\<`null`, `"required"`>, [`VFloat64`](/api/classes/values.VFloat64)\<`number`, `"required"`>], `"required"`, `never`> ; `invocation`: [`VUnion`](/api/classes/values.VUnion)\<`null` \| `string`, \[[`VNull`](/api/classes/values.VNull)\<`null`, `"required"`>, [`VString`](/api/classes/values.VString)\<`string`, `"required"`>], `"required"`, `never`> ; `review_id`: [`VUnion`](/api/classes/values.VUnion)\<`null` \| `string`, \[[`VNull`](/api/classes/values.VNull)\<`null`, `"required"`>, [`VString`](/api/classes/values.VString)\<`string`, `"required"`>], `"required"`, `never`>  }, `"required"`, `"contract"` \| `"arguments"` \| `"operation"` \| `"invocation"` \| `"review_id"` \| `"state"` \| `"decided_at"` \| `"session"` \| `"reason"` \| `"for"` \| `"agent"` \| `"tool"` \| `"proposed_at"` \| `"decided_by"` \| \`arguments.\$\{string}\`>, \{ `by_for`: \[`"for"`, `"proposed_at"`, `"_creationTime"`]  }, \{}, \{}, `false`, \{}> |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.