fix(compression): strip whitespace from tool_call_id in _sanitize_tool_pairs
_sanitize_tool_pairs() in ContextCompressor compared raw tool_call_id strings without stripping whitespace, the same bugfa3ab2ffdjust fixed in agent_runtime_helpers.py / run_agent.py (_get_tool_call_id_static + sanitize_api_messages). ContextCompressor has its own near-identical reimplementation of the pair-repair logic that was left unpatched. When assistant-side and result-side IDs diverge only in surrounding whitespace, the compressor misclassifies valid results as orphaned and replaces them with [Result unavailable] stubs — silent data loss on every compression cycle that touches such pairs. Apply the same .strip() fix to all three sites: - _get_tool_call_id (extracts IDs from assistant tool_calls) - result_call_ids accumulation loop - orphaned_results filter predicate Closes the sibling gap offa3ab2ffd/ #42405.
This commit is contained in:
@@ -6045,8 +6045,8 @@ This compaction should PRIORITISE preserving all information related to the focu
|
||||
SimpleNamespace), for logging/display only. Matching logic must use
|
||||
:meth:`_tool_call_id_variants` instead — see its docstring."""
|
||||
if isinstance(tc, dict):
|
||||
return tc.get("call_id", "") or tc.get("id", "") or ""
|
||||
return getattr(tc, "call_id", "") or getattr(tc, "id", "") or ""
|
||||
return (tc.get("call_id", "") or tc.get("id", "") or "").strip()
|
||||
return (getattr(tc, "call_id", "") or getattr(tc, "id", "") or "").strip()
|
||||
|
||||
@staticmethod
|
||||
def _tool_call_id_variants(tc) -> set:
|
||||
@@ -6092,7 +6092,7 @@ This compaction should PRIORITISE preserving all information related to the focu
|
||||
result_call_ids: set = set()
|
||||
for msg in messages:
|
||||
if msg.get("role") == "tool":
|
||||
cid = msg.get("tool_call_id")
|
||||
cid = (msg.get("tool_call_id") or "").strip()
|
||||
if cid:
|
||||
# Expand alias spellings on the RESULT side too — a
|
||||
# composite ``call|item`` tool_call_id must match a
|
||||
|
||||
Reference in New Issue
Block a user