{"record":{"id":"e7d57e23ece75ad7","repo":"Hmbown/CodeWhale","slug":"turn-turn-id-has-an-indeterminate-dynamic-tool-r","errorCode":null,"errorMessage":"Turn {turn_id} has an indeterminate dynamic-tool receipt; refusing to publish turn completion","messagePattern":"Turn (.+?) has an indeterminate dynamic-tool receipt; refusing to publish turn completion","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/runtime_threads.rs","lineNumber":7205,"sourceCode":"        claim: ClaimedDynamicToolSettlement,\n        timeout: Duration,\n    ) -> Result<()> {\n        let ack = self\n            .spawn_dynamic_tool_settlement(claim, DynamicToolTerminalOutcome::Timeout { timeout });\n        Self::await_dynamic_tool_settlement(ack).await?;\n        Ok(())\n    }\n\n    async fn settle_dynamic_tools_for_terminal_turn(\n        &self,\n        thread_id: &str,\n        turn_id: &str,\n    ) -> Result<()> {\n        loop {\n            let (claims, mut settling, indeterminate) =\n                self.claim_or_watch_pending_dynamic_tools_for_turn(thread_id, turn_id);\n            if indeterminate {\n                bail!(\n                    \"Turn {turn_id} has an indeterminate dynamic-tool receipt; refusing to publish turn completion\"\n                );\n            }\n            if claims.is_empty() && settling.is_empty() {\n                return Ok(());\n            }\n\n            let mut first_error = None;\n            for claim in claims {\n                let ack = self.spawn_dynamic_tool_settlement(\n                    claim,\n                    DynamicToolTerminalOutcome::Canceled {\n                        reason: \"turn_terminal\",\n                        terminal: true,\n                    },\n                );\n                if let Err(error) = Self::await_dynamic_tool_settlement(ack).await\n                    && first_error.is_none()","sourceCodeStart":7187,"sourceCodeEnd":7223,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/runtime_threads.rs#L7187-L7223","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Resolve the indeterminate receipt: re-run settlement for the affected tool or force an explicit success/failure outcome.","Check the receipt store for the tool claim and reconcile it against the settlement task logs.","Do not bypass the guard — publishing completion with unknown tool outcomes corrupts the turn record.","If caused by a crash, replay the tool or mark it failed explicitly before completing the turn."],"exampleFix":"// before\n// turn completion attempted with an unresolved receipt\nruntime.complete_turn(thread_id, turn_id).await?;\n// after\nruntime.reconcile_dynamic_tool_receipt(turn_id, tool_claim_id).await?; // force explicit outcome\nruntime.complete_turn(thread_id, turn_id).await?;","handlingStrategy":"validation","validationCode":"let (_, _, indeterminate) = runtime.claim_or_watch_pending_dynamic_tools_for_turn(thread_id, turn_id);\nif indeterminate {\n    anyhow::bail!(\"resolve indeterminate receipts before completing turn {}\", turn_id);\n}","typeGuard":null,"tryCatchPattern":"match runtime.complete_turn(thread_id, turn_id).await {\n    Err(e) if e.to_string().contains(\"indeterminate dynamic-tool receipt\") => {\n        reconcile_receipts(turn_id).await?;\n        runtime.complete_turn(thread_id, turn_id).await?;\n    }\n    other => other,\n}","preventionTips":["Force an explicit success/failure outcome on every dynamic-tool receipt before turn end.","Persist settlement outcomes atomically so a crash cannot leave them ambiguous.","Never bypass this guard — completing with unknown tool outcomes corrupts the record."],"tags":["dynamic-tools","turn-lifecycle","indeterminate-state"],"backgroundTag":"internal-invariant-violation","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}