Skip to content

feat(agent): enforce cancellation-aware switch boundary for streaming model fallback (issue #210) - #368

Open
XianReallyHot-ZZH wants to merge 1 commit into
agentic-ai-java:mainfrom
XianReallyHot-ZZH:feat/issue-210-streaming-fallback-boundary
Open

XianReallyHot-ZZH wants to merge 1 commit into
agentic-ai-java:mainfrom
XianReallyHot-ZZH:feat/issue-210-streaming-fallback-boundary

Conversation

@XianReallyHot-ZZH

Copy link
Copy Markdown
Contributor

Contributing to ARGI: enforce a cancellation-aware switch boundary for streaming model fallback in ModelFallbackInterceptor — cause-chain cancellation detection, first-event switch gate, per-attempt execution guard checks, boundedElastic switch dispatch and per-subscription switch state, aligning the interceptor with ModelRetryInterceptor's streaming semantics (issue #210).

… model fallback (issue agentic-ai-java#210)

ModelFallbackInterceptor matched only top-level CancellationException, so a
wrapped cancellation still dispatched another provider call, and streaming
failures were passed through unchanged regardless of observable output.

- Detect cancellations through the cause chain (depth-bounded against cyclic
  chains) and terminate without switching; the unwrapped identity is kept
  before and after the first emitted event. Reactive paths never touch the
  pooled thread's interrupt flag; the synchronous path keeps its
  thread-aware semantics.
- Switch a failing stream to the next candidate only before any event (text
  delta, tool call, usage, response) has been emitted; afterwards the failure
  terminates the stream so two models' output is never concatenated.
- Check the request's ExecutionGuard before every attempt, the primary
  included; a dead run is terminal on both the synchronous and the streaming
  path.
- Dispatch the streaming switch on boundedElastic so a non-streaming fallback
  candidate cannot park the thread that delivered the failure.
- Give each subscription its own switch state, extend the aggregate failure
  message with the attempt sequence, and document the recommended
  fallback-outer/retry-inner composition order.
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.

1 participant