What each layer handles
| Concern | Orchestration framework | Mellea |
|---|---|---|
| Which tool to call next | ✓ | — |
| Multi-agent routing | ✓ | — |
| Workflow graphs | ✓ | — |
| Output meets requirements | — | ✓ |
| Instruct–validate–repair | — | ✓ |
| Structured type enforcement | — | ✓ |
| Per-call sampling strategy | — | ✓ |
| Context window management | — | ✓ |
Using Mellea inside an orchestrator
A@generative function or an instruct() call is just a Python function. Any
framework that calls Python functions can use Mellea as a tool.
smolagents
Requires: uv pip install smolagents
reliable_summarize as a tool. From its perspective, it
is an opaque Python function. Inside, Mellea ensures the word-count requirement is
enforced before the result is returned.
LangChain
entity_tool in its toolbox without knowing Mellea
is involved.
Building agents with Mellea
Mellea also supports building agentic programs directly, without an external orchestrator:- ReACT loops — implement thought/action/observation cycles using
m.chat()withChatContextand the@tooldecorator. See Tools and Agents. - Guarded agents — combine the ReACT pattern with
requirementsandGuardianCheckto enforce safety constraints at every step. See Security and Taint Tracking. - Structured outputs — use
@generativewith Pydantic models orLiteraltypes to enforce type-safe structured output at each step. See Generative Functions.
Adoption paths
Greenfield
Build directly with Mellea from the start:Leaf-node injection
Add Mellea to an existing system by wrapping individual calls:Tool enrichment
Add Mellea to an existing orchestrator by replacing unreliable tool implementations: Replace a tool function that directly calls an LLM with a Mellea-instrumented version that validates its output before returning. The orchestrator’s routing logic is unchanged; the tool just becomes more reliable.When you need an orchestrator
Mellea does not provide:- Agent planning and reasoning about which tool to use next
- Multi-agent coordination (spawning sub-agents, passing results between agents)
- Long-running workflow state across sessions
- Automatic tool selection from a registry
See also: Tools and Agents | Security and Taint Tracking