17 Verified ScenariosPython Examples

Example Library

Explore verified script patterns built directly into the repository test structure. Learn how to implement everything from local Ollama loops to distributed Redis-cached agent networks.

01 / Core Loops & Tools

Basics of initialization, tool registering, and model arguments validation.

  • 01_basic_runtime.py

    Runs a simple conversation loop between the model adapter and memory context.

  • 02_tool_execution.py

    Demonstrates automatic Pydantic-based JSON schema generation and successful function calls.

  • 12_structured_data_extraction.py

    Uses Pydantic models for verifying complex arguments fed into registered tool loops.

  • 14_manual_state_injection.py

    Manipulates agent conversational history and injects states programmatically mid-run.

02 / Governance & Safety

Deterministic security controls, approval interrupts, and recovery scenarios.

  • 03_policy_interrupt.py

    Configures a policy evaluator to automatically reject calls exceeding safety boundaries.

  • 04_resume_after_approval.py

    Saves states to checkpoints, pauses execution, and resumes once approval triggers.

  • 05_credit_review_demo.py

    Simulates a real banking workflow with multiple policy validations and audit trails.

  • 13_error_recovery_retry.py

    Implements self-healing agent pipelines that handle and retry on tool failure.

03 / Orchestration & Graphs

StateGraph orchestrations, symbolic piping, and conditional routing.

  • 07_multi_agent_graph.py

    Creates manual transitions, routing states across specialized support agents.

  • 08_symbolic_chaining.py

    Chains agents into sequential graphs using the symbolic chaining syntax sugar (>>).

  • 09_conditional_router.py

    Routes turns based on conversational intent and prints Mermaid diagrams of transitions.

  • 11_researcher_writer_graph.py

    Deploys a complex 3-agent pipeline involving researchers, writers, and editorial nodes.

04 / Production & Cloud

Context window optimization, cloud databases, and observability logs.

  • 06_ollama_local_run.py

    Bypasses network latency by executing agent loops entirely locally using Ollama models.

  • 10_performance_bench.py

    Benchmarks state caching hits and context window trimming rules during massive logs.

  • 15_aws_lambda_handler.py

    Serverless deployment handler template combining AWS Lambda with Amazon DynamoDB tables.

  • 16_distributed_redis_state.py

    Maintains distributed state caches across clustered deployments using Redis adapters.

  • 17_cloudwatch_tracing.py

    Writes structured audit event metrics directly to Amazon CloudWatch JSON logs.