Repository navigation
Failure events 1/4: protocol, and one path for every invocation failure - #198
Open
shawnburke wants to merge 2 commits into
Open
shawnburke wants to merge 2 commits into
shawnburke wants to merge 2 commits into
Conversation
The first of four PRs split from #190. It adds the failure event protocol and the agent plumbing that classifies failures. Nothing consumes the failures yet: the FailureManager and the DispatchEvents stream come next. Protocol (additive): - DispatchEvents, a bidi stream for failure events and their answers. - DispatchRequest.failure_events, so the agent only keeps events for clients that ask. - DispatchHandlerInvoke.attempt and .deadline. - ReportInvocationRequest.failure, InvocationFailure, FailureReason, FailureSource, FailureAction, FailureResolution. Agent: - Invocations have one SetState with an explicit transition table. A queued invocation leaves the queue once: dispatched, expired or rejected. A dispatched one no longer expires on its queue timeout. - Every failure completes its invocation with a FailureError: a full queue, expiry in the queue, the agent's own timeout, and a failure the client reports. One watcher in Manager hands those to a FailureNotifier. An error reported without a failure, as older SDKs send, is only recorded. - Each dispatched invocation carries an absolute deadline (timeout + 5s grace), after which the agent reports the timeout itself. - InvocationSource[T] and a generic drain() replace the Dispatch send loop. Dequeue takes only ctx. - DispatchEvents answers Unimplemented until the FailureManager lands. - HandlerInvoke methods use pointer receivers, and the dispatch queue map is locked. - The webhook port can be set with WEBHOOK_PORT. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 20, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
shawnburke
marked this pull request as ready for review
November 20, 2026 02:15
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.
Context
Customer ask to be able to be notified if Axon handlers fail, with the handler invoke info and the failure reason, and the ability to retry or drop them in that case.
This is the basic protocol and plumbing for tracking and publishing failures (~400 lines impl)
Summary
Part 1 of 4, split from #190 (failure hooks, COR2-1098). This PR adds the failure event protocol and the agent plumbing that classifies every invocation failure. Nothing consumes the failures yet. The FailureManager and the
DispatchEventsstream come in part 2.Stack:
DispatchEventsProtocol (additive only)
rpc DispatchEvents(stream DispatchEventsRequest) returns (stream DispatchEvent): a bidi stream. The agent sends each failure, and the client answers DROP or RETRY on the same stream. It is a separate stream fromDispatch, because the Python SDK stops readingDispatchwhile all its handler slots are busy. That is exactly when failures happen.DispatchRequest.failure_events: the agent keeps events only for clients that ask for them.DispatchHandlerInvoke.attempt(0 means "not said", treat it as 1) and.deadline.ReportInvocationRequest.failure,InvocationFailure,FailureReason,FailureSource,FailureAction,FailureResolution,DispatchEventsRequest,DispatchEvent.Agent
Invocation state. A single
SetStatewith an explicit transition table. A queued invocation moves once, to dispatched, expired or rejected. Once dispatched, it ends only by a report or by the agent's timeout, not by its queue timeout.One failure path. Every failure the agent can see completes its invocation with a
FailureError, and one watcher inManager(watch) hands it to aFailureNotifier. The four sources are:NO_RESOURCES,caller_rejected);NO_RESOURCES);TIMEOUT/RUNTIME);ReportInvocationRequest.failure.An error reported without
failure, as older SDKs send them, is only recorded.Deadline. Each dispatched invocation carries an absolute
deadline: timeout + 5s grace. After it, the agent stops waiting and reports the timeout itself. The SDKs (parts 3 and 4) use it so they do not start stale work.Generic send loop.
InvocationSource[T]has one method,Dequeue(ctx, dispatchId), anddrain()sends whatever a source hands out.Dispatchnow drainsManager. Part 2 uses the same loop forDispatchEvents.DispatchEventsanswersUnimplementeduntil part 2. Without this stub, the embedded nilAxonAgentServerwould panic.Fixes:
HandlerInvokemethods use pointer receivers, because the value copy raced withComplete.Test support: the webhook port can be set with
WEBHOOK_PORT.Compatibility
All proto changes are additive. Old SDKs do not set
failure_eventsand ignore the new fields. With noFailureNotifierset, a failure is only logged.Test plan
make -C agent test,test-raceinvoke_state_test.go), with a recording notifier:invocation_failure_test.go):TIMEOUT/RUNTIME, with the right deadline;DispatchEventsanswersUnimplemented.🤖 Generated with Claude Code