Add cancel_execution to the Hosted Agents trigger operations - #736
Merged
Merged
Conversation
harness-trigger now exposes POST .../executions/{id}/cancel (a supported
way to end a stuck webhook/cron execution instead of waiting on the
platform's reclaim sweep or destroying the session by hand). Adds
cancel_execution to both TriggersOperations (sync) and
AsyncTriggersOperations, hand-written like the rest of custom_triggers.py
(this API is not in the public OpenAPI spec pydo otherwise generates
from).
The force query param is passed as the literal string "true" rather than
a bare Python bool -- HttpRequest serializes bool params as "True"/
"False", which the server's exact-match check on "true" would silently
never see as forced. Covered by
test_cancel_execution_force_serializes_lowercase /
test_async_cancel_execution.
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.
What
Adds
cancel_executiontoTriggersOperations(sync) andAsyncTriggersOperations, wrapping harness-trigger's newPOST /v2/agents/triggers/{trigger_id}/executions/{execution_id}/cancel(MARSOHS-1686) -- a supported way to end a stuck webhook/cron execution
instead of waiting on the platform's reclaim sweep or destroying the session
by hand.
Hand-written in
custom_triggers.py/aio/agents/custom_triggers.py, likethe rest of the trigger API -- these operations aren't in the public
OpenAPI spec pydo otherwise generates from, and the module docstring already
notes it's "preserved across
make generate".A real bug caught before it shipped
The optional
forceparam is passed to the API as the literal string"true", not a bare Pythonbool.azure.core.rest.HttpRequestserializesTrue/Falseparams as the strings"True"/"False"(capital), and theserver does an exact match against lowercase
"true"-- soforce=Truewould have silently never actually forced anything. Verified this
empirically against a real
HttpRequestbefore writing the fix, and pinnedit with
test_cancel_execution_force_serializes_lowercase/test_async_cancel_execution.Testing
pytest tests/agents/test_triggers.py tests/agents/test_async_triggers.py--24 passed, including 4 new cases (plain cancel,
force=Trueserializingcorrectly,
force=False/omitted both dropping the param).black --checkclean.
Not in this PR
No
make generaterun -- the trigger API bypasses codegen entirely, sothere's nothing to regenerate.