Public declaration syntax from forge-rs/crates/forge-agent/src/error.rs Original source SHA-256: a14655daf1adde0a63aecf6d3b61545a56aa6a704bbe2315a506fcdffb7e0f69 Function bodies and constant values are omitted. This is not the complete implementation. Source line 35 #[derive(Debug, Error)] pub enum ForgeAgentError { /// The agent's tool loop failed during execution. /// /// This error indicates that a step within the agent's tool loop encountered /// an unrecoverable failure. The `step` field indicates which iteration /// failed, and `reason` explains what went wrong. /// /// See ANVIL Spec SS7.1 -- Agent Execution Loop. #[error("agent '{agent_name}' tool loop failed at step {step}: {reason}")] ToolLoopFailed { /// The name of the agent whose tool loop failed. agent_name: String, /// The step number (1-indexed) at which the failure occurred. step: u32, /// A human-readable description of what went wrong. reason: String, }, /// A workflow orchestration step failed. /// /// This error wraps failures that occur during sequential, parallel, or /// router workflow execution. It identifies which agent within the workflow /// caused the failure. /// /// See ANVIL Spec SS7.2 -- Agent Workflows. #[error("workflow '{workflow_name}' failed at agent '{agent_name}': {reason}")] WorkflowFailed { /// The name of the workflow that failed. workflow_name: String, /// The name of the agent within the workflow that caused the failure. agent_name: String, /// A human-readable description of the failure. reason: String, }, /// A sub-agent delegation failed. /// /// This error occurs when creating or executing a sub-agent that was /// delegated work from a parent agent. The parent-child relationship /// is captured in the error context. /// /// See ANVIL Spec SS11.2 -- Lineage Propagation. #[error( "sub-agent delegation failed: parent '{parent_name}' -> child '{child_name}': {reason}" )] SubAgentFailed { /// The parent agent that initiated the delegation. parent_name: String, /// The child agent that failed. child_name: String, /// A human-readable description of the failure. reason: String, }, /// A lifecycle state machine violation occurred. /// /// This error wraps [`forge_health::error::ForgeHealthError`] when an agent /// attempts an invalid lifecycle transition (e.g., running a terminated agent). /// /// See ANVIL Spec SS5.1 -- Lifecycle State Machine. #[error("lifecycle error in agent '{agent_name}': {reason}")] LifecycleError { /// The agent whose lifecycle is in an invalid state. agent_name: String, /// A human-readable explanation of the lifecycle violation. reason: String, }, /// An inter-agent messaging operation failed. /// /// This error occurs when sending or receiving messages between agents /// via agent channels. Common causes include channel closure and capacity /// exhaustion. #[error("agent messaging error: {reason}")] MessageError { /// A human-readable description of the messaging failure. reason: String, }, /// The agent's stop condition was reached. /// /// This is a structured termination, not a failure. The agent stopped /// because its configured stop condition (max steps, max tokens, or a /// custom predicate) was satisfied. /// /// See ANVIL Spec SS7.1 -- Agent Execution Loop, stop conditions. #[error("agent '{agent_name}' stopped: {reason} (steps={steps_taken}, tokens={tokens_used})")] StopConditionReached { /// The agent that was stopped. agent_name: String, /// Why the agent stopped. reason: String, /// Number of tool loop steps completed. steps_taken: u32, /// Total tokens consumed across all steps. tokens_used: u64, }, /// Tool invocation was denied by the authorization gate (ANVIL Spec SS8.7). /// /// This error occurs when a Host (Tier 2) tool is invoked but the agent's /// Arsenal ACT does not grant the required scope. Platform (Tier 1) and /// Embedded (Tier 3) tools are never denied. /// /// See ANVIL Spec SS8.7 -- Tool Authorization Gate. #[error("tool '{tool_name}' authorization denied for agent '{agent_did}': {reason}")] AuthorizationDenied { /// The DID of the agent that was denied. agent_did: String, /// The tool that was requested. tool_name: String, /// A human-readable explanation of the denial. reason: String, }, /// Coding-provider execution was denied by the active boundary contract. #[error("coding-provider execution denied for agent '{agent_name}' on provider '{provider_ref}': {reason}")] BoundaryContractDenied { /// The human-readable agent name. agent_name: String, /// The provider reference that was denied. provider_ref: String, /// Why the boundary contract denied the execution. reason: String, }, /// AEGIS-backed delegation or authority validation failed before provider execution. #[error("coding-provider delegation denied for agent '{agent_name}' on provider '{provider_ref}': {reason}")] DelegationDenied { /// The human-readable agent name. agent_name: String, /// The provider reference that was denied. provider_ref: String, /// Why the delegation or authority check failed. reason: String, }, /// The agent's ACT does not grant the provider scope required for execution. #[error("coding-provider scope denied for agent '{agent_name}' on provider '{provider_ref}': missing scope '{required_scope}' in ACT {act_id}")] CredentialScopeDenied { /// The human-readable agent name. agent_name: String, /// The provider reference being executed. provider_ref: String, /// The scope required by the provider execution preflight. required_scope: String, /// The ACT that was checked, or `[missing]` when no ACT was configured. act_id: String, }, /// Identity derivation failed during sub-agent creation. /// /// This error occurs when a parent agent attempts to derive a child agent /// identity, but the OAS key derivation or document construction fails. /// /// See ANVIL Spec SS11.2 -- Lineage Propagation. #[error("identity derivation failed for sub-agent '{child_name}' from parent '{parent_did}': {reason}")] IdentityDerivationFailed { /// The parent agent's OAS DID. parent_did: String, /// The child agent's intended name. child_name: String, /// A human-readable description of what went wrong. reason: String, }, /// A `forge-core` error occurred during agent execution. #[error("core error: {0}")] Core(#[from] forge_core::error::ForgeError), /// A `forge-generate` error occurred during inference. #[error("generation error: {0}")] Generate(#[from] forge_generate::ForgeGenerateError), /// A `forge-tool` error occurred during tool execution. #[error("tool error: {0}")] Tool(#[from] forge_tool::error::ForgeToolError), /// A `forge-health` error occurred during lifecycle management. #[error("health error: {0}")] Health(#[from] forge_health::error::ForgeHealthError), /// A `forge-identity` error occurred during identity operations. #[error("identity error: {0}")] Identity(#[from] forge_identity::error::ForgeIdentityError), /// A `forge-auth` error occurred during authorization operations. #[error("auth error: {0}")] Auth(#[from] forge_auth::error::ForgeAuthError), } Source line 227 pub type ForgeAgentResult = Result;