mirror of
https://github.com/usestrix/strix.git
synced 2026-10-16 04:28:23 +00:00
fix: recognize salvaged histories by prefix
This commit is contained in:
parent
29eaa86cda
commit
78b537cdf7
2 changed files with 13 additions and 2 deletions
|
|
@ -172,7 +172,7 @@ async def _salvage_stream_to_session(
|
|||
logger.exception("could not build salvage history for %s", agent_id)
|
||||
return
|
||||
pre_len = len(pre_run_items)
|
||||
if pre_len > 0 and len(replay) >= pre_len and replay[-pre_len:] == pre_run_items:
|
||||
if pre_len > 0 and len(replay) >= pre_len and replay[:pre_len] == pre_run_items:
|
||||
desired = replay
|
||||
else:
|
||||
desired = list(pre_run_items) + replay
|
||||
|
|
|
|||
|
|
@ -806,11 +806,22 @@ async def test_salvage_stream_to_session_preserves_full_history(tmp_path: Any) -
|
|||
"recon turn 2",
|
||||
]
|
||||
|
||||
# A replayed full history starts with the already-persisted session items.
|
||||
replayed_history = [
|
||||
*stored,
|
||||
{"role": "assistant", "content": "recovered turn"},
|
||||
]
|
||||
await execution._salvage_stream_to_session(
|
||||
session, stored, _SalvageStream(replayed_history), "child"
|
||||
)
|
||||
stored = [cast("dict[str, Any]", i) for i in await session.get_items()]
|
||||
assert stored == replayed_history
|
||||
|
||||
# A crash with nothing new to salvage leaves the session untouched.
|
||||
await execution._salvage_stream_to_session(
|
||||
session, list(await session.get_items()), _SalvageStream([]), "child"
|
||||
)
|
||||
assert len(await session.get_items()) == 3
|
||||
assert len(await session.get_items()) == len(replayed_history)
|
||||
session.close()
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue