Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Fixed

- Added regression coverage for `_cap_context_snapshot()` on many-small-fields snapshots (long field names and short values, and many short-named fields) staying within the 32768-byte limit. The marker-overhead accounting fix this card targeted was independently landed with a more thorough byte-precise budget in tsk-kkxn6f's `_build_truncated_marker()`; this fold pass kept that implementation and this card's added tests.
18 changes: 18 additions & 0 deletions tests/test_restart_orchestrator_resume.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,24 @@ def test_missing_snapshot_is_noop(self):
ro._cap_context_snapshot(note)
assert "context_snapshot" not in note

def test_many_long_keys_small_values_stays_under_limit(self):
big = {f"k{i:04d}_" + "x" * 53: "v" for i in range(600)}
note = {"context_snapshot": big}
ro._cap_context_snapshot(note)
capped_size = len(json.dumps(note["context_snapshot"], separators=(",", ":")))
assert capped_size <= ro._MAX_CONTEXT_SNAPSHOT_BYTES, (
f"cap returned {capped_size} bytes"
)

def test_many_short_keys_small_values_stays_under_limit(self):
big = {f"k{i}": i for i in range(4000)}
note = {"context_snapshot": big}
ro._cap_context_snapshot(note)
capped_size = len(json.dumps(note["context_snapshot"], separators=(",", ":")))
assert capped_size <= ro._MAX_CONTEXT_SNAPSHOT_BYTES, (
f"cap returned {capped_size} bytes"
)


class TestResumeRetryLoopCapsSnapshot:
@pytest.mark.asyncio
Expand Down
Loading