Execute Programmatic • AI Agent SDK

execute_programmatic: Execute typed handoff programmatically with schema validation.

execute_programmatic

Method

</div>

This is a method of the TypedHandoff class in the handoff module.

Execute typed handoff programmatically with schema validation.

Signature

python
def execute_programmatic(source_agent: 'Agent', payload: Union[T, dict, str], context: Optional[Dict[str, Any]]) -> HandoffResult

Parameters

ParamField Agent

The agent initiating the handoff

ParamField Union[T, dict, str]

The typed payload (Pydantic model instance or dict) OR a string prompt (for backward compatibility)

ParamField Optional

Optional additional context

Returns

ResponseField HandoffResult

HandoffResult with response or error

Exceptions

HandoffValidationError

If payload validation fails

Uses

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

Used By

Source

View on GitHub

praisonaiagents/agent/handoff.py at line 1656