Repository navigation
PydanticAI
AlgentaToolset — a WrapperToolset over
pydantic-ai's own MCPToolset, pointed at your self-hosted
engine. execute_decision's result parses into a typed ExecutionReceipt; denials surface
through pydantic-ai's native ToolDenied
primitive with the real gate name preserved.
pip install pydantic-ai-algentaDepends on exactly two things: the published algenta-sdk and pydantic-ai-slim[mcp] (not the
full pydantic-ai metapackage).
import asyncio
from pydantic_ai import Agent
from pydantic_ai_algenta import AlgentaToolset
async def main() -> None:
toolset = AlgentaToolset(base_url="http://localhost:8000/mcp", profile="observe")
agent = Agent("openai:gpt-5", toolsets=[toolset])
result = await agent.run("What's the expected value of scenario X?")
print(result.output)
asyncio.run(main())profile="observe" is the default. Endpoint resolves from base_url= → ALGENTA_BASE_URL →
http://localhost:8000/mcp (see Self-Hosted).
All four, per the contract: observe (default) · govern · execute · full
(opt-in). force/override_safety are stripped from advertised schemas and scrubbed from
forwarded arguments, in every profile.
-
Why
ToolDenied, notApprovalRequired: an earlier version modeled an async approval-pause via pydantic-ai's deferred-approval primitives. Checked against the real engine,execute_decisionhas no "pending" state — a call succeeds or is denied by one of three named gates in the same call — so that machinery was removed.ToolDenied(what a human reviewer's "no" produces) is the correct, simpler fit. -
Transport failures are not wrapped: a dropped connection or 5xx surfaces as pydantic-ai's
own
ToolFailed/ModelRetrybefore the toolset ever sees a result. -
Try it locally:
local_demo.pyin the package directory runs a full agent turn against the stub server withTestModel— no engine, no API key:uv run --package pydantic-ai-algenta python pydantic-ai-algenta/local_demo.py. -
Tests:
ALLOW_MODEL_REQUESTS = Falseis enforced inconftest.pyas a real guard against live-model calls —uv run --package pydantic-ai-algenta pytest pydantic-ai-algenta/tests -v.
Full reference: package README
(the decision lifecycle, gate table, ExecutionReceipt fields).
thyn-ai/algenta-integrations · Apache-2.0 · The Algenta engine is separate, closed-source software — these packages are ordinary Python and TypeScript talking to its public HTTP/MCP APIs. · Support · Security · Discord
Start here
Framework guides
- LangChain
- LlamaIndex
- Pydantic AI
- MS Agent Framework
- Haystack
- LiteLLM
- Ray Serve
- vLLM
- Vercel AI SDK
- n8n
Project