Hmbown/CodeWhale · error
Dynamic tool settlement task ended before acknowledgement
Error message
Dynamic tool settlement task ended before acknowledgement
What it means
The oneshot receiver in `await_dynamic_tool_settlement` resolves with `Err(_)` when the sender half was dropped without sending — meaning the dynamic-tool settlement task terminated (panic, early return, abort) before acknowledging. The runtime surfaces this as a distinct error so callers know settlement outcome is unknown, not merely failed.
Solutions
- Inspect logs for a panic or early return in the dynamic-tool settlement task.
- Ensure every exit path of the settlement task sends the ack (or an explicit error) before dropping.
- Retry the operation if shutdown caused the task cancellation; otherwise report it as a runtime bug.
- Add coverage so the settlement task is not silently dropped on cancel.
Example fix
// before
let ack = match tool_settles(tool_id).await {
Ok(a) => a,
Err(_) => return, // drops sender -> 'ended before acknowledgement'
};
tx.send(ack).ok();
// after
let ack = tool_settles(tool_id).await
.unwrap_or_else(|e| DynamicToolSettlementAck::failed(e.to_string()));
let _ = tx.send(ack); Defensive patterns
Strategy: retry
Try / catch
match runtime.await_dynamic_tool_settlement(rx).await {
Err(e) if e.to_string().contains("ended before acknowledgement") => {
warn!("settlement task died; retrying once");
retry_settlement(tool_id).await?;
}
other => other?,
} Prevention
- Ensure every code path in the settlement task sends the oneshot ack before returning.
- Wrap the settlement body so panics still emit an error ack.
- Avoid dropping settlement tasks during shutdown without reconciling their receipts.
When it happens
Trigger: The settlement task is dropped/panics/aborts before calling the oneshot sender; task spawned for settlement is cancelled during shutdown; sender's `send` never invoked on an early-exit code path.
Common situations: Runtime shutdown cancelling spawned settlement tasks; a panic inside the settlement worker; a bug where one branch returns without sending the ack.
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/81feb0bd9370f04d.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/runtime_threads.rs:7181
Err(format!(
"Dynamic tool settlement task panicked: {}",
panic_payload_message(&*payload)
))
}
};
let _ = ack_tx.send(result);
});
self.track_receipt_worker(worker);
ack_rx
}
async fn await_dynamic_tool_settlement(
ack: oneshot::Receiver<std::result::Result<DynamicToolSettlementAck, String>>,
) -> Result<DynamicToolSettlementAck> {
match ack.await {
Ok(Ok(ack)) => Ok(ack),
Ok(Err(error)) => bail!("{error}"),
Err(_) => bail!("Dynamic tool settlement task ended before acknowledgement"),
}
}
async fn settle_dynamic_tool_timeout(
&self,
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,View on GitHub (pinned to 73e0f67d83)