Conversation
A fit that outlives the platform's request window answers HTTP 202 naming the fit rather than the prediction. `predict*` passed that body straight to `result["prediction"]` and raised KeyError, so a long Thinking fit could not be retrieved at all. It now collects: the id in the 202 is re-sent until the result is ready, paced by `Retry-After` and bounded by the new `collect_timeout_s`. Those follow-ups carry only the id and the test rows, so the training data is not shipped again — at a large context that is the whole payload on every attempt. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MuU9cPnmjTezLecPsK9HPd
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MuU9cPnmjTezLecPsK9HPd
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.
A Foundry endpoint answers HTTP 202 when a fit outlives the platform's request window: the body names the fit instead of carrying a prediction.
predict*readresult["prediction"]from it unconditionally and raisedKeyError, so a Thinking fit long enough to be handed off could never be retrieved — which is every Thinking fit on a non-trivial dataset._invokenow treats 202 as "not ready yet": it takes themodel_idfrom the body and re-sends until the result arrives.Retry-After, falling back to 10s. Only the delta-seconds form is honoured; an HTTP-date falls back rather than failing a collect that is otherwise progressing.collect_timeout_s(default 2h). On expiry it raisesTimeoutErrorand says the fit continues server-side, so calling again collects it.model_idraisesFoundryEndpointErrorrather than looping forever.Follow-up requests carry only the id and the test rows.
_build_request_bodyalready omits training data when a cached id is set, so the payload drops from the full dataset toX_teston every attempt after the first — the difference between re-uploading hundreds of megabytes per poll and a few.No change to the success path, and nothing new on the wire: the id was already returned on a 200 and already accepted as
context.model_id.Testing
tests/unit/test_foundry_collect.pydrives the loop withrespx: a 202 then a 200, several 202s in a row, a 202 lacking amodel_id, and an exhausted collect budget. It asserts the resend dropsx_train/y_trainand carriescontext.model_id, and coversRetry-Afterparsing including the HTTP-date fallback and a negative delta.The existing unit suite (333 tests) passes unchanged.
🤖 Generated with Claude Code
https://claude.ai/code/session_01MuU9cPnmjTezLecPsK9HPd