fix: drop tool results missing call ids
maintainer edit: treat tool messages without tool_call_id as orphaned during session persistence so malformed results cannot survive into history.
This commit is contained in:
@@ -1406,6 +1406,23 @@ def test_save_turn_drops_orphaned_tool_results() -> None:
|
||||
assert [m["role"] for m in session.messages] == ["user", "assistant"]
|
||||
|
||||
|
||||
def test_save_turn_drops_tool_results_without_tool_call_id() -> None:
|
||||
loop = _mk_loop()
|
||||
session = Session(key="test:missing-tool-call-id")
|
||||
session.add_message("user", "hi")
|
||||
|
||||
loop._save_turn(
|
||||
session,
|
||||
[
|
||||
{"role": "tool", "name": "exec", "content": "missing id"},
|
||||
{"role": "assistant", "content": "done"},
|
||||
],
|
||||
skip=0,
|
||||
)
|
||||
|
||||
assert [m["role"] for m in session.messages] == ["user", "assistant"]
|
||||
|
||||
|
||||
def test_save_turn_keeps_tool_results_declared_in_prior_history() -> None:
|
||||
# Declarations may live in already-persisted history (e.g. a restored
|
||||
# runtime checkpoint), not only in the new-turn slice.
|
||||
|
||||
Reference in New Issue
Block a user