




























@@ -784,8 +784,6 @@ describe("claudeCliSessionTranscriptHasOrphanedToolUse", () => {
784784});
785785786786it("returns true when the last assistant message has a trailing tool_use without tool_result", async () => {
787-// Reproduces the 3d-engineer stuck-resume scenario: gateway died after
788-// claude emitted tool_use(Bash) but before the tool_result was flushed.
789787await writeJsonlSession("orphan", [
790788{
791789type: "assistant",
@@ -838,9 +836,6 @@ describe("claudeCliSessionTranscriptHasOrphanedToolUse", () => {
838836});
839837840838it("returns false when an earlier assistant tool_use is unanswered but the last assistant message resolved cleanly", async () => {
841-// Edge case: an unanswered tool_use deep in history is INERT — it
842-// can't block forward progress because a later assistant message
843-// already moved past it. Only TRAILING orphans matter.
844839await writeJsonlSession("buried", [
845840{
846841type: "assistant",
@@ -875,19 +870,11 @@ describe("claudeCliSessionTranscriptHasOrphanedToolUse", () => {
875870});
876871877872it("ignores sidechain entries when deciding orphans (matches main-history importer's skip rule)", async () => {
878-// A trailing sidechain (Task-tool / subagent) `tool_use` without a
879-// matching `tool_result` is NOT a forward-progress blocker for the
880-// main conversation. The existing history importer at
881-// gateway/cli-session-history.claude.ts skips `isSidechain === true`
882-// entries; this probe must do the same or it will falsely invalidate
883-// healthy main-conversation resumes that happen to have a sidechain
884-// unanswered tool_use near the tail.
885873await writeJsonlSession("sidechain-trailing", [
886874{
887875type: "assistant",
888876message: { role: "assistant", content: [{ type: "text", text: "ok" }] },
889877},
890-// Sidechain assistant with unanswered tool_use — should be ignored.
891878{
892879isSidechain: true,
893880type: "assistant",
@@ -908,15 +895,13 @@ describe("claudeCliSessionTranscriptHasOrphanedToolUse", () => {
908895909896it("still flags a main-conversation orphan even when sidechain entries exist alongside", async () => {
910897await writeJsonlSession("main-orphan-with-sidechain", [
911-// Main assistant orphan
912898{
913899type: "assistant",
914900message: {
915901role: "assistant",
916902content: [{ type: "tool_use", id: "toolu_main_orphan", name: "Bash", input: {} }],
917903},
918904},
919-// Sidechain entries after that don't help the orphan get answered.
920905{
921906isSidechain: true,
922907type: "user",
@@ -938,9 +923,6 @@ describe("claudeCliSessionTranscriptHasOrphanedToolUse", () => {
938923});
939924940925it("inspects the transcript tail past 500 records (does not inherit the content-probe cap)", async () => {
941-// 600 user-pings + 1 healthy-and-resolved tool turn + 1 trailing
942-// orphan tool_use. A capped walk that stops at record 500 would
943-// never see the orphan and incorrectly return false (resume hangs).
944926const lines: object[] = [];
945927for (let i = 0; i < 600; i++) {
946928lines.push({
@@ -980,9 +962,6 @@ describe("claudeCliSessionTranscriptHasOrphanedToolUse", () => {
980962});
981963982964it("does not falsely flag a long transcript whose orphan was resolved past record 500", async () => {
983-// 600 user-pings + early tool_use + 100 user-pings + late tool_result
984-// resolving it. A capped walk would stop before reaching the
985-// tool_result and return true (false positive → unnecessary reset).
986965const lines: object[] = [];
987966lines.push({
988967type: "assistant",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。