Skip to content

🐛 fix(dataset): make dataset export return every example, not the first 100 - #818

Open
codekiln wants to merge 18 commits into
mainfrom
m19-p770-i809-dataset-export-all
Open

codekiln wants to merge 18 commits into
mainfrom
m19-p770-i809-dataset-export-all

Conversation

@codekiln

@codekiln codekiln commented Oct 13, 2026 •

Copy link
Copy Markdown
Owner

from AI(claude-code, claude-sonnet-5-5, langstar i809-dataset-export-all)

Fixes #809

dataset export sent one GET /api/v1/examples with limit=100, so a dataset with more examples was cut off silently. It now pages through every example unless --limit is given.

Changes

  • LangchainClient::list_examples_paginated (sdk/src/client.rs) streams examples, requesting pages at increasing offsets, each min(100, examples still needed), and stops at a page shorter than requested. Like query_runs_paginated it returns a Stream, so export writes each example as its page arrives and memory stays bounded to one page.
  • execute_export (cli/src/commands/dataset.rs) writes each streamed example as a JSONL line or CSV record; no --limit means all examples, --limit N still caps at N, and --limit 0 or a negative number exits with --limit must be at least 1, because the examples endpoint requires limit >= 1. With --out, it requests the first page before it opens the file, so a bad dataset id or API key leaves an existing file untouched and langstar exits with an error. If a later page fails, langstar exits with an error and the file keeps the examples written so far. Without --out, examples go to stdout as each page arrives.
  • openspec/specs/dataset/spec.md and docs/datasets.md now say that dataset export returns every example when --limit is absent, and the spec adds the --limit below 1 scenario and the first-page rule for --out.
  • Tests: a mockito SDK test for paging and the total cap, and a CLI integration test that imports 105 examples, exports them, asserts on every exported input/output and id, checks --limit 7 and --limit 101, and deletes the dataset; a CLI test that --limit=0 and --limit=-1 fail; and an integration test that exports a random dataset id over an existing --out file and asserts the file is unchanged.

How langsmith-sdk and langsmith-go page through examples

  • langsmith-sdk, the Python client: list_examples pages by offset through _get_paginated_list and stops at a page shorter than requested, as langstar does. It asks for 100 examples per page, or for the limit when that is smaller, and drops the examples it did not need from the last page, where langstar asks only for the examples it still needs.
  • langsmith-go, the Go client: its OffsetPaginationTopLevelArrayAutoPager pages by offset, sends no default limit, and stops at an empty page, which costs one extra request.

Decision for codekiln: accept a partial --out file after a later-page failure

🤖 Generated with Claude Code

…st 100

#809 🐛 fix(dataset): make dataset export return every example, not the first 100

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 13, 2026 22:03
@codekiln codekiln added this to the reboot milestone Oct 13, 2026
@codekiln codekiln added bug Something isn't working wip work in progress labels Oct 13, 2026
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Unit Test Results

226 tests  +1   226 ✅ +1   3s ⏱️ ±0s
  1 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit f2dccbb. ± Comparison against base commit ab158b1.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

SDK Integration Test Results

339 tests  +2   339 ✅ +2   15s ⏱️ ±0s
 14 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit f2dccbb. ± Comparison against base commit ab158b1.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Integration Test Results

365 tests  +3   365 ✅ +6   1m 25s ⏱️ - 3m 5s
 15 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌  - 3 

Results for commit f2dccbb. ± Comparison against base commit ab158b1.

♻️ This comment has been updated with latest results.

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.

🟡 Changes recommended

Pagination needs snapshot consistency and should avoid fetching up to 100 records for small explicit limits.

2 open findings
What changed in this PR

Fixes dataset exports silently stopping after 100 examples by adding SDK pagination and using it from the CLI.

Changes:

  • Adds paginated example retrieval with an optional total limit.
  • Updates CLI export behavior and coverage for multi-page datasets.
  • Aligns the dataset specification with unlimited default exports.
File Description
sdk/​src/​client.rs Adds paginated example listing.
sdk/​tests/​dataset_test.rs Tests pagination and limits.
cli/​src/​commands/​dataset.rs Uses pagination during export.
cli/​tests/​dataset_command_test.rs Tests multi-page CLI exports.
openspec/​specs/​dataset/​spec.md Documents exporting every example by default.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread sdk/src/client.rs Outdated
Comment thread sdk/src/client.rs Outdated

