Repository navigation
Failure events 4/4: Go SDK failure hook - #201
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 fourth of four PRs split from #190. WithFailureHook sets a hook that runs for each failure event the agent sends on DispatchEvents, and returns FailureActionDrop or FailureActionRetry, which is sent back as the answer. A panicking hook answers DROP and the stream continues. The SDK does not run the hook for its own failures. It classifies them into ReportInvocationRequest.failure: HANDLER_ERROR for an error or panic, TIMEOUT for a timeout, APPLICATION or RUNTIME by where it happened (a timeout during a Cortex API call, or one capped by the deadline, is RUNTIME). It does not start an invocation past its deadline. An agent without DispatchEvents answers Unimplemented; the SDK logs once and does not redial. Fixes found along the way: - invokeHandler let a timed-out handler write to the report while it was being sent. - Run(ctx) ignored cancellation: it opened its stream with context.Background(), and its exit flag was raced. The end-to-end test builds and runs the real agent; it is skipped with -short. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
engrams-agent
Bot
force-pushed
the
shawn/failure-events-2-manager
branch
from
November 20, 2026 02:12
e1a7aa0 to
5019c4b
Compare
engrams-agent
Bot
force-pushed
the
shawn/failure-events-4-go
branch
from
November 20, 2026 02:12
2989379 to
16e636e
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 4 of 4, split from #190 (COR2-1098). This PR adds
WithFailureHookto the Go SDK. Based on #199.Stack:
DispatchEventsBehavior
WithFailureHooksets a hook that runs for each failure event from the agent. It returnsFailureActionDroporFailureActionRetry, which is sent back as the answer. A panicking hook answers DROP, and the stream continues.ReportInvocationRequest.failure:HANDLER_ERROR/APPLICATION;TIMEOUT;RUNTIME.DispatchEventsanswersUnimplemented. The SDK logs once and does not redial.invokeHandlerlet a timed-out handler write to the report while it was being sent.Run(ctx)ignored cancellation: it opened its stream withcontext.Background(), and its exit flag was raced.Test plan
go test -race ./...insdks/goUnimplementedagent is not redialed;failure_eventsflag.e2e_failure_test.go, skipped with-short): against a real agent, a handler error and a timeout each reach the hook, the retry succeeds with the original body, and the failure is not delivered twice.🤖 Generated with Claude Code