Hmbown/CodeWhale · error

failed to record sub-agent verification approval

Error message

failed to record sub-agent verification approval: {err}

What it means

After a sub-agent run completes, its verification approval must be recorded under the reference `agent:{agent_id}:approval` in the lifecycle journal; failure triggers reconciliation to OwnerState::Failed and this error wrapping the underlying cause. The message deliberately embeds the inner error ({err}) because an unrecorded approval means the sub-agent's success cannot be trusted downstream.

Solutions

  1. Inspect the wrapped {err} in the message — it names the real underlying failure (IO, storage, format)
  2. Retry the sub-agent run after fixing the state store (disk space, permissions, file lock)
  3. Verify the session journal/state files are not corrupted or from an incompatible version
  4. Ensure the approval record API is called before the parent turn finishes settling, and handle its Result explicitly

Example fix

// before: ignore record failure, agent looks approved
let _ = record_approval(&lifecycle.external, &reference, "agent", &key);
// after: fail loudly and reconcile (as the tool does)
if let Err(err) = record_approval(&lifecycle.external, &reference, "agent", &key) {
    let _ = lifecycle.reconcile_state(OwnerState::Failed, 1, None);
    return Err(anyhow!("failed to record sub-agent verification approval: {err}"));
}
Defensive patterns

Strategy: try-catch

Validate before calling

// preflight the state store before recording
if !lifecycle.store_writable() {
    return Err(anyhow!("lifecycle store not writable; approval cannot be recorded"));
}

Try / catch

if let Err(err) = record_approval(&lifecycle.external, &reference, "agent", &key) {
    let _ = lifecycle.reconcile_state(OwnerState::Failed, 1, None);
    return Err(anyhow!("failed to record sub-agent verification approval: {err}"));
}
// caller: inspect inner err for IO/permission/corruption fixes

Prevention

When it happens

Trigger: Calling the sub-agent completion path when the approval-record function errors — e.g. the lifecycle journal/state store is unavailable, the reference is rejected, or the underlying record API returns an error while lifecycle.external/reference are being persisted.

Common situations: Disk-full or permission problems writing lifecycle state; a corrupted or locked session journal; schema changes to the approval record format after an upgrade; concurrent settlement closing the record mid-write.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/bf9a04673654edd2. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/tools/subagent/mod.rs:3178

                error = %err,
                "sub-agent work-graph registration skipped; spawning unbound"
            );
            return Ok(None);
        }

        // A root Operate verification lease is provenance, not delegated
        // authority. Nested workers cannot inherit this bit.
        if runtime.accept_verification && runtime.spawn_depth == 1 {
            let reference = format!("operate-verification:{agent_id}");
            if let Err(err) = lifecycle.work.record_operation_approval(
                &lifecycle.session_id,
                &lifecycle.external,
                &reference,
                "agent",
                &format!("agent:{agent_id}:approval"),
            ) {
                let _ = lifecycle.reconcile_state(OwnerState::Failed, 1, None);
                return Err(anyhow!(
                    "failed to record sub-agent verification approval: {err}"
                ));
            }
        }
        Ok(Some(lifecycle))
    }

    fn reconcile_record(&self, record: &AgentWorkerRecord) -> Result<bool, String> {
        let Some(snapshot) = agent_worker_owner_snapshot(record) else {
            return Ok(false);
        };
        self.work.reconcile_operation(&self.session_id, snapshot)
    }

    fn reconcile_state(
        &self,
        state: OwnerState,
        seq: u64,

View on GitHub (pinned to 73e0f67d83)