> ## 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.

# Execute Programmatic • AI Agent SDK

> execute_programmatic: Execute typed handoff programmatically with schema validation.

# execute\_programmatic

<div className="flex items-center gap-2">
  <Badge color="purple">Method</Badge>
</div>

> This is a method of the [**TypedHandoff**](../classes/TypedHandoff) class in the [**handoff**](../modules/handoff) module.

Execute typed handoff programmatically with schema validation.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def execute_programmatic(source_agent: 'Agent', payload: Union[T, dict, str], context: Optional[Dict[str, Any]]) -> HandoffResult
```

## Parameters

<ParamField query="source_agent" type="Agent" required={true}>
  The agent initiating the handoff
</ParamField>

<ParamField query="payload" type="Union[T, dict, str]" required={true}>
  The typed payload (Pydantic model instance or dict) OR a string prompt (for backward compatibility)
</ParamField>

<ParamField query="context" type="Optional" required={false}>
  Optional additional context
</ParamField>

### Returns

<ResponseField name="Returns" type="HandoffResult">
  HandoffResult with response or error
</ResponseField>

### Exceptions

<AccordionGroup>
  <Accordion title="HandoffValidationError">
    If payload validation fails
  </Accordion>
</AccordionGroup>

## Uses

* `execute_programmatic`
* `time.time`
* `validated_payload.model_dump_json`
* `json.dumps`
* `logger.info`
* `chat`
* `HandoffResult`
* `logger.error`

## Used By

* [`Agent.handoff_to`](../functions/Agent-handoff_to)
* [`TypedHandoff.execute_programmatic`](../functions/TypedHandoff-execute_programmatic)

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/agent/handoff.py#L1431">
  `praisonaiagents/agent/handoff.py` at line 1431
</Card>
