Oracle Generative AI Β· Multi-Agent Reasoning Orchestrator SDK
Built inside Oracle. Used in production. Open to everyone.
Documentation Β· Cognitive Router Β· Multi-agent Β· DeepAgent Β· 56 Tutorials Β· Workbench
from locus import Agent
agent = Agent(model="oci:openai.gpt-5")
print(agent.run_sync("What is the capital of France?").text)
# β ParisThat's it. Agent handles the model call, the response, and any retries.
Swap "oci:openai.gpt-5" for "openai:gpt-4o" or "anthropic:claude-sonnet-4-6" β the interface stays the same.
Tools are plain Python functions. The model sees the docstring and decides when to call them.
from locus import Agent, tool
@tool
def get_weather(city: str) -> str:
"""Return the current weather for a city."""
return weather_api.fetch(city)
agent = Agent(
model="oci:openai.gpt-5",
tools=[get_weather],
system_prompt="You are a helpful travel assistant.",
)
print(agent.run_sync("Should I bring an umbrella to Tokyo tomorrow?").text)The agent loops β Think β call tool β Think β answer β until it's done.
Add @tool(idempotent=True) to any tool that must not fire twice (bookings, payments, alerts).
The loop dedupes on (name, args) so retries are safe by design.
pip install "locus-sdk[oci]" # OCI GenAI (90+ models, day-0)
pip install "locus-sdk[openai]" # OpenAI
pip install "locus-sdk[anthropic]" # Anthropic
pip install "locus-sdk[sdk]" # everythingNo mandatory cloud account to start β MockModel lets every tutorial run offline.
Once you know agents, the next step is knowing which shape to use. The cognitive router takes a natural-language task, selects from eight proven coordination patterns, and instantiates the right primitive β without you hand-coding the topology.
from locus.deepagent.workflow import create_research_workflow, KEY_PROMPT
workflow = create_research_workflow(
model=get_model(),
tools=[web_search, web_fetch],
grounding_threshold=0.65,
)
result = await workflow.execute({KEY_PROMPT: "What happened in mathematics in 2026?"})
print(result.final_state["summary"])The workflow runs: execute (ReAct) β causal inference β summarize β grounding eval β
lightweight regenerate or full replan if grounding is too low.
Every step emits research.* SSE events you can stream in real time.
β Cognitive router concept Β· Research workflow
When one agent isn't enough, locus gives you seven in-process shapes plus cross-process A2A.
Every pattern uses the same Agent class and the same event stream.
| Pattern | When to use |
|---|---|
| SequentialPipeline | A β B β C in order; each output feeds the next |
| ParallelPipeline | Fan out to N agents simultaneously, merge results |
| LoopAgent | Refine until a condition fires (PASS/FAIL, confidence, iteration cap) |
| Orchestrator + Specialists | One coordinator routes to domain experts in parallel |
| Swarm | Open-ended research; peers share a task queue and context |
| Handoff | Escalation desk; conversation moves with full history to the next specialist |
| StateGraph | Explicit DAG with conditional edges, cycles, and human-in-the-loop gates |
| A2A | Cross-process meshes over HTTP; agents advertise capabilities via AgentCard |
from locus import Agent, SequentialPipeline
researcher = Agent(model=model, system_prompt="Find three key facts about the topic.")
critic = Agent(model=model, system_prompt="Identify any gaps or errors in the research.")
writer = Agent(model=model, system_prompt="Write a clear one-paragraph summary.")
result = await SequentialPipeline(agents=[researcher, critic, writer]).run(
"Explain quantum entanglement to a high-schooler."
)
print(result.text)β All patterns
| π§ Cognitive router | Describe a task β eight named protocols β right primitive compiled automatically. LLM fills a typed schema; routing is deterministic. |
| π€ Multi-agent | Seven native patterns + cross-process A2A. One Agent class. One event stream. |
| π¬ DeepAgent | create_deepagent (single agent, per-turn grounding) and create_research_workflow (StateGraph with post-hoc grounding eval + two-level recovery). |
| π‘ Observability | Opt-in EventBus β one run_context() streams 40+ canonical events from every layer, no external broker. TelemetryHook for OpenTelemetry/OTLP. |
| π§ Reasoning | reflexion=True Β· grounding=True Β· CausalChain Β· GSAR typed grounding layer (arXiv:2604.23366). |
| π‘ Idempotent tools | @tool(idempotent=True) β dedupes on (name, args). The model can't double-charge, double-book, or double-page. |
| πΎ Durable memory | 9 backends β OCI Object Storage, PostgreSQL, Redis, SQLite, Oracle 26ai, OpenSearch, in-memory, file, HTTP. |
| π RAG | 7 vector stores Β· OCI Cohere + OpenAI embeddings Β· multimodal (PDF, image OCR, audio). |
| π‘ Streaming + Server | Typed events Β· SSE Β· AgentServer (FastAPI, per-principal thread isolation). |
| πͺ Hooks | Logging Β· OpenTelemetry Β· ModelRetry Β· Guardrails Β· Steering (LLM-as-judge). |
| πͺ MCP | MCPClient consumes MCP servers. LocusMCPServer exposes locus tools as MCP. |
| π Multi-modal | Agent(web_search=β¦, web_fetch=β¦, image_generator=β¦, speech_provider=β¦) auto-registers tools. |
| π Evaluation | EvalCase / EvalRunner / EvalReport regression suites. |
| π§° Models | OCI GenAI (90+ models, V1 + SDK) Β· OpenAI Β· Anthropic Β· Ollama. |
Every locus agent runs the same four-node loop β Think β Execute β Reflect β Terminate β with one immutable state flowing through.
- Think β model decides the next action or final answer.
- Execute β runs tool calls in parallel;
@tool(idempotent=True)dedupes on(name, args). - Reflect β Reflexion, Grounding, Causal on cadence or on error.
- Terminate? β typed stop conditions:
MaxIterations(10) | ToolCalled("submit") & ConfidenceMet(0.9).
Every node emits a write-protected typed event β same stream powers SSE, telemetry hooks, and your own async for event in agent.run(β¦) consumer.
examples/ has 56 progressive tutorials, each a single runnable file.
Every tutorial runs offline with MockModel; set one env var to upgrade to a real provider.
git clone https://github.com/oracle-samples/locus.git
cd locus && pip install -e .
python examples/tutorial_01_basic_agent.py # start here
python examples/tutorial_02_agent_with_tools.py # add tools
python examples/tutorial_41_deepagent.py # deep research
python examples/tutorial_51_cognitive_router.py # routing
python examples/tutorial_56_research_workflow.py # full research pipeline| Track | What you learn |
|---|---|
| Foundations (01β05, 21, 27, 28, 37) | Agent, tools, memory, streaming, hooks, server, termination |
| Graphs (06β10, 25, 35, 36) | StateGraph, conditional routing, reducers, HITL, composition |
| Multi-agent (11, 16β18, 34, 41β45) | Swarm, handoff, orchestrator, A2A, DeepAgent, real-world crews |
| Reasoning (13, 14, 39) | Structured output, reflexion + grounding, GSAR typed grounding |
| RAG (22β24) | Basics, providers, RAG agents |
| Skills, playbooks, plugins (12, 15, 31β33) | MCP, playbooks, plugins, steering |
| Production (19, 20, 26, 29, 30, 38, 40) | Guardrails, checkpoints, evaluation, model providers, DAC |
| Real-world workflows (46β50) | Incident response, procurement, contract review, audio |
| Cognitive router + observability (51β56) | Routing, EventBus, agent yield bridge, event catalogue, research |
Try every tutorial in your browser. Bring your own model key β no install required.
# or open in GitHub Codespaces (badge above)
cd workbench && docker-compose upThree model slots (A / B / C) so multi-agent tutorials can mix a fast triage model with a deeper specialist. Tutorials tab, Skills tab, Protocols tab (shows all eight cognitive router protocols with cost + latency metadata).
β Workbench guide
pip install "locus-sdk[oci,server]"AgentServer is a drop-in FastAPI app: POST /invoke, POST /stream, GET/DELETE /threads/{id}, GET /health.
from locus.server import AgentServer
server = AgentServer(agent=my_agent, api_key=os.environ["API_KEY"])
server.run(host="0.0.0.0", port=8080)The repo ships a multi-stage Dockerfile and a Helm chart at
deploy/helm/locus-agent/ β Deployment, HPA, Ingress, OCI workload-identity hooks.
β Deploy guide
src/locus/
βββ agent/ Agent runtime, config, SequentialPipeline / ParallelPipeline / LoopAgent
βββ core/ AgentState, Message, events, termination algebra, Send
βββ loop/ ReAct nodes (Think, Execute, Reflect)
βββ router/ Cognitive router β GoalFrame, ProtocolRegistry, PolicyGate, CognitiveCompiler
βββ deepagent/ create_deepagent + create_research_workflow + 6 node primitives
βββ observability/ EventBus, run_context, agent yield bridge, EV_* constants
βββ memory/ BaseCheckpointer + 9 backends
βββ models/ Provider registry + OCI, OpenAI, Anthropic, Ollama
βββ multiagent/ Orchestrator, Swarm, Handoff, StateGraph, Functional
βββ a2a/ Cross-process Agent-to-Agent protocol
βββ reasoning/ Reflexion, Grounding, Causal, GSAR
βββ rag/ Embeddings + 7 vector stores + retrievers
βββ providers/ Multi-modal: web search, web fetch, image, speech
βββ tools/ @tool decorator, registry, builtins, executors
βββ hooks/ Logging, telemetry, retry, guardrails, steering
βββ skills/ AgentSkills.io filesystem-first capability disclosure
βββ playbooks/ Declarative step plans + PlaybookEnforcer
βββ server/ FastAPI AgentServer with thread persistence
βββ evaluation/ EvalCase + EvalRunner + EvalReport
βββ integrations/ MCP (client + server)
workbench/ Browser playground β Tutorials / Skills / Protocols tabs,
three model slots, SSE event stream, Codespaces-ready.
examples/ 56 progressive tutorials, each a single runnable file.
tests/unit/ Deterministic, no external deps. Runs in CI on every PR.
tests/integration/ Live OCI / OpenAI / Oracle Database 26ai. Gated on credentials.
git clone https://github.com/oracle-samples/locus.git
cd locus && pip install -e ".[dev,all]"
hatch run check # ruff + mypy
hatch run test # unit tests across Python 3.11β3.14
pre-commit installSee CONTRIBUTING.md. Every PR runs format, lint, mypy, unit tests, DCO sign-off.
@article{kamelhar2026gsar,
title = {GSAR: Typed Grounding for Hallucination Detection and Recovery in Multi-Agent LLMs},
author = {Kamelhar, Federico A.},
journal = {arXiv preprint arXiv:2604.23366},
year = {2026},
}Please consult the security guide for our responsible security vulnerability disclosure process.
Copyright (c) 2026 Oracle and/or its affiliates.
Released under the Universal Permissive License v1.0 as shown at https://oss.oracle.com/licenses/upl/.