Skip to main content
Query runs and traces your agents have written to the state store.
The user runs an agent, then reads persisted runs and traces from the state store for that session.

Quick Start

1

Configure State Store

Set PRAISONAI_STATE_URL or pass state_url= when creating agents. See Database Persistence for configuration options.
2

Query Runs

Run an agent, then read its runs back using get_runs(session_id):
3

Query Traces with Filters

Use get_traces() with optional filters for session_id, user_id, and limit:

How It Works

Both methods read persisted data from the configured state store:

Configuration Options

Behavior:
  • If state_store is not configured, returns [] and logs a warning
  • limit=0 returns [], limit=None returns everything matching
  • Bad/non-dict entries are skipped with a warning
  • Uses state_store.scan_prefix() when available, falls back to state_store.keys()

Common Patterns

Show last 10 runs for a user:
Export traces for a session:

Best Practices

Otherwise you get [] and a warning: "get_runs() called but no state_url configured; returning []".Configure via environment variable or constructor:
These methods scan the store, so use small limits for responsive UIs:
Both methods perform store scans which can be expensive for large datasets. Cache results when possible:

Database Persistence

Configure state stores for persistence

Session Management

Manage agent sessions and state