Skip to content

Agent API

The client.agent namespace exposes multi-agent safety budgets and chain-of-oversight primitives.

SDK proxy

crp.sdk.proxies._AgentProxy

Multi-agent safety budget and chain proxy (SPEC-012).

Exposes the agent safety budget, event accounting, sub-agent linking, and quality aggregation.

budget()

Return the orchestrator's AgentSafetyBudget if present.

Returns:

Type Description
Any

AgentSafetyBudget instance.

account_event(risk_level)

Account a risk event against the agent safety budget.

Parameters:

Name Type Description Default
risk_level str

One of LOW, MEDIUM, HIGH, CRITICAL.

required

Returns:

Type Description
dict[str, Any]

Dict with budget, health, circuit_state, and

dict[str, Any]

halted status.

Link a sub-agent session into the orchestrator HMAC chain.

Parameters:

Name Type Description Default
parent_handle str

Parent session/window identifier.

required
child_handle str

Child session/window identifier.

required

Returns:

Type Description
str

HMAC link string.

aggregate(results)

Aggregate quality across sub-agent results.

Parameters:

Name Type Description Default
results list[Any]

Sub-agent response strings or result objects.

required

Returns:

Type Description
dict[str, Any]

Dict with coherence and completeness summaries.

Agent Safety Budget

crp.agent.budget.AgentSafetyBudget dataclass

Session-scoped safety budget (CRP-SPEC-012 §2).

The authoritative budget value lives in the signed session token; this object is the gateway-side accountant. Decrements are computed server-side only (anti-inflation, §10.1) and the budget never recovers within a session (§2.4).

Attributes:

Name Type Description
budget float

Current remaining safety budget, initialised to INITIAL_BUDGET.

decrements dict[RiskLevel, float]

Mapping from RiskLevel to the amount subtracted when a response at that risk level is delivered. Values are clamped to the interoperability ranges in DECREMENT_RANGES.

health property

Return the current BudgetHealth band.

circuit_state property

Return the current CircuitState.

peek()

Return the current decision without applying any decrement.

Returns:

Type Description
BudgetDecision

A BudgetDecision reflecting the present budget state.

account(risk_level, *, is_redispatch=False)

Decrement the budget for a delivered response's risk level (§2.2).

Re-dispatches do not decrement (§2.5) - only the final delivered response counts.

Parameters:

Name Type Description Default
risk_level RiskLevel | None

DPE risk level of the delivered response, or None if the response carries no risk classification.

required
is_redispatch bool

When True, the event is a re-dispatch and must not decrement the budget.

False

Returns:

Type Description
BudgetDecision

The resulting BudgetDecision after accounting for the event.

merge_downstream(sub_agent_budget)

Fan-in merge: orchestrator budget = min of self and sub-agent (§5.3).

Parameters:

Name Type Description Default
sub_agent_budget float

Remaining safety budget reported by a sub-agent.

required

Returns:

Type Description
BudgetDecision

The resulting BudgetDecision after merging budgets.