From 5885289c475e6783d6cc56590c5583be7b614d37 Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Wed, 26 Aug 2026 02:22:48 +0530 Subject: [PATCH] refactor(codex): route transports _pair_ids through shared fc_ canonicalization The reuse reviewer found a third copy of the fc_->call_ synthesis in agent/transports/codex.py _pair_ids (item_id[3:] spelling, which is why the len('fc_') grep missed it). All three sites now share _canonical_call_id_from_fc(), keeping the pairing invariant in one place. --- agent/transports/codex.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/agent/transports/codex.py b/agent/transports/codex.py index 45b53410c5..b6f0ef1c02 100644 --- a/agent/transports/codex.py +++ b/agent/transports/codex.py @@ -285,7 +285,10 @@ def _is_post_tool_replay(messages: Optional[List[Dict[str, Any]]]) -> bool: legacy sessions and host-fed histories still use, and let the rejected payload through. """ - from agent.codex_responses_adapter import _split_responses_tool_id + from agent.codex_responses_adapter import ( + _canonical_call_id_from_fc, + _split_responses_tool_id, + ) def _pair_ids(raw: Any, explicit: Any = None) -> set: """Every call id a stored tool id could pair on, converter-order.""" @@ -295,8 +298,9 @@ def _is_post_tool_replay(messages: Optional[List[Dict[str, Any]]]) -> bool: ids.add(explicit.strip()) if not ids and isinstance(raw, str) and raw.strip(): ids.add(raw.strip()) - if isinstance(item_id, str) and item_id.startswith("fc_") and item_id[3:]: - ids.add(f"call_{item_id[3:]}") + canonical = _canonical_call_id_from_fc(item_id) + if canonical: + ids.add(canonical) return ids trailing = set()