feat: add task deadlines and cancellation#49
Merged
Conversation
1fe7c21 to
530d4f6
Compare
ebarti
added a commit
that referenced
this pull request
Jul 10, 2026
## What - delegates the no-override model choice to each provider instead of pinning library-owned names - preserves one precedence chain: task field > legacy metadata > constructor override > provider-native - omits vendor model kwargs when selection is provider-native - records `model_source` on every provider result and records `model` only when known - keeps `default_model=` as an explicit migration override - makes configured model allow-lists fail closed when provider-native selection cannot be verified ## Why Hard-coded adapter defaults age faster than the SDK and can override supported provider configuration. The SDK-evolution docs already described Claude and Antigravity as provider-native, but the adapters silently forced stale model names. ## Root cause Model resolution treated the library constructor default as mandatory rather than an optional override, and result metadata could not distinguish task, metadata, constructor, and provider-native selection. ## Compatibility This is an intentional pre-1.0 behavior change. Applications that need the prior pin can pass the same value through `default_model=`; task and metadata overrides keep their existing precedence. ## Checks - `ruff check src tests` - strict `mypy` - full all-extras suite: 396 passed, 3 skipped - model-policy coverage run: 356 passed, 3 skipped; 91.00% coverage - installed SDK contracts: 23 passed - `uv lock --check` - `uv build` ## Stack - Base: #47 - Next: #49
bcd080c to
dbca5cd
Compare
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.
Stack
What this fixes
The runtime protocol advertised cancellation, but every provider adapter implemented it as a no-op, and tasks had no portable execution deadline. That left callers unable to bound startup, process-reuse queueing, or in-flight provider work.
Changes
AgentTask.deadlineAgentKit.run(timeout=...)as a finite non-negative seconds/timedeltaconvenienceAgentTaskTimeoutErrorandFinishReason.TIMED_OUTCancellationReceiptand explicit cancellation dispositionsAgentKit.cancel()target active cached runtimes without constructing new onescancel()returnsNoneAdversarial race hardening
Independent reproductions found concurrency defects beyond the initial green suite. Follow-up commits now:
AgentKit.cancel()caller is cancelledAttributeErrorVerification
uv run ruff check .mypyuv lock --checkuv buildgit diff --checkStack health
All 11 required GitHub checks pass on
bcd080c; the opt-in upstream-latest workflow is skipped by design.