Skip to main content

Basic Usage

Builder Methods

with_tools

Set available tools for the agent.

with_streaming

Enable/disable streaming output.

with_debug

Enable debug logging to sessions/{session_id}/debugger/.

with_thinking

Enable extended thinking (Claude only). Budget: 8000, 16000, 32000, or 64000.

with_hooks

Set behavior hooks.

with_hook_short_circuit

Stop hook execution on first Deny.

with_max_tool_iterations

Limit consecutive tool call loops.

with_auto_save

Auto-save session after each turn.

with_injection_chain

Set context injection chain.

with_auto_name

Automatically name conversations after first turn.

with_naming_llm

Use separate LLM for naming (e.g., faster/cheaper model).

with_prompt_caching

Enable/disable prompt caching.

with_dangerous_skip_permissions

Skip ALL permission checks. Use with security hooks.

Complete Example