Skip to content

Add OrcaRouter agent example - #896

Open
JinhaoSong322 wants to merge 2 commits into
apache:mainfrom
JinhaoSong322:add-orcarouter-provider
Open

Add OrcaRouter agent example#896
JinhaoSong322 wants to merge 2 commits into
apache:mainfrom
JinhaoSong322:add-orcarouter-provider

Conversation

@JinhaoSong322

Copy link
Copy Markdown

Summary

Adds a new example, examples/orcarouter-agent/, that shows how to build a small
stateful chat agent with Burr backed by OrcaRouter.

OrcaRouter is an OpenAI-compatible gateway (https://api.orcarouter.ai/v1) that
routes to a wide range of models through a single API key. It also runs
gateway-level, zero-trust security for AI agents on the same endpoint — screening
every prompt/response and governing every tool call on a default-deny basis, with
no application code changes.

Because the endpoint is OpenAI-compatible, the example uses the standard openai
client with base_url pointed at OrcaRouter and the orcarouter/auto model
alias. The agent loops between human_input and ai_response actions,
accumulating a chat_history in state.

Changes

  • examples/orcarouter-agent/application.py — Burr state machine with two
    actions (human_input, ai_response) calling https://api.orcarouter.ai/v1
    via the openai client (ORCAROUTER_API_KEY, optional
    ORCAROUTER_BASE_URL/ORCAROUTER_MODEL).
  • examples/orcarouter-agent/README.md, notebook.ipynb,
    requirements.txt, __init__.py, statemachine.png — standard example
    contents (mirrors examples/simple-chatbot-intro/).
  • examples/README.md — added the example to the index.
  • docs/ecosystem.rst — added an OrcaRouter row to the LLM & AI Frameworks table.

How I tested this

  • python -m pytest validate_examples.py in examples/ — 48 passed (includes
    orcarouter-agent).
  • black, isort, flake8 clean on the new example.
  • scripts/check_asf_headers.py — clean.
  • Live test with a real OrcaRouter key through the example's code path
    (application.run(..., halt_after=["ai_response"])) — returned a valid
    completion from https://api.orcarouter.ai/v1.

Notes

No existing Burr code was changed; this only adds a new example and two doc
index entries.

Checklist

  • PR has an informative and human-readable title (this will be pulled into the release notes)
  • Changes are limited to a single goal (no scope creep)
  • Code passed the pre-commit check & code is left cleaner/nicer than when first encountered.
  • Any change in functionality is tested
  • New functions are documented (with a description, list of inputs, and expected output)
  • Placeholder code is flagged / future TODOs are captured in comments
  • Project documentation has been updated if adding/changing functionality.

Disclosure: I'm an engineer on the OrcaRouter team.

Add a minimal stateful chat agent example that points the OpenAI-compatible
openai client at OrcaRouter (https://api.orcarouter.ai/v1), using the
orcarouter/auto model alias. Register the example in the examples index and
the ecosystem docs table.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: JinhaoSong322 <jinhao.song@myflashcloud.com>
@github-actions github-actions Bot added area/website burr.apache.org website area/examples Relates to /examples labels Aug 19, 2026

@jernejfrank jernejfrank left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks looks great!

@jernejfrank

Copy link
Copy Markdown
Contributor

@JinhaoSong322 sorry was a bit too fast on the approval there. Do you mind addressing this from the CI

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED tests/test_release_config.py::test_examples_include_exclude_coverage - AssertionError: 
  ❌ Example directories exist but are NOT in pyproject.toml config:
     ['orcarouter-agent']
  
     WHY THIS MATTERS:
     Flit auto-discovers examples/ as a package (it has __init__.py) and will
     include ALL subdirectories in the release tarball unless explicitly excluded.
     Every example directory MUST be either included or excluded to ensure the
     Apache release contains only the intended examples for voters to test.
  
     To fix: Add to pyproject.toml [tool.flit.sdist]:
     - To INCLUDE in Apache release: add 'examples/<name>/**' to 'include' list
     - To EXCLUDE from Apache release: add 'examples/<name>/**' to 'exclude' list
  
     Currently only these 5 examples should be included:
     email-assistant, multi-modal-chatbot, streaming-fastapi, deep-researcher, hello-world-counter
  
  
  📋 Current configuration:
     Included examples (5): ['deep-researcher', 'email-assistant', 'hello-world-counter', 'multi-modal-chatbot', 'streaming-fastapi']
     Excluded examples (31): ['adaptive-crag', 'conversational-rag', 'custom-serde', 'deployment', 'hamilton-integration', 'haystack-integration', 'image-telephone', 'instructor-gemini-flash', 'integrations', 'llm-adventure-game', 'ml-training', 'multi-agent-collaboration', 'openai-compatible-agent', 'opentelemetry', 'other-examples', 'parallelism', 'pytest', 'rag-lancedb-ingestion', 'ray', 'recursive', 'simple-chatbot-intro', 'simulation', 'streaming-overview', 'talks', 'templates', 'test-case-creation', 'tool-calling', 'tracing-and-spans', 'typed-state', 'web-server', 'youtube-to-social-media-post']
     Included files (1): ['__init__.py']
     Excluded files (3): ['README.md', 'fastapi_mount_example.py', 'validate_examples.py']
     Actual directories (37): ['adaptive-crag', 'conversational-rag', 'custom-serde', 'deep-researcher', 'deployment', 'email-assistant', 'hamilton-integration', 'haystack-integration', 'hello-world-counter', 'image-telephone', 'instructor-gemini-flash', 'integrations', 'llm-adventure-game', 'ml-training', 'multi-agent-collaboration', 'multi-modal-chatbot', 'openai-compatible-agent', 'opentelemetry', 'orcarouter-agent', 'other-examples', 'parallelism', 'pytest', 'rag-lancedb-ingestion', 'ray', 'recursive', 'simple-chatbot-intro', 'simulation', 'streaming-fastapi', 'streaming-overview', 'talks', 'templates', 'test-case-creation', 'tool-calling', 'tracing-and-spans', 'typed-state', 'web-server', 'youtube-to-social-media-post']
     Actual files (4): ['README.md', '__init__.py', 'fastapi_mount_example.py', 'validate_examples.py']
  
assert not ["\n❌ Example directories exist but are NOT in pyproject.toml config:\n   ['orcarouter-agent']\n\n   WHY THIS MATTERS:...media-post']\n   Actual files (4): ['README.md', '__init__.py', 'fastapi_mount_example.py', 'validate_examples.py']\n"]
============ 1 failed, 644 passed, 1 skipped, 19 warnings in 17.66s ============

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/examples Relates to /examples area/website burr.apache.org website

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants