Examples¶
Runnable Python scripts that exercise the public Kneo Agent SDK surface. Every script in this directory uses mock or local models where possible so it runs without real API keys; the few that need a specific service flag it in their docstring.
For project-level orientation see the top-level
README. For the user-facing task guides that match
several of these examples, see ../docs/user/.
Directory map¶
examples/
├── 01..19_*.py numbered tour of each major capability
├── cookbook/ longer-form recipes for SME / on-prem / enterprise use
└── skills/ sample SKILL.md skill loaded by example 08
Suggested reading order¶
The fastest path from "I want an agent" to having one running:
19_simple_builder.py—build_sync_agent, the one-line shortcut. Noasyncioboilerplate.07_tool_registry_and_streaming.py— local tools and streaming chunks.- One provider-specific example matching your stack:
02_bridge_openai.py,03_bridge_langchain.py, or01_bridge_google_adk.py. 08_skill_file_ingestion.py— load theskills/weather/skill from disk.09_workflow_as_agent.py— sequential workflow wrapped as anAgent.- From here, branch into the topics that match your needs: MCP (12–13), human-in-the-loop (14–15), middleware (16–17), telemetry (18), or alternative runtime styles (Adapter 04–06).
By topic¶
Runtime styles — pick by who owns the loop¶
| Pattern | When | Examples |
|---|---|---|
| Bridge | Kneo owns the reasoning loop; you pick simple / react / plan-act |
01 Google ADK · 02 OpenAI · 03 LangChain |
| Adapter | The provider SDK owns the loop; Kneo wraps it | 04 Google ADK · 05 OpenAI Agents · 06 LangChain |
| Native | The provider SDK exposes its own runtime (used via factory) | 05, 18 |
| Builder shortcut | One-call construction without explicit factories | 19 |
Capabilities¶
- Tools and streaming —
07_tool_registry_and_streaming.py. - Skills —
08_skill_file_ingestion.pyingests theSKILL.md-format skill underskills/weather/including itsreferences/andscripts/resources. - Workflows —
09_workflow_as_agent.py(graph + sequential as agent),10_workflow_orchestrations.py(concurrent / handoff / group chat). - Agent-as-tool —
11_agent_as_tool.pyexposes one agent to another viaagent.as_tool(...). - MCP tool servers —
12_mcp_stdio_filesystem.py(stdio transport),13_mcp_http_sse.py(HTTP + SSE). - Human-in-the-loop —
14_workflow_human_in_loop_resolver.py(inline resolver),15_workflow_human_in_loop_pause.py(pause / resume across calls). - Middleware —
16_agent_middleware_logging.py(run / model / tool hooks),17_agent_middleware_short_circuit.py(guardrails, stream short-circuiting). - Telemetry —
18_opentelemetry_middleware.pyrequires the[telemetry]extra; emits GenAI semantic-convention spans to aConsoleSpanExporter.
Cookbook (cookbook/)¶
Longer-form recipes for SME / on-prem / enterprise integration. Read the one that matches the problem in front of you — they are not a sequence.
| Recipe | What it shows |
|---|---|
local_ollama.py |
Point the OpenAI runtime at a local Ollama / vLLM / llama.cpp / LocalAI server via base_url=. |
workflow_branching_and_retry.py |
Graph workflow combining WorkflowBuilder.add_edge(condition=...) routing with RetryStep resilience. |
mcp_server_catalog.py |
Load a YAML/JSON list of MCPServerConfig entries at app startup. |
sql_query_tool.py |
Read-only parameter-bound SQL tool over SQLite (psycopg2 / pymysql / pyodbc swap noted). |
rest_api_tool.py |
Per-host REST tool with auth resolved from a SecretProvider. |
object_store_tool.py |
List / get / put against MinIO / on-prem S3 via boto3's endpoint_url=. |
search_index_tool.py |
Elasticsearch / OpenSearch query tool with a query-type allow-list. |
Sample data (skills/)¶
skills/weather/— a completeSKILL.md-format skill withreferences/REFERENCE.mdandscripts/normalize_weather.pyas bundled resources. Loaded by example 08.
Running¶
Every script is self-contained and runs from the repo root:
A tests/integration/test_doc_example_drift.py gate verifies every
examples/...py referenced from a doc actually exists on disk, so
renaming an example without updating the docs is caught in CI.
Subsections¶
Files¶
01_bridge_google_adk.py02_bridge_openai.py03_bridge_langchain.py04_adapter_google_adk.py05_adapter_openai_agents.py06_adapter_langchain.py07_tool_registry_and_streaming.py08_skill_file_ingestion.py09_workflow_as_agent.py10_workflow_orchestrations.py11_agent_as_tool.py12_mcp_stdio_filesystem.py13_mcp_http_sse.py14_workflow_human_in_loop_resolver.py15_workflow_human_in_loop_pause.py16_agent_middleware_logging.py17_agent_middleware_short_circuit.py18_opentelemetry_middleware.py19_simple_builder.py