Plugins¶
Structural protocols — implement the right methods and any class qualifies. No base class, no registration decorator.
See Plugins for a full authoring guide.
ModelProvider¶
civitas.plugins.model.ModelProvider
¶
Bases: Protocol
Protocol for LLM invocation abstraction.
chat(model, messages, tools=None)
async
¶
Send a chat completion request to the model.
civitas.plugins.model.ModelResponse(content, model, tokens_in, tokens_out, cost_usd=None, tool_calls=None)
dataclass
¶
Response from an LLM call.
cost_usd = None
class-attribute
instance-attribute
¶
Computed cost in USD, or None if the model's pricing is not known.
civitas.plugins.model.ToolCall(id, name, input)
dataclass
¶
A single tool call requested by the model.
Normalized across providers: Anthropic tool_use blocks and LiteLLM
tool_calls entries both map to this shape.
Implementations¶
civitas.plugins.anthropic.AnthropicProvider(api_key=None, default_model='claude-sonnet-4-6', max_tokens=4096, max_retries=3)
¶
ModelProvider implementation backed by the Anthropic SDK.
Requires pip install civitas[anthropic].
Source code in civitas/plugins/anthropic.py
chat(model, messages, tools=None)
async
¶
Send a chat request to the Anthropic API.
Source code in civitas/plugins/anthropic.py
ToolProvider & ToolRegistry¶
civitas.plugins.tools.ToolProvider
¶
civitas.plugins.tools.ToolRegistry()
¶
Holds registered tools, injected into AgentProcess as self.tools.
Source code in civitas/plugins/tools.py
register(tool)
¶
Register a tool by its name.
Raises ValueError on duplicate name — silent overwrite would cause
the wrong implementation to be called since names are used by the model.
Source code in civitas/plugins/tools.py
StateStore¶
civitas.plugins.state.StateStore
¶
Bases: Protocol
Protocol for agent state persistence.
get(agent_name)
async
¶
Retrieve the persisted state for an agent, or None if absent.
set(agent_name, state)
async
¶
Persist state for an agent.
delete(agent_name)
async
¶
Remove persisted state for an agent.
list_agents()
async
¶
Return all agent names with persisted state.
close()
async
¶
Release resources held by the store (connections, file handles).
civitas.plugins.state.InMemoryStateStore()
¶
Default state store — in-memory, no persistence. State is lost on restart.
Source code in civitas/plugins/state.py
get(agent_name)
async
¶
set(agent_name, state)
async
¶
Store state for an agent in memory (shallow copy to prevent aliasing).
Without copying, subsequent mutations to the caller's dict would also mutate the stored checkpoint, making restore-from-checkpoint a no-op.
Source code in civitas/plugins/state.py
delete(agent_name)
async
¶
list_agents()
async
¶
civitas.plugins.sqlite_store.SQLiteStateStore(db_path='agency_state.db')
¶
SQLite-backed StateStore implementing the StateStore protocol.
State is scoped per-agent. Stateless agents (those that never call checkpoint()) incur zero overhead — no rows are written.
All I/O runs in a thread executor so SQLite operations do not block the
asyncio event loop. close() is the authoritative cleanup path and is
called by Runtime.stop(). __del__ is a safety net only.
Source code in civitas/plugins/sqlite_store.py
Plugin Loading¶
civitas.plugins.loader.load_plugins_from_config(config)
¶
Load all plugins from a YAML configuration dict.
Expected YAML structure
plugins: models: - type: anthropic config: api_key: "sk-..." default_model: "claude-sonnet-4-20250514" exporters: - type: console - type: otel config: endpoint: "http://localhost:4317" state: type: in_memory
Returns a dict with keys: model_providers, exporters, state_store.