interplane.Get Omega
Read in your language

aegis-runtime-mv

Native Rust agent runtime: Axum WebSocket/SSE/REST gateway, heartbeat scheduler, dependency-aware task workflow, SQLite storage. Attachment of AienOS. Pre-alpha.

Brought by drakestapleton

branch main Branches Tags History

aegis-runtime-mv / docs / FAILURE-PROVENANCE.md

67 lines · 4707 bytes Raw Blame History Source

Failure provenance and retry classification (issue #38)

Code: src/failure.rs (all public types), wired in src/agent.rs, src/skills.rs (dispatch_classified) and src/events/event.rs (AegisEvent::StepFailed).

AEGIS is out of release v1. Nothing here is wired into a release path.

Vocabulary

FailureClass: Rejected, Unavailable, Timeout, Cancelled, Uncertain, Failed, Malformed, ApprovalPending. EffectCertainty: NoEffect, Uncertain, EffectOccurred. RetryEligibility: Retryable { max_attempts } or NotRetryable. Derived by the pure function retry_eligibility(class, certainty, idempotent, policy). It is never stored and never grants anything.

Upstream mapping: aien-mcp Rejected is Rejected + NoEffect; Uncertain is Uncertain; Finished has no failure record.

Retry rule

An automatic retry happens only when all hold: class is Unavailable (never Rejected: a policy or gate denial is not retried), certainty is NoEffect, the skill is on the idempotent list (skill_effect_profile), and RetryPolicy.max_attempts is above 1 (default 1, ceiling 5). Every attempt is a new dispatch through the gated path (probe gate, allowlist, handler). Timeout, Cancelled, Uncertain, Failed, Malformed and ApprovalPending are never retried. ApprovalPending also stops the run: the later calls of that turn are not run and the model is not asked again.

State and error mapping

Existing siteSignal todayFailureClassEffectCertainty
enforcement::probe_gate refusal (skills.rs gated path)Err stringRejectedNoEffect
enforcement::pre_dispatch_check: not on allowlist, empty name, non-object args, bad shell commandErr stringRejectedNoEffect
Skill name not in registry"not found in registry"RejectedNoEffect
Handler error starting with "Unavailable" (cortex, telemetry stubs)Err stringUnavailableNoEffect
Handler error, idempotent skill (read_file, list_dir, git_status)Err stringFailedNoEffect
Handler error, mutating skill (write_file, bash_eval)Err stringFailedEffectOccurred (conservative)
Per-call deadline (FailurePolicy.tool_timeout), idempotent skillnewTimeoutNoEffect
Per-call deadline, mutating skillnewTimeoutUncertain
CancelToken set before dispatchnewCancelledNoEffect
CancelToken set while running, idempotent / mutatingnewCancelledNoEffect / Uncertain
Custom ToolDispatcher reports lost responseToolFaultUncertainUncertain
Custom ToolDispatcher reports unparsable resultToolFaultMalformedas reported
Custom ToolDispatcher reports human approval neededToolFaultApprovalPendingas reported
ExecutionAuthority::authorize Err (broker seam, not used by execute_task today)Err stringUnavailableNoEffect
DoctrineDecision deny at the brokerdecisionRejectedNoEffect
ActionStatus::Denied / FailedstatusRejected / FailedNoEffect / as recorded
RunState::Failed / Cancelled / WaitingForApprovalstatederived from last record / Cancelled / ApprovalPendingfrom last record
Inference endpoint unreachable (execute_task returns Err)Errnot classified (out of scope, engine error semantics unchanged)n/a
Model tool arguments that are not valid JSONwrapped as {"raw": ...}unchangedn/a

Rows marked broker, ActionStatus and RunState document how those states would map; this change does not alter those code paths. Only the agent tool-call rows are exercised by tests.

Record shape

FailureRecord: sequence (stable order, starts at 1 per run), run_id, step_index, tool_call_id, parent_call_id (the directly preceding failed call, a causal hint), tool_name, attempt, class, effect_certainty, created_at (call scheduled, ms), failed_at (ms), cause (max 8 entries, each message at most 512 bytes, payload stored only as a sha256 digest, argument strings echoed in messages replaced by [redacted]), cause_truncated.

Tool error text sent back to the model and stored in ToolExecutionRecord.output passes through the same redaction as the failure record. ToolExecutionRecord.arguments is unchanged and still holds the raw arguments (pre-existing behaviour, not part of this change).

ToolExecutionRecord.failure holds the terminal record; retry_failures holds earlier failed attempts. Both default to empty so older persisted JSON still loads. Every failed attempt is also published as AegisEvent::StepFailed on the EventBus when one is attached (AgentEngine::with_event_bus). root_cause(records, start) follows parent links to the original failure.