run • AI Agent SDK

run: Execute agent silently and return structured result.

run

Method

</div>

This is a method of the Agent class in the agent module.

Execute agent silently and return structured result.

Production-friendly execution. Always uses silent mode with no streaming or verbose display, regardless of TTY status. Use this for programmatic, scripted, or automated usage where you want just the result.

Signature

python
def run(prompt: str) -> Any

Parameters

ParamField str

The input prompt to process **kwargs: Additional arguments: – stream (bool): Force streaming if True. Default: False – output (str): Output preset override (rarely needed)

Returns

ResponseField Any

The agent’s response as a string

Usage

python
agent = Agent(instructions="You are helpful")
    result = agent.run("What is 2+2?")  # Silent, returns "4"
    print(result)

Uses

  • substitute_variables
  • chat

Notes

Unlike .start() which enables verbose output in TTY for interactive use, .run() is always silent. This makes it suitable for: – Production pipelines – Automated scripts – Background processing – API endpoints

Used By

Source

View on GitHub

praisonaiagents/agent/agent.py at line 5926