Skip to content

SWF(bug): honor after cursor and has_more in conversation item listing - #58

Merged
maplepaladin73 merged 1 commit into
mainfrom
devin/1795378311-conversation-items-pagination
Nov 22, 2026
Merged

maplepaladin73 merged 1 commit into
mainfrom
devin/1795378311-conversation-items-pagination

Conversation

@maplepaladin73

@maplepaladin73 maplepaladin73 commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

GET /v1/conversations/{id}/items now pages like OpenAI: after skips past the cursor item (in the requested order), has_more is true when items remain beyond limit, and an unknown after id returns 400 (param: "after", code: "item_not_found").

Root cause: list_conversation_items never read the after query param, truncated the full ordered list, and hard-coded "has_more": false. So limit=1 reported no more pages, and after=<first id> returned the first item again.

Try it: ATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo test -p spark-server --bin spark conversation_items_pagination (run bash scripts/ci_gpu_stubs.sh once first on a GPU-less box)

Test plan

New regression tests in api/tests/conversation_items_pagination.rs (limit=1 has_more, after=first returns second, last page, desc+after, unknown after → 400, empty conversation).

Before the fix (5 of 6 fail):

unknown_after_is_invalid_request ... FAILED
  left: 200
 right: 400
limit_one_has_more ... FAILED
  left: Bool(false)
 right: true
test result: FAILED. 1 passed; 5 failed; 0 ignored; 0 measured; 3233 filtered out

After the fix:

test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 3233 filtered out

Full spark bin suite: test result: ok. 3225 passed; 0 failed; 14 ignored.

Live check: modelless spark serve, a conversation with items first, second, third:

GET items?limit=1                    -> data:[first]  has_more:true
GET items?limit=1&after=first        -> data:[second] has_more:true
GET items?limit=1&after=second       -> data:[third]  has_more:false
GET items?order=desc&limit=1&after=third -> data:[second] has_more:true
GET items?after=missing              -> HTTP 400 invalid_request_error, param "after", code "item_not_found"
  • cargo fmt --all -- --check
  • ATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo clippy --workspace --tests (clean)
  • bash scripts/check-license-headers.sh (0 invalid)
  • typos (clean)
  • Tested against a real model / hardware: not done (no GPU run; the change only touches the HTTP handler)
  • Added or updated tests where applicable

Notes for reviewers

  • Not tested: GPU/real-model serving. Also untested: before (not supported here, and not part of this fix).
  • I picked 400 for an unknown after id rather than silently returning page one, so clients with a bad cursor get an error instead of repeated data.

CLA


Software Factory opened this PR for Robert
Implemented in session Fix conversation items pagination cursor and has_more
Review with Devin · Open in Devin Desktop


…sting

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@maplepaladin73
maplepaladin73 merged commit 7a09f5c into main Nov 22, 2026
1 check passed
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.

1 participant