Hmbown/CodeWhale · error · anyhow::Error

failed to register sub-agent work: {err}

Error message

failed to register sub-agent work: {err}

What it means

Raised in the sub-agent lifecycle constructor: work.register_operation for the agent spawn operation failed, so no work-tracking entry exists for this sub-agent's run. The {err} explains the registry-side cause (closed channel, session shutdown, or duplicate operation id).

Source

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

        let external = format!("worker:{agent_id}");
        let lifecycle = Self {
            work,
            session_id,
            external,
        };
        lifecycle
            .work
            .register_operation(
                &lifecycle.session_id,
                OperationIntent::new(
                    lifecycle.external.clone(),
                    title,
                    true,
                    "agent",
                    format!("agent:{agent_id}:spawn"),
                ),
            )
            .map_err(|err| anyhow!("failed to register sub-agent work: {err}"))?;

        // 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}"
                ));
            }
        }

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Inspect the inner {err} for the work-registry failure cause
  2. Verify the parent session/work registry is still alive and accepting operations
  3. Retry spawning the agent after the registry issue is resolved
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at crates/tui/src/tools/subagent/mod.rs:2883 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/e9b9143dbb4ce593. Report an issue: GitHub.