mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
fix: strip reasoning item IDs from Responses API input when store=False (#10217)
With store=False (our default for the Responses API), the API does not persist response items. When reasoning items with 'id' fields were replayed on subsequent turns, the API attempted a server-side lookup for those IDs and returned 404: Item with id 'rs_...' not found. Items are not persisted when store is set to false. The encrypted_content blob is self-contained for reasoning chain continuity — the id field is unnecessary and triggers the failed lookup. Fix: strip 'id' from reasoning items in both _chat_messages_to_responses_input (message conversion) and _preflight_codex_input_items (normalization layer). The id is still used for local deduplication but never sent to the API. Reported by @zuogl448 on GPT-5.4.
This commit is contained in:
parent
e69526be79
commit
a4e1842f12
2 changed files with 28 additions and 13 deletions
|
|
@ -1249,13 +1249,17 @@ def test_chat_messages_to_responses_input_deduplicates_reasoning_ids(monkeypatch
|
|||
]
|
||||
items = agent._chat_messages_to_responses_input(messages)
|
||||
|
||||
reasoning_ids = [it["id"] for it in items if it.get("type") == "reasoning"]
|
||||
# rs_aaa should appear only once (first occurrence kept)
|
||||
assert reasoning_ids.count("rs_aaa") == 1
|
||||
# rs_bbb and rs_ccc should each appear once
|
||||
assert reasoning_ids.count("rs_bbb") == 1
|
||||
assert reasoning_ids.count("rs_ccc") == 1
|
||||
assert len(reasoning_ids) == 3
|
||||
reasoning_items = [it for it in items if it.get("type") == "reasoning"]
|
||||
# Dedup: rs_aaa appears in both turns but should only be emitted once.
|
||||
# 3 unique items total: enc_1 (from rs_aaa), enc_2 (rs_bbb), enc_3 (rs_ccc).
|
||||
assert len(reasoning_items) == 3
|
||||
encrypted = [it["encrypted_content"] for it in reasoning_items]
|
||||
assert encrypted.count("enc_1") == 1
|
||||
assert "enc_2" in encrypted
|
||||
assert "enc_3" in encrypted
|
||||
# IDs must be stripped — with store=False the API 404s on id lookups.
|
||||
for it in reasoning_items:
|
||||
assert "id" not in it
|
||||
|
||||
|
||||
def test_preflight_codex_input_deduplicates_reasoning_ids(monkeypatch):
|
||||
|
|
@ -1272,7 +1276,11 @@ def test_preflight_codex_input_deduplicates_reasoning_ids(monkeypatch):
|
|||
normalized = agent._preflight_codex_input_items(raw_input)
|
||||
|
||||
reasoning_items = [it for it in normalized if it.get("type") == "reasoning"]
|
||||
reasoning_ids = [it["id"] for it in reasoning_items]
|
||||
assert reasoning_ids.count("rs_xyz") == 1
|
||||
assert reasoning_ids.count("rs_zzz") == 1
|
||||
# rs_xyz duplicate should be collapsed to one item; rs_zzz kept.
|
||||
assert len(reasoning_items) == 2
|
||||
encrypted = [it["encrypted_content"] for it in reasoning_items]
|
||||
assert encrypted.count("enc_a") == 1
|
||||
assert "enc_b" in encrypted
|
||||
# IDs must be stripped — with store=False the API 404s on id lookups.
|
||||
for it in reasoning_items:
|
||||
assert "id" not in it
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue