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

# Handoff

> Agent-to-agent handoff

# Handoff

Handoff enables seamless transfer of conversation context between agents.

## Quick Start

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { Handoff, handoff, Agent } from 'praisonai';

const specialistAgent = new Agent({
  name: 'Specialist',
  instructions: 'You are a technical specialist.'
});

const myHandoff = handoff({
  target: specialistAgent,
  condition: (ctx) => ctx.input.includes('technical')
});

const mainAgent = new Agent({
  name: 'Main',
  instructions: 'You are a helpful assistant.',
  handoffs: [myHandoff]
});
```

## Configuration

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
interface HandoffConfig {
  target: Agent;
  condition: (ctx: HandoffContext) => boolean;
  onHandoff?: (ctx: HandoffContext) => void;
}

interface HandoffContext {
  input: string;
  history: Message[];
  metadata?: Record<string, any>;
}
```

## Handoff Filters

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { handoffFilters } from 'praisonai';

// Built-in filters
const technicalHandoff = handoff({
  target: techAgent,
  condition: handoffFilters.containsKeywords(['code', 'debug', 'error'])
});

const urgentHandoff = handoff({
  target: urgentAgent,
  condition: handoffFilters.matchesPattern(/urgent|asap|emergency/i)
});
```

## Example

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { Agent, handoff } from 'praisonai';

// Create specialized agents
const codeAgent = new Agent({
  name: 'CodeExpert',
  instructions: 'You are a coding expert.'
});

const supportAgent = new Agent({
  name: 'Support',
  instructions: 'You handle customer support.'
});

// Create main agent with handoffs
const mainAgent = new Agent({
  name: 'Assistant',
  instructions: 'You are a helpful assistant.',
  handoffs: [
    handoff({
      target: codeAgent,
      condition: (ctx) => /code|programming|debug/i.test(ctx.input),
      onHandoff: (ctx) => console.log('Handing off to code expert...')
    }),
    handoff({
      target: supportAgent,
      condition: (ctx) => /help|support|issue/i.test(ctx.input)
    })
  ]
});
```

## CLI Usage

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai-ts handoff info
```

The CLI provides information about the handoff feature. Full handoff functionality requires SDK usage.
