Refresh Large_Scale_Tasks_Recipe.py for the current Task Group API - #75
Open
elijahgjacob wants to merge 2 commits into
Open
elijahgjacob wants to merge 2 commits into
elijahgjacob wants to merge 2 commits into
Conversation
The old recipe was a product-matching script on the beta SDK surface with a hard-coded task spec. This replaces it with a generic, resumable batch runner on client.task_group: plan (no API calls), paced submit at 1,000 runs per request under the caller's quota with run ids checkpointed before the next request, status across groups, and JSONL export that validates every input row came back exactly once (exit 2 otherwise). Verified end to end against the live API on 3 lite runs: submit, resume no-op, status, export with basis, and a tampered run log failing validation. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BqEaXBEuFVsj4Cz5iHyy2q
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BqEaXBEuFVsj4Cz5iHyy2q
elijahgjacob
marked this pull request as ready for review
September 23, 2026 01:03
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Large-Scale Tasks recipe was written a year ago against
client.beta.task_groupwith a hard-coded product-matching spec, and it no longer reflects how we run big batches. This replaces it with a generic, resumable runner on the current SDK surface. Same filename so existing links keep working.What the new recipe does
plan: counts runs, requests, and groups and estimates enqueue time from your quota. No API calls.submit: adds runs 1,000 per request withrefresh_status=False, paced at 90% of--rate-limit(runs per minute), sharded into Task Groups. Everyadd_runsresponse is appended toruns.jsonlbefore the next request, so a crash or re-run never resubmits a paid run. Any CSV works: all columns become string input fields, or one column can be sent as JSON.status: polls each group summary, optionally until no group is active. Its output is how you see the running count plateau, which is what a throughput pilot should measure.export: streams each group's runs to JSONL with output and per-field basis, then checks every input row came back exactly once. Exits 2 if anything is missing, duplicated, or unexpected.The module docstring covers what people get wrong on large jobs: the rate limit governs intake not throughput, runs cannot be cancelled once created, and a pilot should be at least 5k runs measured after concurrency plateaus. Wording matches the "Sizing a Large Job" section proposed in shapleyai/documentation#748.
Also updates the recipe descriptions in the root and
python-recipesREADMEs.Tested against the live API
2,000
literuns, 2026-09-22, grouptgrp_4dd7cbbb4a3541ce883cecaac94c1e7d, about $10:plan --input rows.csvsubmitsubmitagainstatus --waitexportok: true, exit 0The running count climbed 267 → 400 → 495 → 652 over the first four minutes before draining, the same ramp-up seen in the docs pilot. That is why the docstring says to pilot at least 5k runs and measure after the plateau rather than end to end.
Failure path, earlier 3-run check: a fake row appended to
runs.jsonlmadeexportreportmissing: 1,ok: false, exit 2.🤖 Generated with Claude Code
https://claude.ai/code/session_01BqEaXBEuFVsj4Cz5iHyy2q