> ## Documentation Index
> Fetch the complete documentation index at: https://cognitio-agent.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Function: defineAgent()

> Generated from the public TypeScript API.

```ts theme={null}
function defineAgent<T>(def): T;
```

Validate a session-scoped helper or subagent definition while preserving its type.

## Type Parameters

### T

`T` *extends* [`AgentDefinition`](../interfaces/AgentDefinition)

## Parameters

### def

`T`

Prompt, model, tools and child-session policy.

## Returns

`T`

The validated definition.

## Throws

A configuration error for invalid prompt, model, tool rules, or MCP descriptors.

## Example

```ts theme={null}
const reviewer = defineAgent({ prompt: "Review correctness.", tools: ["read", "grep"], spawnMode: "fresh" })
```


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