Skip to content

fix(repair): match answered tool calls by call_id - #544

Closed
Kyzcreig wants to merge 1 commit into
mainfrom
fix/message-repair-call-id
Closed

fix(repair): match answered tool calls by call_id#544
Kyzcreig wants to merge 1 commit into
mainfrom
fix/message-repair-call-id

Conversation

@Kyzcreig

Copy link
Copy Markdown
Collaborator

Summary

  • make Pass 1.5 consume answered tool-result budget against both id and call_id
  • preserve valid Codex Responses-shaped tool turns when the result references call_id
  • remove the two temporary xfail markers for the restored regression tests

Problem

Pass 1 already registers both identifiers for each assistant tool call. Pass 1.5 only checked tc.get("id"), so a correctly answered tool call carrying only call_id — or distinct Codex id / call_id values — was misclassified as unanswered. The repair pass then deleted a valid assistant turn before every API request.

Solution

For each tool call, inspect both identifiers and consume whichever still has an unconsumed contiguous tool-result budget. This preserves the existing multiset behavior for duplicate IDs and the existing orphan/partial-orphan repair paths.

Verification

  • RED proof: reverted the production hunk with the xfail markers removed; both test_repair_keeps_tool_matching_*call_id tests failed with repairs == 1
  • scripts/run_tests.sh tests/run_agent/test_message_sequence_repair.py -q — 25 passed
  • python -m ruff check agent/agent_runtime_helpers.py tests/run_agent/test_message_sequence_repair.py — passed
  • git diff --check — passed

Scope

Pass 1.5 is fork-only code. This PR fixes the fork implementation without changing the broader repair pipeline.

Pass 1.5 now consumes the answered-result budget against both id and call_id, preserving Codex-shaped turns whose tool result references call_id. Remove the two temporary xfail markers.

RED: both call_id regressions fail with the production hunk reverted. GREEN: scripts/run_tests.sh tests/run_agent/test_message_sequence_repair.py -q (25 passed). Ruff passes on both changed files.
@Kyzcreig

Copy link
Copy Markdown
Collaborator Author

Closing as a duplicate of #547 — my fault, not the author's.

I dispatched a worker onto card t_08cca32f without noticing the card was already dispatchable, so two agents independently built the same fix ~15 minutes apart. Both are behaviorally equivalent: Pass 1.5 now resolves the answered budget against the id||call_id superset, matching Pass 1 (NousResearch#58168), and both delete the two xfail(strict=False) markers.

Adjudicated on measured merits rather than arrival order:

#544 (this) #547
Pass 1.5 superset match yes yes
xfail markers removed yes yes
test_repair_pass_1_5_keeps_call_id_only_assistant_turn yes yes
leftover unused import pytest yes (0 remaining pytest. uses) removed
inline rationale at the fix site brief full "why this deletes an answered turn"

#547 wins on the unused-import cleanup and the explanatory comment. No behavior is lost by closing this one.

Independent verification I ran on this branch still stands and applies to the shared fix: reverting the source alone turned exactly 3 tests red (test_repair_keeps_tool_matching_codex_call_id, test_repair_keeps_tool_matching_only_call_id, test_repair_pass_1_5_keeps_call_id_only_assistant_turn), restoring it gave 26 passed / 0 failed. The fix is load-bearing.

@Kyzcreig Kyzcreig closed this Aug 10, 2026
@Kyzcreig
Kyzcreig deleted the fix/message-repair-call-id branch August 10, 2026 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant