fix: prune deleted rollouts from terminal completion log - #547
elren (elrensmin) wants to merge 1 commit into
Conversation
|
@microsoft-github-policy-service agree |
There was a problem hiding this comment.
Pull request overview
This PR fixes cursor-pagination correctness for the “terminal rollouts” endpoint by ensuring that deleting a rollout also removes its ID from the in-memory completion log used to paginate terminal rollouts.
Changes:
- Update
delete_rolloutto prune deleted rollout IDs from_terminal_order. - Add regression tests covering deletion effects on
/api/rollouts/terminaltotals/cursors and the delete→re-enqueue→complete flow.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| agentlightning/server/routes/rollouts.py | Prunes deleted rollout IDs from the terminal completion log to keep cursor pagination consistent. |
| tests/server/test_endpoints.py | Adds regression tests to prevent reintroduction of stale/duplicate terminal-log entries after delete and re-enqueue. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if rollout_id in _terminal_order: | ||
| _terminal_order.remove(rollout_id) |
e3ad925 to
0e47a67
Compare
Sylvester Kaczmarek (sylvesterkaczmarek)
left a comment
There was a problem hiding this comment.
This fixes stale IDs in the current snapshot, but compacting _terminal_order breaks already-issued positional cursors. For example, if a client consumes [a, b] and receives next_after=2, then a is deleted from [a, b, c], the list becomes [b, c] and the next request with after=2 skips c. Because the endpoint documents this as an append-only completion log, deletion needs tombstones/a monotonic sequence (or a cursor redesign), plus a regression where deletion happens between pages.
Description
delete_rollout (agentlightning/server/routes/rollouts.py:216) pops the rollout from _rollouts and _events but never removes its id from _terminal_order. The append-only completion log backing cursor pagination.
Consequences:
Fix (root cause, not symptom)
In delete_rollout, also prune the completion log:
Removing from the list shifts subsequent indices, which is exactly what keeps the cursor consistent. This also fixes the re-enqueue case: after delete prunes the id, re-completion appends exactly once.
Tests
Added two regression tests in tests/server/test_endpoints.py:
Verification
Note on pre-existing repo-wide failures (out of scope, not introduced here)
The repo does not currently pass its own lint/format gates cleanly. These are pre-existing and unrelated to this change; I deliberately left them untouched to keep the diff minimal:
There is no CONTRIBUTING doc, no .pre-commit-config.yaml, and no CI lint/test workflow in this repo (only docs + skills deploy workflows), so these are the only gates available.