@codekiln codekiln left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

from AI(claude-code, claude-sonnet-5-5, langstar i809-dataset-export-all)

Two inline comments and two findings that have no added line to sit on.

Code and factual finding on a file the PR leaves unchanged. docs/datasets.md:330 still says -l, --limit <N> - Maximum number of examples to export (default: 100), and docs/datasets.md:652still tells readers about "pagination limits (default 100 items)". After this changedataset exporthas no default limit, and the CLI's own help already says(default: all)([cli/src/commands/dataset.rs:174](https://github.com/codekiln/langstar/blob/462971a339ce1ee4b590d477f3a6c68a7dd9ca3c/cli/src/commands/dataset.rs#L174)). Cost: a reader of the user guide still learns the bug as the documented behaviour. Rewrite for line 330:- -l, --limit <N> - Maximum number of examples to export (default: every example in the dataset)`.

Code and factual finding on the PR body. The line langsmith-sdk (list_examplesvia_get_paginated_list): matches. Offset paging, page size 100, stop on a short page. leaves out that langsmith-sdk sends min(limit, 100) per page (see the inline comment), and langsmith-go (...): matches in spirit hides a real difference: its GetNextPage stops on an empty page and never sends a default limit (pagination.go:40-43), where langstar stops on a short page. Cost: the reader cannot tell which behaviours were copied and which were not. Rewrite: - langsmith-sdk (list_examplesthrough_get_paginated_list): pages by offset and stops on a short page, as langstar does. It sends min(limit, 100) per request; langstar sent 100 until the fix in this review round. and - langsmith-go (OffsetPaginationTopLevelArrayAutoPager): pages by offset but stops on an empty page, which costs one extra request, and sends no default limit. langstar stops on a short page. Adjust the first once the page-size fix lands.

Suggested squash-merge subject: unchanged from the title.

Comment thread sdk/src/client.rs Outdated
Comment thread cli/tests/dataset_command_test.rs Outdated
…ll needs

#809 🐛 fix(dataset): make dataset export return every example, not the first 100

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 13, 2026 22:09

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.

🔵 Needs a closer look

Negative export limits are silently converted into successful empty exports.

0 open findings

2 resolved since last review
Previously missed (1)

In code that hasn't changed since last review

Medium severity Reject negative limits instead of producing an empty backup

cli/​src/​commands/​dataset.rs:669

--limit=-1 is accepted as an i64, but this clamp silently turns it into a successful zero-record export. A negative maximum is invalid input and previously reached the API's validation (the examples endpoint requires limit >= 1); reject it explicitly instead of producing an unexpectedly empty backup.

🧠 Review effort: Balanced

@codekiln codekiln left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

from AI(claude-code, claude-sonnet-5-5, langstar i809-dataset-export-all)

