Repository navigation
feat(runner)!: idempotent run submission via idempotency_key - #450
Draft
agutmanstein-scale wants to merge 1 commit into
Draft
agutmanstein-scale wants to merge 1 commit into
agutmanstein-scale wants to merge 1 commit into
Conversation
Runner.submit and POST /api/v1/tasks/{id}/run take an optional
idempotency_key. LocalRunner derives the run and instance ids from the key,
so a repeat of the same request returns the first run's handle without
starting another, and the same key with a different request raises
IdempotencyConflict (HTTP 409 in the explorer). Run groups reject the key.
The explorer passes the key only when a request carries one. A custom Runner
whose submit lacks the new parameter keeps working until a caller sends a
key; the plugin-api check still reports the signature change, hence the !.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QaPoLEaSJECgPbYkBi9rgb
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.
Requested by Alec Gutmanstein · Slack thread
What and why
Before: every
Runner.submitandPOST /api/v1/tasks/{id}/runstarted a new run, so a client that retried after a lost response, or sent the same request twice, got duplicate runs.After:
submitandPOST .../runtake an optionalidempotency_key. A repeat of the same request returns the first run's handle and starts no second run, even if the first failed. The same key with a different request is a 409 (IdempotencyConflict).POST .../runs(run groups) rejects the key with a 422.How:
LocalRunnerderives the run id and instance id from sha256 of the key, and compares the stored request (task, version, instance id, parameters) before inserting the run record. The check has noawaitbetween it and the insert, so concurrent submits on one event loop cannot both pass. The explorer passes the key only when a request carries one, so a customRunnerwithout the parameter keeps working until a caller sends a key. The!in the title is because the plugin-api check reports the newRunner.submitparameter as a break for overrides with the old signature.The hub-side equivalent is scaleapi/scaleapi PR #171584 (https://github.com/scaleapi/scaleapi/pull/171584), which dedupes via Temporal workflow ids and is independent of this change.
How it was tested
pytest tst/unit/runner tst/unit/explorer -q: 161 passed.ruff check .: clean.python .github/scripts/check_plugin_api.py --base origin/main --title "feat(runner)!: ...": reports theRunner.submitbreak, passes because the title carries!.make unit-test: 12541 passed, 2 failed, 16 skipped. The two failures,test_cli_env.py::test_no_limits_add_no_flagsandlocal_grant_server_test.py::test_the_platform_default_is_served_on_loopback_too_where_a_vm_on_this_machine_reaches_it, fail identically onmainwithout this change.Generated by Claude Code