Skip to content

The agent that grows with you

fix(codex): confirm a pending call whose call_id first appears on its done item

Tekniuma9e2716c9b9e
diff --git a/agent/codex_runtime.py b/agent/codex_runtime.py
index 2dd1ce47738..a14be68fc69 100644
--- a/agent/codex_runtime.py
+++ b/agent/codex_runtime.py
@@ -980,6 +980,13 @@ class _CodexResponseAssembler:
# must not evict unrelated calls, even when no alias matches.
pending_keys = [key for key, pending in self.pending_function_calls.items()
if _event_field(pending["item"], "call_id") == done_call_id]
+ # An announcement that carried no call_id cannot contradict this one, so the
+ # positional match argument events use is the only evidence left for it.
+ if not pending_keys:
+ pending_key = self._pending_function_key(done_id, _event_field(event, "output_index"))
+ if pending_key is not None and not _event_field(
+ self.pending_function_calls[pending_key]["item"], "call_id"):
+ pending_keys = [pending_key]
announced_sequence, announced_index = None, None
else:
# Without a stable call_id, retain item-id then index association,
diff --git a/tests/agent/test_codex_responses_settle_pending_tool_calls.py b/tests/agent/test_codex_responses_settle_pending_tool_calls.py
index c1f152b674f..9257ef9869e 100644
--- a/tests/agent/test_codex_responses_settle_pending_tool_calls.py
+++ b/tests/agent/test_codex_responses_settle_pending_tool_calls.py
@@ -158,6 +158,8 @@ def test_done_call_coalesces_all_pending_aliases_in_announced_order(done_id):
id='call_id_over_conflicting_item_and_index'),
pytest.param({'call_id': 'call_a'}, {'id': 'fc_a', 'call_id': 'call_new'}, 0, False,
id='unmatched_call_id_cannot_evict_by_item_or_index'),
+ pytest.param({}, {'id': 'fc_done', 'call_id': 'call_a'}, 0, True,
+ id='call_id_first_seen_on_done_confirms_by_index'),
*[pytest.param({'call_id': 'call_a'}, {**fields, 'call_id': 'call_a'}, 1, True,
id=f'{label}_item_id_uses_call_id')
for label, fields in [('missing', {}), ('null', {'id': None}),