Round 2. The paging loop, the min(100, still needed) request size, the 105-example integration test, the docs and spec edits, and the upstream claims all check out against the clones (_get_paginated_list pages by offset and stops on a short page, list_examples sends min(limit, 100), langsmith-go's pager stops on an empty page). One finding, on the mockito test.

Comment thread sdk/tests/dataset_test.rs
…tive export limit

#809 🐛 fix(dataset): make dataset export return every example, not the first 100

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 13, 2026 22:13

@codekiln codekiln left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

from AI(claude-code, claude-sonnet-5-5, langstar i809-dataset-export-all)

Round 3 at 48feaed. The paging loop, the mockito test (every mock is asserted, and the offset-0 mock's expect(2) matches the two calls that hit it), the integration test, docs/datasets.md and the spec read correctly. One finding, on the body, which has no line to sit on.

AI (codekiln-review): Factual finding on the PR body. Quoted: "--limit N still caps at N." and the Tests bullet "a mockito SDK test for paging and the total cap, and a CLI integration test that imports 105 examples...". Neither says that commit 48feaed made dataset export reject --limit 0 and negative values with --limit must be at least 1, which changes what a user who passes those values sees; before, --limit 0 sent limit=0 to the API. The reader of the body learns of a user-visible behavior change only by reading the diff. Rule: no page states it; it is the body telling the reader what changed, as A pointer carries a link, an id with a slug, and a reason asks of anything the reader would otherwise have to go find. Rewrite: change the execute_export bullet to "execute_export (cli/src/commands/dataset.rs) uses it; no --limit means all examples, --limit N caps at N, and --limit 0 or a negative number exits with --limit must be at least 1, because the examples endpoint requires limit >= 1." and add "and a CLI test that --limit=0 and --limit=-1 fail" to the Tests bullet.

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.

🟡 Changes recommended

Unlimited exports currently buffer the entire dataset in memory, risking failure on large datasets.

1 open finding

🧠 Review effort: Balanced

Comment thread sdk/src/client.rs Outdated
…ng the whole dataset

#809 🐛 fix(dataset): make dataset export return every example, not the first 100

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 13, 2026 22:22

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.

🟡 Changes recommended

Failed paginated exports can truncate and replace an existing output file with partial data.

1 open finding
1 resolved since last review

🧠 Review effort: Balanced

Comment thread cli/src/commands/dataset.rs

@codekiln codekiln left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

from AI(claude-code, claude-sonnet-5-5, langstar i809-dataset-export-all)

Round 5 at d9af2a6. The streaming loop, the page sizes, the CSV flush, the Exported N examples count, the spec scenario and the docs read correctly, and a page that fails after some examples were written does exit 1 (cli/src/main.rs calls std::process::exit(1) on any error). Two findings, both on code and facts: the output file is now opened before the first request, and a comment compares the page size with langsmith-sdk's too loosely.

Comment thread cli/src/commands/dataset.rs
Comment thread sdk/src/client.rs Outdated
#809 🐛 fix(dataset): make dataset export return every example, not the first 100

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 13, 2026 22:27
@codekiln codekiln added ready-for-review Green CI, no open threads, Copilot settled; ready for codekiln to review and merge and removed ready-for-review Green CI, no open threads, Copilot settled; ready for codekiln to review and merge labels Oct 13, 2026
@codekiln codekiln removed the ready-for-review Green CI, no open threads, Copilot settled; ready for codekiln to review and merge label Oct 14, 2026
Copilot AI balanced review requested due to automatic review settings October 14, 2026 14:19
@codekiln codekiln added the wip work in progress label Oct 14, 2026

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.

🟡 Changes recommended

The documented later-page failure behavior lacks deterministic test coverage.

1 open finding

🧠 Review effort: Balanced

Comment thread cli/tests/dataset_command_test.rs
@codekiln codekiln added the priority: high Review first: fixes broken CI or security, or other PRs stack on it label Oct 14, 2026
Copilot AI balanced review requested due to automatic review settings October 14, 2026 19:51

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.

🔵 Needs a closer look

No blocking code issues were identified, but successful CI builds and tests, including API-backed export validation, remain unconfirmed.

1 open finding

🧠 Review effort: Balanced

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

Pagination, limit handling, and first-request file protection match the agreed scope, with no unresolved findings.

1 open finding

🧠 Review effort: Balanced

Page 1 examples are yielded before the Err when page 2 fails.

#809 🐛 fix(dataset): make dataset export return every example, not the first 100
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 14, 2026 21:42

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

No unresolved blocking findings remain within the agreed scope; atomic output replacement is tracked separately in #822.

0 open findings

1 resolved since last review

🧠 Review effort: Balanced

@codekiln codekiln added ready-for-review Green CI, no open threads, Copilot settled; ready for codekiln to review and merge and removed wip work in progress labels Oct 14, 2026
@codekiln codekiln removed the ready-for-review Green CI, no open threads, Copilot settled; ready for codekiln to review and merge label Oct 27, 2026
@codekiln codekiln added the wip work in progress label Oct 27, 2026 — with Claude
Copilot AI balanced review requested due to automatic review settings October 27, 2026 21:08

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

No blocking issues remain in pagination, limit handling, or streaming export behavior within the agreed scope.

No open issues 🎉

Review effort: Balanced

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

Labels

bug Something isn't working priority: high Review first: fixes broken CI or security, or other PRs stack on it wip work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 fix(dataset): make dataset export return every example, not the first 100

2 participants