Streaming and OutputConfig presets

Stream tokens live for faster perceived latency

When an agent writes a 200-word explanation, waiting 6 seconds for a blank screen feels broken. Configure OutputConfig(stream=True) or output='silent' / 'verbose' / 'json' to match your interface.

Example

from praisonai import Agent, OutputConfig

writer = Agent(
    name='LiveWriter',
    instructions='Explain token streaming in one short sentence.',
    output=OutputConfig(stream=True, verbose=False),
)
for chunk in writer.start('Why stream AI replies?'):
    print(chunk, end='', flush=True)
print()

Try it Yourself

Example explained

  • OutputConfig(stream=True, verbose=False) — Streams chunks progressively without terminal trace boxes.
  • for chunk in writer.start(…) — Iterates over streamed tokens as they arrive from the model.

Choose the right OutputConfig mode

Use output='silent' in automated Python pipelines and unit tests, OutputConfig(stream=True) in interactive CLIs/chat UIs, and output='verbose' while debugging tool arguments.

Common pitfall: mixing verbose banners into JSON stdout

If another program pipes your script's stdout into jq or json.loads(), always set output='silent' or json_output=True so terminal formatting boxes don't break JSON parsing.

Reference: documentation