From 0caa57d8b701e35cb695bfd45016c3dff4d0c1e7 Mon Sep 17 00:00:00 2001 From: nesquena-hermes Date: Thu, 25 Jun 2026 19:23:31 +0000 Subject: [PATCH] fix(#4927): cover the Anthropic tool_use derived push with the persisted fallback Codex gate: the third derived-push site (Anthropic tool_use content-array branch, ui.js) still read resultsByTid[tid]||'' without the persisted fallback, so Anthropic-format sessions could still cold-reload with an empty tool body. Add the persistedSnippetByTid fallback there too; now all derived result-snippet reads (OpenAI top-level, Anthropic tool_use, partial) chain to the durable persisted snippet. Added a guard test asserting EVERY derived resultSnippet read includes the fallback. --- static/ui.js | 2 +- tests/test_issue4927_durable_tool_snippet.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/static/ui.js b/static/ui.js index 0f6d3274..58635ada 100644 --- a/static/ui.js +++ b/static/ui.js @@ -11935,7 +11935,7 @@ function renderMessages(options){ const args=p.input||{}; const tid=p.id||''; const patchSnippet=_cliPatchSnippetFromArgs(name,args); - const resultSnippet=resultsByTid[tid]||''; + const resultSnippet=resultsByTid[tid]||persistedSnippetByTid[tid]||''; const argsSnap=_toolArgsSnapshot(args); derived.push(copyLiveToolMetadata({ name, diff --git a/tests/test_issue4927_durable_tool_snippet.py b/tests/test_issue4927_durable_tool_snippet.py index 4bbaf521..6973b1cc 100644 --- a/tests/test_issue4927_durable_tool_snippet.py +++ b/tests/test_issue4927_durable_tool_snippet.py @@ -60,3 +60,20 @@ def test_partial_tool_calls_path_also_falls_back(): "the partial-tool-calls derived path must also fall back to the " "persisted snippet (#4927)" ) + + +def test_all_derived_result_snippet_reads_have_fallback(): + """Every derived-push result-snippet READ (OpenAI top-level, Anthropic + tool_use content-array, and partial) must include the persisted fallback — + a missed branch (e.g. the Anthropic content-array push) would still + cold-reload with an empty body (#4927 gate).""" + region = _slice_derived_rebuild() + # Find every `const resultSnippet=resultsByTid[tid]...` read and assert each + # one chains to persistedSnippetByTid. + reads = re.findall(r"const resultSnippet=resultsByTid\[tid\][^;]*;", region) + assert reads, "no resultSnippet reads found in the derived rebuild" + for r in reads: + assert "persistedSnippetByTid[tid]" in r, ( + f"derived resultSnippet read missing the persisted fallback (#4927): {r}" + ) +