Skip to content

Add cancel_execution to the Hosted Agents trigger operations - #736

Merged
SSharma-10 merged 2 commits into
mainfrom
prao/MARSOHS-1686/feat.cancel-execution
Oct 1, 2026
Merged

SSharma-10 merged 2 commits into
mainfrom
prao/MARSOHS-1686/feat.cancel-execution

Conversation

@sanpj2292

Copy link
Copy Markdown
Contributor

What

Adds cancel_execution to TriggersOperations (sync) and
AsyncTriggersOperations, wrapping harness-trigger's new
POST /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, like
the 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 force param is passed to the API as the literal string
"true", not a bare Python bool. azure.core.rest.HttpRequest serializes
True/False params as the strings "True"/"False" (capital), and the
server does an exact match against lowercase "true" -- so force=True
would have silently never actually forced anything. Verified this
empirically against a real HttpRequest before writing the fix, and pinned
it 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=True serializing
correctly, force=False/omitted both dropping the param). black --check
clean.

Not in this PR

No make generate run -- the trigger API bypasses codegen entirely, so
there's nothing to regenerate.

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.

@SSharma-10 SSharma-10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@SSharma-10
SSharma-10 merged commit 090048f into main Oct 1, 2026
6 checks passed
@SSharma-10
SSharma-10 deleted the prao/MARSOHS-1686/feat.cancel-execution branch October 1, 2026 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants