Zero-dependency asyncio plugin framework, a Python port of cordis
pip install pycordis-framework Copy PIP instructions
The plugin runtime for Python AI agents. Your model clients, tools, memory and connectors become plugins that start when they're ready, restart when they fail, and clean up after themselves.
Quickstart · A real agent · Agent guide · Reference
pycordis is not another LLM framework. It sits underneath the one you already use (the OpenAI or Anthropic SDK, PydanticAI, LangGraph…) and runs everything around it. Think FastAPI's Depends, plus a process supervisor, for long-running async apps.
pip install pycordis-framework # Python 3.12+, zero dependencies The problem Every real agent's main() ends up like this:
llm = AsyncAnthropic() # crashes if the key is missing db = await VectorDB.connect(url) # must come before search_docs tools = [search_docs(db)] if SLACK_TOKEN: # optional tool, ad-hoc check tools.append(slack_tool(SLACK_TOKEN)) memories: dict[str, Memory] = {} # global, shared by every user try: await serve(llm, tools, memories) finally: await db.close() # and the Slack client? the scheduler? Startup order is maintained by hand. One flaky dependency kills the whole process. Per-user state is a global dict. And when a tool is missing, you get to ask "why didn't it load?"
With pycordis, each piece is a plugin that declares what it provides and what it needs. The runtime handles the order, the restarts, the isolation and the cleanup.
import asyncio from collections.abc import Callable from pycordis import Context, ServiceKey, plugin_meta DB = ServiceKey[dict[str, str]]("db") @plugin_meta(name="search", inject=[DB]) # needs DB def search(ctx: Context, config: None) -> Callable[[], None]: print(f"search: online, {len(ctx.use(DB))} docs") return lambda: print("search: offline") # cleanup, run on unload @plugin_meta(name="db", provide=DB) # provides DB async def db(ctx: Context, config: None) -> None: await asyncio.sleep(0.1) # connecting... ctx.provide(DB, {"intro": "hello"}) async def main() -> None: async with Context() as app: app.plugin(search) # registered first: it simply waits for DB conn = await app.plugin(db) await conn.dispose() # pull the DB out from under it asyncio.run(main()) search: online, 1 docs search: offline search started the moment DB existed, and shut itself down the moment it went away. No ordering in main(), no try/finally, no globals.
A model client with a restart policy, a tool registry you can change while it runs, and private memory per user:
# my_agent.py from dataclasses import dataclass from anthropic import AsyncAnthropic from pycordis import Context, ServiceKey, plugin_meta LLM = ServiceKey[AsyncAnthropic]("llm") @dataclass class LLMConfig: api_key: str @plugin_meta(name="llm", provide=LLM, Config=LLMConfig) def llm(ctx: Context, config: LLMConfig) -> None: ctx.provide(LLM, AsyncAnthropic(api_key=config.api_key)) # needs a "slack_client" service that nothing provides yet: see `pycordis doctor` below @plugin_meta(name="slack", inject=["slack_client"]) def slack(ctx: Context, config: None) -> None: ... The config file decides what runs:
# agent.toml [loader] watch = true # edit while it runs: only what changed reloads [[plugins]] id = "llm" use = "my_agent:llm" config = { api_key = "${env:ANTHROPIC_API_KEY}" } # checked against LLMConfig restart = { mode = "on-failure", max_restarts = 5 } # self-healing [[plugins]] id = "slack" use = "my_agent:slack" disabled = false # true: kept in the file, not running Start it, with health endpoints for your orchestrator:
pycordis start -c agent.toml --health-port 8080 # GET /healthz /readyz /inspect # in a container, add --health-host 0.0.0.0 so the orchestrator's probes reach it If something doesn't start, ask why:
$ pycordis doctor -c agent.toml root #0 ACTIVE └─ slack #2 [entry slack] PENDING missing-service: no plugin declares or currently provides "slack_client" How it compares pycordis hand-written main() FastAPI lifespan + Depends Start order from dependencies ✅ by hand by hand Restart a failed part while the rest keeps running ✅ ❌ ❌ Add or remove parts while running ✅ ❌ ❌ Per-conversation state with cleanup ✅ by hand per request Explains why something didn't start ✅ ❌ ❌ pycordis works with agent frameworks, not against them: it owns the lifecycles, and your framework owns the reasoning.
Does it replace LangChain, LangGraph or PydanticAI? No. Use them inside plugins. pycordis manages their clients, tools and lifetimes.
Do I need the config file or the CLI? No. Everything works from plain Python. The loader and pycordis command are optional.
Is it production-ready? It's 0.1 (beta): strictly typed, 1,250+ tests and 98% coverage, but the API may still change before 1.0.
What's cordis? The TypeScript plugin framework behind Koishi. pycordis is a faithful asyncio port of cordis 4.1.0, with the same lifecycle, events and error messages. You don't need to know it. If you do, the mapping table lists every API side by side.
MIT. pycordis is a port of cordis (MIT, © 2021-present Shigma).
Both files in this release have provenance metadata.
agents asyncio cordis dependency-injection framework llm plugin services
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.
Both files in this release have been uploaded with provenance metadata.
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.




