Repository navigation
Failure events 3/4: Python SDK failure hook - #200
Draft
shawnburke wants to merge 1 commit into
Draft
shawnburke wants to merge 1 commit into
shawnburke wants to merge 1 commit into
Conversation
This was referenced Nov 20, 2026
The third of four PRs split from #190. AxonClient takes on_failure. The hook runs for each failure event the agent sends on DispatchEvents, and returns FailureAction.DROP or RETRY, which is sent back as the answer. Returning None or raising means DROP. Events are read on their own thread and run on their own pool, so they arrive even while every handler slot is busy. The SDK does not run the hook for its own failures. It classifies them into ReportInvocationRequest.failure (APPLICATION or RUNTIME; a timeout during a Cortex API call or while waiting for a free handler is RUNTIME), and the agent delivers them. At the deadline the SDK reports the timeout itself and drops whatever the handler does afterwards, since a Python thread can't be stopped. It does not start an invocation past its deadline. An agent without DispatchEvents answers Unimplemented; the SDK logs once and does not ask again. The end-to-end tests build and run the real agent, so the workflow now sets up Go. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
engrams-agent
Bot
force-pushed
the
shawn/failure-events-3-python
branch
from
November 20, 2026 02:12
0102204 to
82c193f
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.
Summary
Part 3 of 4, split from #190 (COR2-1098). This PR adds
on_failureto the Python SDK. Based on #199.Stack:
DispatchEventsThe hook receives the original message and a reason that separates handler failures from Axon failures:
reasonsourceHANDLER_ERRORAPPLICATIONTIMEOUTAPPLICATION, orRUNTIMEif it was waiting on a Cortex API call or for a free handlerTIMEOUTRUNTIMENO_RESOURCESRUNTIME,caller_rejected=trueNO_RESOURCESRUNTIMEUsage
Behavior
ReportInvocationRequest.failure, and runs the hook only for events from the agent. The hook's return value is the answer. ReturningNoneor raising means DROP.DispatchEventsanswersUnimplemented. The SDK logs once and stops asking.Test plan
ruffclean; locally 28 passed and the 3 e2e tests skipped (no Go modules in my environment).APPLICATION, and its late result is dropped;🤖 Generated with Claude Code