laya-thalamus
Decision middleware for AI agents that uses local Laya to pick tools and judge results, falling back to an LLM when unsure.
Overview
Thalamus, named after the brain's sensory relay, pulls three recurring questions out of the LLM agent loop: which tool to call, whether the information gathered is enough, and whether a result can be trusted. It answers them with local Laya for the hot path and falls back to a larger model for hard cases. It works as drop-in middleware for OpenAI tools, LangChain and custom agents, and adds production features: fallback, circuit breaker, cache, idempotency and Prometheus or OpenTelemetry metrics. An optional FastAPI server exposes it over HTTP.
The README publishes a candid benchmark on a 100-item Chinese and English gold set measured in September 2026. Jev (jev-1.13 via OpenRouter) reached 97 to 98% tool accuracy and 86 to 93% score accuracy at about 1.3 seconds, while Laya multilingual reached 58 to 65% tool accuracy at about 0.25 seconds, with Laya ahead on English yes/no questions. This makes clear why an LLM fallback is part of the design. Documentation is in English and Chinese.
What the decision model decides
| Type | Question | Answers |
|---|---|---|
| Choice | Which tool should handle this request? | — |
| Yes / no | Is the information gathered so far enough to answer? | — |
| Score | How trustworthy is this tool result? | — |
How it works
- Agent passes the request or tool result to Thalamus
- Laya answers the routing, sufficiency or trust question
- If confidence is low, fall back to an LLM
- Middleware applies caching, circuit breaking and metrics
- Agent proceeds with the decision
Strengths
- Local fast path with LLM fallback
- Production features built in
- Honest benchmark against Jev
Caveats
- Laya accuracy on tool choice is much lower than Jev in the README's tests
- Fallback adds LLM cost on hard cases
- Chinese and English only in benchmarks
Getting started
pip install "laya-thalamus[laya]", then AgentRouter().route("What is 123 * 456?").At a glance
- Type
- Project
- Status
- beta
- Language
- Python
- Runtime
- library with optional FastAPI server
- Has code
- yes
- Has tests
- yes
Use cases and integrations
How curated lists describe it
A System1 decision orchestrator for AI agents.
wh000wh000/awesome-jev-live
Frequently asked questions
What does Thalamus decide?
Which tool to use, whether information is sufficient and whether a result can be trusted.
How does Laya compare with Jev here?
In the README's benchmark, Jev was far more accurate on tool choice but about five times slower.
Does it need a cloud model?
Only for the fallback on uncertain cases.
Related projects
AutoGPT agent platform, listed as adding Jev decision blocks for typed routing, filtering, scoring and confidence-gated next actions.
ProjectproductionPythonOne skill and MCP server for Claude Code, Codex and Hermes where Jev gates large-model turns, routes models and guards Git steps.
MCP serverbetaPythonFramework-independent participation gate letting group-chat agents answer untagged questions only when Jev finds a useful reason to join.
ProjectbetaTypeScriptPython harness for open-ended goals: AI-authored tools and checks, Jev choosing the next tool and arguments from fresh state.
ProjectbetaPythonPython agent runtime where Jev Choice decisions pick tools and arguments, and low-confidence picks go to an LLM for review.
ServicebetaPythonSelf-improving multi-platform agent harness with an optional Jev companion for typed judgments and per-session model routing.
ServicebetaTypeScript