Hmbown/CodeWhale · error

Turn has an indeterminate dynamic-tool receipt; refusing to…

Error message

Turn {turn_id} has an indeterminate dynamic-tool receipt; refusing to publish turn completion

What it means

Before publishing turn completion, the runtime claims or watches pending dynamic tools for the turn. If any receipt is in an indeterminate state (outcome neither confirmed success nor confirmed failure — e.g., settlement outcome was lost or ambiguous), publishing completion would falsely report the turn's tool results, so it refuses with this error and the loop retries/wait instead.

Solutions

  1. Resolve the indeterminate receipt: re-run settlement for the affected tool or force an explicit success/failure outcome.
  2. Check the receipt store for the tool claim and reconcile it against the settlement task logs.
  3. Do not bypass the guard — publishing completion with unknown tool outcomes corrupts the turn record.
  4. If caused by a crash, replay the tool or mark it failed explicitly before completing the turn.

Example fix

// before
// turn completion attempted with an unresolved receipt
runtime.complete_turn(thread_id, turn_id).await?;
// after
runtime.reconcile_dynamic_tool_receipt(turn_id, tool_claim_id).await?; // force explicit outcome
runtime.complete_turn(thread_id, turn_id).await?;
Defensive patterns

Strategy: validation

Validate before calling

let (_, _, indeterminate) = runtime.claim_or_watch_pending_dynamic_tools_for_turn(thread_id, turn_id);
if indeterminate {
    anyhow::bail!("resolve indeterminate receipts before completing turn {}", turn_id);
}

Try / catch

match runtime.complete_turn(thread_id, turn_id).await {
    Err(e) if e.to_string().contains("indeterminate dynamic-tool receipt") => {
        reconcile_receipts(turn_id).await?;
        runtime.complete_turn(thread_id, turn_id).await?;
    }
    other => other,
}

Prevention

When it happens

Trigger: Completing a turn while `claim_or_watch_pending_dynamic_tools_for_turn` reports `indeterminate == true` — a dynamic-tool receipt whose settled outcome cannot be determined.

Common situations: A settlement ack was lost (sender dropped) or persisted in a partial state; crash/restart mid-settlement leaves a receipt ambiguous; concurrent writers to the same tool receipt.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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

Appendix: source

Thrown at crates/tui/src/runtime_threads.rs:7205

        claim: ClaimedDynamicToolSettlement,
        timeout: Duration,
    ) -> Result<()> {
        let ack = self
            .spawn_dynamic_tool_settlement(claim, DynamicToolTerminalOutcome::Timeout { timeout });
        Self::await_dynamic_tool_settlement(ack).await?;
        Ok(())
    }

    async fn settle_dynamic_tools_for_terminal_turn(
        &self,
        thread_id: &str,
        turn_id: &str,
    ) -> Result<()> {
        loop {
            let (claims, mut settling, indeterminate) =
                self.claim_or_watch_pending_dynamic_tools_for_turn(thread_id, turn_id);
            if indeterminate {
                bail!(
                    "Turn {turn_id} has an indeterminate dynamic-tool receipt; refusing to publish turn completion"
                );
            }
            if claims.is_empty() && settling.is_empty() {
                return Ok(());
            }

            let mut first_error = None;
            for claim in claims {
                let ack = self.spawn_dynamic_tool_settlement(
                    claim,
                    DynamicToolTerminalOutcome::Canceled {
                        reason: "turn_terminal",
                        terminal: true,
                    },
                );
                if let Err(error) = Self::await_dynamic_tool_settlement(ack).await
                    && first_error.is_none()

View on GitHub (pinned to 73e0f67d83)