Python API¶
Generated from the docstrings in src/aeon. The aeon.axioms package has no dependencies, so importing only it already gives you the standalone gate.
Top level: from aeon import axiom, enforce, Gate, Action, Level, Mode, Budget, ChaosBudget, Monitor, default_gate, ActionBlocked.
aeon.axioms¶
aeon.axioms ¶
Axioms and the gate: declare rules over actions and enforce them before execution.
from aeon.axioms import axiom, enforce @axiom(on_violation="BLOCK") ... def no_destructive_tool_call(action): ... return action.tool not in {"delete_file"} or action.approved
AxiomRegistry ¶
An ordered, thread-safe collection of axioms.
AxiomSpec
dataclass
¶
A registered axiom: the rule function plus its declared level and scope.
check ¶
check(action: Action) -> Finding | None
Run the rule. Returns a finding when it objects, None when it passes.
Gate ¶
Evaluates axioms for each action and applies the verdict according to the mode.
Fail-safe rule: if an axiom or the gate itself raises, the verdict is BLOCK. In enforce mode the action does not run; in shadow mode it runs and the error is logged.
subscribe ¶
subscribe(
callback: Callable[[Decision], None],
) -> Callable[[], None]
Call callback after every decision. Returns an unsubscribe function.
reset ¶
reset(agent: str = 'default') -> bool
Release agent from Safe State. Returns whether it was held.
observe ¶
observe(
action: Action,
*,
latency_ms: float,
error: BaseException | None = None,
tokens: int | None = None,
cost: float | None = None,
) -> None
Record the outcome of an action that ran. Feeds the baseline and the audit log.
KillSwitch ¶
Operator stop. While engaged, every action of every agent is blocked, in any mode.
SafeState
dataclass
¶
Why and since when an agent is held in Safe State.
Action
dataclass
¶
One action an agent is about to take: a tool name plus its arguments.
approved is set by a human or an approval hook. context carries anything an
axiom may need (the user's request, the step number, the environment).
ActionLimited ¶
Bases: ActionBlocked
Raised when a LIMIT verdict was not approved. The agent stays out of Safe State.
AeonError ¶
Bases: Exception
Base class for errors raised by Æon.
Decision
dataclass
¶
The gate's answer for one action.
verdict is what the rules concluded. enforced says whether that verdict was
applied (false in shadow mode). allowed says whether the action may run.
to_record ¶
to_record(*, include_args: bool = False) -> dict[str, Any]
The audit form. Arguments are digested unless include_args is set.
Finding
dataclass
¶
One axiom's objection, as recorded in a decision.
Level ¶
Bases: IntEnum
Autonomy levels, ordered by severity.
GO means no rule objected. ALERT records and never interferes. LIMIT
restricts (the action needs approval and does not run without it). BLOCK stops
the action and moves the agent to its Safe State.
Mode ¶
Bases: str, Enum
shadow decides and records but never enforces. enforce applies the verdict.
SafeStateActive ¶
Violation
dataclass
¶
What an axiom returns to object to an action. level overrides the axiom default.
axiom ¶
axiom(fn: AxiomFn) -> AxiomFn
axiom(
*,
on_violation: str | Level = ...,
name: str | None = ...,
tools: Iterable[str] | None = ...,
description: str = ...,
gate: Gate | None = ...,
) -> Callable[[AxiomFn], AxiomFn]
axiom(
fn: AxiomFn | None = None,
/,
*,
on_violation: str | Level = Level.BLOCK,
name: str | None = None,
tools: Iterable[str] | None = None,
description: str = "",
gate: Gate | None = None,
) -> AxiomFn | Callable[[AxiomFn], AxiomFn]
Declare a rule over an action.
The function receives an :class:Action and returns True (or None) to pass,
False or a reason string to object at on_violation level, or a
:class:Violation to choose the level per call. tools limits the rule to those
tool names. The function is registered and returned unchanged, so it stays testable.
capture ¶
capture() -> Iterator[AxiomRegistry]
Redirect module-level @axiom registrations into a fresh registry.
Used to load an axiom file in isolation (aeon axioms check).
Yields:
| Type | Description |
|---|---|
AxiomRegistry
|
The registry that receives the axioms declared inside the block. |
default_gate ¶
default_gate() -> Gate
The process-wide gate, built from aeon.toml and AEON_* variables on first use.
enforce ¶
enforce(
executor: F,
/,
*,
gate: Gate | None = ...,
agent: str = ...,
tool: str | None = ...,
to_action: ActionBuilder | None = ...,
context: Mapping[str, Any] | None = ...,
) -> F
enforce(
executor: None = None,
/,
*,
gate: Gate | None = ...,
agent: str = ...,
tool: str | None = ...,
to_action: ActionBuilder | None = ...,
context: Mapping[str, Any] | None = ...,
) -> Callable[[F], F]
enforce(
executor: F | None = None,
/,
*,
gate: Gate | None = None,
agent: str = "default",
tool: str | None = None,
to_action: ActionBuilder | None = None,
context: Mapping[str, Any] | None = None,
) -> F | Callable[[F], F]
Wrap an executor so every call is checked by the gate before it runs.
Works on sync and async callables, directly or as a decorator. A denied call raises
:class:ActionBlocked (or its subclasses :class:ActionLimited,
:class:SafeStateActive) and the executor is not called.
set_default_gate ¶
set_default_gate(gate: Gate | None) -> None
Replace the process-wide gate (None rebuilds it from config on next use).
aeon.axioms.builtin¶
aeon.axioms.builtin ¶
Ready-made axiom factories. Each returns an :class:AxiomSpec to pass to a Gate.
They are deliberately simple and syntactic: they look at tool names and argument values, never at the meaning of free text (see docs/known-limits.md).
deny_tools ¶
deny_tools(
tools: Iterable[str],
*,
unless_approved: bool = True,
level: Level | str = Level.BLOCK,
name: str = "deny_tools",
) -> AxiomSpec
Object to the listed tools. With unless_approved, an approved action passes.
allow_tools ¶
allow_tools(
tools: Iterable[str],
*,
level: Level | str = Level.BLOCK,
name: str = "allow_tools",
) -> AxiomSpec
Object to any tool that is not on the allow list.
rate_limit ¶
rate_limit(
max_calls: int,
per_seconds: float,
*,
tools: Iterable[str] | None = None,
level: Level | str = Level.LIMIT,
name: str = "rate_limit",
clock: object = None,
) -> AxiomSpec
Object once an agent exceeds max_calls within a sliding window.
Counts decisions, not executions, so a denied call still counts. clock is a
zero-argument callable returning seconds (monotonic by default), for tests.
deny_arg_pattern ¶
deny_arg_pattern(
pattern: str,
*,
args: Iterable[str] | None = None,
tools: Iterable[str] | None = None,
level: Level | str = Level.BLOCK,
name: str = "deny_arg_pattern",
) -> AxiomSpec
Object when a string argument matches pattern (a Python regex).
require_approval ¶
require_approval(
tools: Iterable[str], *, name: str = "require_approval"
) -> AxiomSpec
LIMIT the listed tools: they run only when the action is approved.
aeon.baseline¶
aeon.baseline ¶
Behavioural baseline, deviation score and budget.
See docs/concepts/budget.md for the math. In short, per agent:
- The first
Budget.baseline_nresults calibrate a baseline (latency mean and spread, error rate, repeat rate, token mean and spread, tool-call distribution). - Each later result gets a deviation score
d_t: a weighted sum of one-sided, clipped z-scores plus a tool-distribution drift term (Jensen-Shannon divergence). - The accumulated deviation is a one-sided CUSUM,
S_t = max(0, S_{t-1} + d_t - k). S_tcrossingalert_at/limit_at/block_atyields ALERT / LIMIT / BLOCK.
Separately, the absolute envelope (p99_ms, error_rate, max_cost,
max_tokens) is checked over a rolling window and does not need calibration.
record runs on the observation path; finding runs on the decision path and only
reads a cached level.
Budget
dataclass
¶
How much deviation an agent may accumulate, plus an optional absolute envelope.
Thresholds apply to the accumulated deviation S_t (unitless, roughly "sigmas
above slack, summed over steps"). Envelope fields left as None are not checked.
Baseline
dataclass
¶
Observation
dataclass
¶
One tool call as seen by the monitor. latency_ms is in milliseconds.
Monitor ¶
Tracks every agent's behaviour against a baseline and a budget.
record ¶
record(
action: Action,
*,
latency_ms: float,
error: bool,
tokens: int | None = None,
cost: float | None = None,
) -> float
Add one result. Returns this step's deviation score d_t.
record_usage ¶
record_usage(
agent: str,
*,
tokens: int | None = None,
cost: float | None = None,
) -> None
Account tokens or cost not tied to one tool call (for example an LLM call).
finding ¶
finding(agent: str) -> Finding | None
Return the budget finding for agent, or None while its level is GO.
reset_accumulated ¶
reset_accumulated(agent: str) -> None
Zero agent's accumulated deviation, window, repeat memory and usage totals.
The calibrated baseline is kept: a reset forgives past deviation, it does not forget what normal behaviour looks like.
baseline ¶
baseline(agent: str) -> Baseline | None
Return agent's calibrated baseline, or None if it has none yet.
set_baseline ¶
set_baseline(agent: str, baseline: Baseline) -> None
Install baseline for agent instead of calibrating from live calls.
js_divergence ¶
js_divergence(
p: Mapping[str, float], q: Mapping[str, float]
) -> float
Jensen-Shannon divergence normalized to [0, 1] (base-2 logarithm).
aeon.audit¶
aeon.audit ¶
Append-only, hash-chained audit log written off the decision path.
Backend ¶
Bases: Protocol
Append-only storage. Only the audit writer thread calls append.
location
property
¶
location: str
Human-readable place the records live (a path, sqlite:<path> or memory).
head ¶
head() -> tuple[int, str] | None
Return (seq, hash) of the last stored record, or None if empty.
append ¶
append(records: list[dict[str, Any]]) -> None
Store records in order. Must be all-or-nothing from the caller's view.
entries ¶
entries() -> Iterator[Entry]
Yield (line number, record) for each stored record, oldest first.
JsonlBackend ¶
One JSON record per line. fsync=True makes each batch durable before returning.
head ¶
head() -> tuple[int, str] | None
Return (seq, hash) from the last line of the file, or None.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
The last line is not a valid record (the file was edited or truncated). |
append ¶
append(records: list[dict[str, Any]]) -> None
Append one line per record, flushing (and fsyncing if enabled) before returning.
MemoryBackend ¶
Keeps records in a list. For tests and ephemeral gates; nothing is persisted.
SqliteBackend ¶
VerifyReport
dataclass
¶
Result of verifying a chain. first_bad_* point at the first broken link.
AuditLog ¶
Append-only, hash-chained, written off the decision path by one background thread.
emit ¶
emit(kind: str, data: Mapping[str, Any]) -> None
Queue an event. Never blocks; a full queue drops the event and counts it.
flush ¶
flush(timeout: float = 5.0) -> bool
Wait until everything emitted so far is durable. Returns False on timeout.
close ¶
close(timeout: float = 5.0) -> None
Stop the writer and wait up to timeout seconds for it to finish.
Events still unwritten afterwards are counted as dropped. Safe to call more than once.
verify ¶
verify(expect_head: str | None = None) -> VerifyReport
Verify the stored chain; see verify_records for expect_head.
records ¶
records() -> Iterator[dict[str, Any]]
Yield the stored records, skipping lines that failed to parse.
AuditStats
dataclass
¶
Counters for the audit writer. Latencies are in milliseconds.
to_dict ¶
to_dict() -> dict[str, Any]
Return the counters as a dict, with latencies rounded to 4 decimals.
open_backend ¶
open_backend(
spec: str | PathLike[str], *, fsync: bool = False
) -> Backend
memory, sqlite:<path>, a path ending in .db/.sqlite, or a JSONL path.
record_hash ¶
record_hash(record: dict[str, Any]) -> str
Return the sha256 hex digest of the canonical JSON of record's hashed fields.
seal ¶
seal(
seq: int, ts: str, kind: str, data: Any, prev: str
) -> dict[str, Any]
Build a record of type kind linked to prev and stamp its hash.
verify_records ¶
verify_records(
entries: Iterable[Entry],
*,
expect_head: str | None = None,
) -> VerifyReport
Recompute the chain and stop at the first broken link.
read ¶
read(spec: str | PathLike[str]) -> Iterator[dict[str, Any]]
Yield the records stored at spec, skipping lines that failed to parse.
verify ¶
verify(
spec: str | PathLike[str],
expect_head: str | None = None,
) -> VerifyReport
Verify the chain stored at spec (a JSONL path, sqlite:<path> or .db path).
aeon.chaos¶
aeon.chaos ¶
Controlled fault injection for agents: fault catalog, blast radius and campaigns.
Campaign
dataclass
¶
One chaos experiment: a hypothesis, the fault that tests it and what to expect.
Time fields are in steps; probability and the *_rate fields are fractions in [0, 1].
from_mapping
classmethod
¶
from_mapping(
d: Mapping[str, Any], source: str | None = None
) -> Campaign
Build a campaign from a parsed TOML-style mapping.
The fault entry is a name or a table with name, params, probability and
start_step; expected holds the success criteria.
Raises:
| Type | Description |
|---|---|
ValueError
|
The mapping has an unknown key, fault or scenario, or an invalid value. |
load
classmethod
¶
load(path: str | PathLike[str]) -> Campaign
Load a campaign from a TOML file at path.
BlastRadius ¶
Bases: IntEnum
Where a fault may run, from least to most exposed.
BlastRadiusExceeded ¶
Bases: AeonError
A fault was asked to run above its declared radius or the configured ceiling.
Fault
dataclass
¶
Base class. Subclasses override before (delay or raise) and/or after.
Injector
dataclass
¶
Applies one fault to calls, with probability fault.probability, from a seeded RNG.
active can be switched off and on to start the fault mid-run.
wrap ¶
wrap(executor: F) -> F
Wrap executor (sync or async) so the fault applies to its calls while active.
RateLimited ¶
Bases: RuntimeError
Raised by the rate-limit fault. status mirrors HTTP 429.
ToolTimeout ¶
Bases: TimeoutError
Raised by the tool-timeout fault.
list_results ¶
list_results(
root: Path | None = None,
) -> list[dict[str, Any]]
Return a summary of the latest result of every campaign that has one.
load_result ¶
load_result(
campaign_id: str, root: Path | None = None
) -> dict[str, Any]
Load the latest result of campaign_id, or the result file if given a .json path.
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
No result exists for the campaign. |
render_markdown ¶
render_markdown(doc: Mapping[str, Any]) -> str
Render a campaign result doc as a Markdown report.
run_campaign ¶
run_campaign(
c: Campaign,
*,
ceiling: str = "staging",
progress: Callable[[str, int, int], None] | None = None,
keep_traces: bool = False,
) -> dict[str, Any]
Run fault and control runs and return the result document.
save_result ¶
save_result(
doc: Mapping[str, Any], root: Path | None = None
) -> Path
Write doc as a timestamped result and as latest.json; return the timestamped path.
wilson ¶
wilson(
k: int, n: int, z: float = 1.96
) -> tuple[float, float]
95% Wilson score interval for k successes out of n.
check_radius ¶
check_radius(
fault: Fault,
requested: BlastRadius | str,
*,
ceiling: BlastRadius | str = BlastRadius.STAGING,
gate_mode: str | None = None,
) -> BlastRadius
Raise :class:BlastRadiusExceeded unless fault may run at requested.
inject ¶
inject(
executor: F,
fault: Fault | str,
*,
seed: int | None = None,
blast_radius: BlastRadius | str = BlastRadius.DEV,
ceiling: BlastRadius | str = BlastRadius.STAGING,
gate_mode: str | None = None,
**params: Any,
) -> F
Wrap executor with fault after checking the blast radius.
Wrap the tool first, then enforce: enforce(inject(tool, "gateway-latency")), so the
gate observes the faulty behaviour.
make ¶
make(name: str, /, **params: Any) -> Fault
Instantiate the fault called name (or its alias) with params.
Raises:
| Type | Description |
|---|---|
KeyError
|
No fault has that name or alias. |
ValueError
|
|
resolve ¶
resolve(name: str) -> type[Fault] | None
Find a fault by name or alias (case-insensitive).
aeon.adapters¶
aeon.adapters ¶
Adapters that put the gate in front of the tools of common agent frameworks.
Import the module for your stack (aeon.adapters.openai, .anthropic,
.langgraph) or use :class:ToolBox for plain Python tools. No SDK is imported here.
GuardedTool ¶
A thin proxy over a tool object. Unknown attributes are delegated to the original.
invoke ¶
invoke(
input: Any, config: Any = None, **kwargs: Any
) -> Any
Call the wrapped tool's invoke after the gate has allowed the call.
Raises:
| Type | Description |
|---|---|
AttributeError
|
The wrapped tool has no |
ainvoke
async
¶
ainvoke(
input: Any, config: Any = None, **kwargs: Any
) -> Any
Call the wrapped tool's ainvoke after the gate has allowed the call.
Raises:
| Type | Description |
|---|---|
AttributeError
|
The wrapped tool has no |
ToolBox ¶
A registry of Python tools. Every call goes through the gate first.
box = ToolBox(gate=my_gate) @box.tool ... def read_file(path: str) -> str: ... box.call("read_file", {"path": "notes.txt"})
tools
property
¶
tools: Mapping[str, Callable[..., Any]]
Return a copy of the registered tools by name.
add ¶
add(name: str, fn: Callable[..., Any]) -> None
Register fn under name, replacing any earlier tool of that name.
call ¶
call(
name: str, args: Mapping[str, Any] | None = None
) -> Any
Run a tool through the gate. A denied call raises :class:ActionBlocked.
acall
async
¶
acall(
name: str, args: Mapping[str, Any] | None = None
) -> Any
Async variant of :meth:call. Sync tools are called directly, async ones awaited.
as_executor ¶
as_executor() -> Callable[[str, Mapping[str, Any]], Any]
(tool, args) -> result, for code that already takes an executor.
safe_call ¶
safe_call(
name: str, args: Mapping[str, Any] | None = None
) -> str
Like :meth:call but returns text for the model instead of raising.
run_text ¶
run_text(
name: str, args: Mapping[str, Any] | None = None
) -> tuple[str, bool]
Run a tool and return (text, is_error). Never raises for tool or gate errors.
guard_tools ¶
guard_tools(
tools: Sequence[Any],
gate: Gate | None = None,
agent: str = "default",
) -> list[Any]
Wrap each tool so invoking it is checked by the gate first.
Tool objects (name plus invoke/ainvoke) become :class:GuardedTool
proxies, except pydantic tools such as LangChain's BaseTool: those are copied with
guarded invoke/ainvoke so isinstance checks and ToolNode keep working.
Plain callables are wrapped with enforce and keep their own name. A denied call
raises :class:aeon.axioms.ActionBlocked.
aeon.agents¶
aeon.agents ¶
Build and run LLM agents with every tool call behind the gate.
:class:Agent is a model, plain functions as tools, and instructions, with sessions and
user memory (:class:SqliteDb), structured output, step events and human approval.
:class:Team delegates to member agents and :class:Workflow runs steps in order. The
clients reach a provider over HTTP with the standard library only; the official SDK
clients work too. No SDK is imported here.
AnthropicClient ¶
Client for the Anthropic Messages API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
str | None
|
Defaults to |
None
|
base_url
|
str
|
The API root. |
'https://api.anthropic.com'
|
version
|
str
|
Value of the |
'2023-06-01'
|
timeout
|
float
|
Seconds per request. |
DEFAULT_TIMEOUT
|
headers
|
Mapping[str, str] | None
|
Extra headers. Gateways that serve the Messages API with bearer auth,
such as OpenRouter ( |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
When no API key is given or set in the environment. |
OpenAICompatible ¶
Client for any Chat Completions endpoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_url
|
str
|
The API root, for example |
'https://api.openai.com/v1'
|
api_key
|
str | None
|
Bearer token. Defaults to |
None
|
timeout
|
float
|
Seconds per request. |
DEFAULT_TIMEOUT
|
headers
|
Mapping[str, str] | None
|
Extra headers, for example OpenRouter's |
None
|
Example
client = OpenAICompatible("http://localhost:11434/v1") # doctest: +SKIP client.chat.completions.create(model="qwen2.5:3b", messages=[...]) # doctest: +SKIP
openrouter
classmethod
¶
openrouter(
api_key: str | None = None,
*,
timeout: float = DEFAULT_TIMEOUT,
) -> OpenAICompatible
A client for OpenRouter. The key defaults to $OPENROUTER_API_KEY.
Raises:
| Type | Description |
|---|---|
ValueError
|
When no API key is given or set in the environment. |
ProviderError ¶
Bases: RuntimeError
The provider answered with an error, or could not be reached.
Attributes:
| Name | Type | Description |
|---|---|---|
status |
HTTP status code, or |
|
body |
The start of the response body, for diagnosis. Never holds the API key. |
Agent ¶
A model with tools behind the gate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
str | Model
|
|
required |
tools
|
Sequence[Callable[..., Any]] | ToolBox
|
Plain functions (their signature and docstring become the tool spec), or
a :class: |
()
|
name
|
str
|
The agent's name in the gate, the audit log and the session store. |
'agent'
|
role
|
str | None
|
One line on what the agent does, used when it is a team member. |
None
|
instructions
|
str | Sequence[str] | None
|
System instructions, a string or a list of strings. |
None
|
gate
|
Gate | None
|
The gate for the tools. Defaults to the process default gate. |
None
|
client
|
Any
|
An SDK or HTTP client, instead of building one from |
None
|
db
|
SqliteDb | None
|
A :class: |
None
|
session_id
|
str | None
|
Default session for :meth: |
None
|
user_id
|
str | None
|
Default user for :meth: |
None
|
add_history_to_context
|
bool
|
Prepend earlier turns of the session. |
False
|
num_history_runs
|
int
|
How many earlier turns. |
3
|
enable_agentic_memory
|
bool
|
Give the model an |
False
|
add_datetime_to_context
|
bool
|
Put the current UTC time in the instructions. |
False
|
output_schema
|
Any
|
A dataclass, Pydantic model or JSON schema dict for the answer. |
None
|
approval
|
Approval
|
For a tool behind |
'pause'
|
max_steps
|
int
|
Maximum model calls per run. |
10
|
max_tokens
|
int | None
|
Output cap per model call (Messages API default: 1024). |
None
|
request
|
Mapping[str, Any] | None
|
Extra fields for every model request, for example |
None
|
debug
|
bool
|
Print every step to stderr. Also on with |
False
|
Example
agent = Agent("openrouter:openai/gpt-4o-mini", tools=[read_file]) # doctest: +SKIP agent.print_response("Summarise notes.txt") # doctest: +SKIP
run ¶
run(
input: str | Sequence[Any],
*,
stream: bool = False,
session_id: str | None = None,
user_id: str | None = None,
) -> Any
Run the loop for one input.
Returns a :class:RunOutput, or with stream=True an iterator of
:class:Event whose last item carries the run in event.run.
continue_run ¶
continue_run(
run: RunOutput,
approve: bool | Mapping[str, bool] = True,
*,
stream: bool = False,
) -> Any
Resume a paused run with the human's answer for each pending tool call.
approve is one answer for all pending calls, or {tool_name: bool}.
print_response ¶
print_response(
input: str | Sequence[Any], **kwargs: Any
) -> RunOutput
Run and print each tool call with its verdict, then the answer. For development.
cli_app ¶
cli_app(
*,
session_id: str | None = None,
user_id: str | None = None,
) -> None
A terminal chat with the agent. Approvals are asked at the prompt; exit quits.
Event
dataclass
¶
One step of a run. run is set on the terminal and paused events.
RunEvent ¶
Bases: str, Enum
The steps of a run, in the order they happen.
RunOutput
dataclass
¶
The outcome of one run.
Attributes:
| Name | Type | Description |
|---|---|---|
content |
Any
|
The answer: text, or the parsed object when |
text |
str | None
|
The model's final text, unparsed. |
status |
Status
|
|
stop_reason |
StopReason
|
Why the loop ended. |
pending |
list[ToolCall]
|
Tool calls waiting for approval when the run is paused. |
ToolCall
dataclass
¶
One tool call the model asked for, and what happened to it.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Tool name as the model sent it. |
args |
dict[str, Any]
|
Decoded arguments (empty when they could not be decoded). |
result |
str
|
The text returned to the model (empty while approval is pending). |
is_error |
bool
|
The call failed, was blocked, denied, or had bad arguments. |
blocked |
bool
|
The gate (or the human) denied the call. |
approval_required |
bool
|
A LIMIT rule asked for human approval. |
approved |
bool | None
|
The human's answer, once given. |
call_id |
str | None
|
The provider's id for the call. |
Model
dataclass
¶
A model id with the client that serves it.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
The provider's model id, for example |
client |
Any
|
An object with |
wire |
Wire
|
|
provider |
str | None
|
The provider name, when the model came from a string. |
SqliteDb ¶
A SQLite file for agent sessions and user memory. Safe to share across threads.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
db_file
|
str | Path
|
Path of the database file; parent directories are created. |
required |
add_run ¶
add_run(
*,
run_id: str,
session_id: str,
agent: str,
user_id: str | None,
input: str,
output: str | None,
status: str,
tokens: int,
) -> None
Record one finished run of a session.
get_runs ¶
get_runs(
session_id: str, limit: int | None = None
) -> list[dict[str, Any]]
The runs of a session, oldest first; limit keeps only the latest ones.
sessions ¶
sessions(agent: str | None = None) -> list[str]
Session ids, most recent first, optionally for one agent.
clear_memories ¶
clear_memories(user_id: str) -> int
Delete every fact about a user. Returns how many were deleted.
Team ¶
A coordinator model and the member agents it can hand tasks to.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
members
|
Sequence[Agent]
|
The member agents. Their |
required |
model
|
str | Model
|
The coordinator's model, as for :class: |
required |
name
|
str
|
The team's name (the coordinator's agent name in the gate). |
'team'
|
instructions
|
str | Sequence[str] | None
|
How the coordinator should work, for example "hear both sides, then synthesize a recommendation". |
None
|
gate
|
Gate | None
|
The gate for delegation calls. |
None
|
**agent_options
|
Any
|
Passed to the coordinator :class: |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
No members, or two members with the same name. |
run ¶
run(input: str | Sequence[Any], **kwargs: Any) -> Any
Run the coordinator; see :meth:Agent.run.
continue_run ¶
continue_run(
run: RunOutput,
approve: bool | Mapping[str, bool] = True,
) -> Any
Resume a paused coordinator run; see :meth:Agent.continue_run.
print_response ¶
print_response(
input: str | Sequence[Any], **kwargs: Any
) -> RunOutput
Run and print the delegations and the final answer.
Step
dataclass
¶
One step. Give exactly one of agent, team or function.
StepOutput
dataclass
¶
What one step produced.
Workflow ¶
Steps over agents, teams and functions, run in order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
steps
|
Sequence[Step]
|
The steps; names must be distinct. |
required |
name
|
str
|
The workflow's name. |
'workflow'
|
Raises:
| Type | Description |
|---|---|
ValueError
|
No steps, or duplicate step names. |
WorkflowOutput
dataclass
¶
The outcome of a workflow run.
Attributes:
| Name | Type | Description |
|---|---|---|
content |
Any
|
The last completed step's output. |
status |
Literal['completed', 'stopped']
|
|
stopped_at |
str | None
|
The name of the step that stopped the workflow. |
resolve_model ¶
resolve_model(
model: str | Model,
client: Any = None,
*,
base_url: str | None = None,
) -> Model
Turn "provider:model" (or a model id plus a client) into a :class:Model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
str | Model
|
|
required |
client
|
Any
|
An SDK or HTTP client to use instead of building one. |
None
|
base_url
|
str | None
|
Overrides the provider's URL (required for |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
Unknown provider, no API key in the environment, or no base URL. |
aeon.config¶
aeon.config ¶
Configuration from aeon.toml or [tool.aeon] in pyproject.toml.
AEON_* environment variables take precedence. New installs default to shadow mode.
Config
dataclass
¶
Resolved Aeon settings. root is the directory relative paths resolve against.
ConfigError ¶
Bases: ValueError
The configuration file or an AEON_* variable is invalid.
find_config ¶
find_config(start: Path | None = None) -> Path | None
Locate the config file, or return None if there is none.
Uses AEON_CONFIG if set. Otherwise walks up from start (default: the working
directory) to the repository root, looking for aeon.toml, .aeon.toml or a
pyproject.toml with a [tool.aeon] table.
load_config ¶
load_config(path: Path | None = None) -> Config
Load config from path (or discover it), then apply AEON_* overrides.
load_axiom_file ¶
load_axiom_file(
path: str | PathLike[str],
) -> list[AxiomSpec]
Import a Python file and return the axioms it declares, without registering them.
build_gate ¶
build_gate(
cfg: Config, *, axioms: AxiomRegistry | None = None
) -> Gate
Build a Gate from config: mode, audit log, budget monitor and axiom files.