Skip to content

fix(server): preserve completion cursors when deleting rollouts - #648

Open
ningyixi wants to merge 1 commit into
microsoft:mainfrom
ningyixi:fix/terminal-rollout-id-reuse
Open

ningyixi wants to merge 1 commit into
microsoft:mainfrom
ningyixi:fix/terminal-rollout-id-reuse

Conversation

@ningyixi

Copy link
Copy Markdown

Deleting a completed rollout leaves its ID in the completion log. Re-enqueueing the same client-assigned ID then makes /api/rollouts/terminal return a queuing rollout; completing it adds a second entry for the same new rollout.

Replace deleted completion entries with tombstones, keeping the existing index-based cursors stable. A live ID-to-index map keeps deletion constant-time instead of rescanning the growing completion log. Wire response fields and pagination semantics stay the same.

Related: #547. That PR removes entries from the list, shifting positions underneath existing cursors. This alternative preserves those positions; its API regression also verifies that a cursor obtained before deletion still returns the next surviving completion. It covers recreation, exclusion before completion, and exactly one new completion after recreation.

Validation:

  • The regression fails on current main: a newly queued rollout appears in the terminal page.
  • uv run --locked --no-sync pytest -q tests/server — 33 passed.
  • Repository-wide Ruff lint, formatting checks, pre-commit hooks, and copyright-header checks passed.
  • Pyright passed for all four changed files. The full VERL/CPU training suite was not run.

Prepared with Codex AI assistance; the diff and before/after regression results were checked locally. No model service or GPU is needed for these tests.

Copilot AI balanced review requested due to automatic review settings October 17, 2026 08:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused changes preserve cursor positions and prevent stale ID replay, with regression coverage and no identified blocking issues.

No open issues 🎉

What changed in this PR

Fixes deleted rollout IDs reappearing in terminal results while preserving existing pagination cursors, avoiding the index shifts proposed in #547.

Changes:

  • Uses tombstones and an ID-to-index map for constant-time deletion without shifting cursors.
  • Adds regression coverage for deletion, ID reuse, and cursor stability.
File Description
tests/​server/​test_endpoints.py Tests deletion, recreation, and stable completion cursors.
tests/​server/​conftest.py Clears the new index between tests.
agentlightning/​server/​store.py Defines tombstone-capable storage and the completion index.
agentlightning/​server/​routes/​rollouts.py Maintains the index and skips deleted completion entries.

Review effort: Balanced

@ningyixi

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants