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¶
Provider implementations (Anthropic, OpenAI, Gemini, Mistral, LiteLLM) live in
civitas-contrib.
Install with e.g. pip install civitas-contrib[anthropic].
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
¶
SQLiteStateStore and PostgresStateStore live in
civitas-contrib.
Install with pip install civitas-contrib or pip install civitas-contrib[postgres].
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.