What Happened
- This change fixes a handoff/compaction bug where a prior assistant tool call is summarized away, leaving a `tool_result` with no visible `tool_use` anchor and causing Anthropic API 400 failures on resume. The PR adds a second pass in `transformMessages` to track surviving `tool_use` IDs, drop truly orphaned `tool_result` entries, and preserve their payload in a synthesized `<stale-tool-result>` developer message so context is not silently lost.
- This change fixes a handoff/compaction bug where a prior assistant tool call is summarized away, leaving a `tool_result` with no visible `tool_use` anchor and causing Anthropic API 400 failures on resume. The PR adds a second pass in `transformMessages` to track surviving `tool_use` IDs, drop truly orphaned `tool_result` entries, and preserve their payload in a synthesized `<stale-tool-result>` developer message so context is not silently lost.
- 1 evidence item attached for review.