Skip to content

fix(extensions): resend calls an extension service did not process - #5735

Open
dvavili wants to merge 1 commit into
ai-openshell:mainfrom
dvavili:fix/5713-extension-call-retry/dvavili
Open

dvavili wants to merge 1 commit into
ai-openshell:mainfrom
dvavili:fix/5713-extension-call-retry/dvavili

Conversation

@dvavili

@dvavili dvavili commented Nov 19, 2026 •

Copy link
Copy Markdown

Summary

A gateway interceptor or supervisor middleware call fails closed when its connection closes as an extension service (like Agent Policy Fabric) restarts, even when a replacement instance is already serving. This PR resends a unary extension call when the transport reports the service did not process it.

Related Issue

Closes #5713

Changes

  • openshell-extension-core: add call_with_retries, which resends a call when the transport shows the service did not process it: a connect failure, a request cancelled before it was sent, a graceful GOAWAY, or a refused stream. Attempts are 5 ms to 100 ms apart and stop at the caller's deadline, returning the last transport failure in place of a timeout.
  • openshell-gateway-interceptors: Evaluate, SnapshotProviderProfiles and Describe go through call_with_retries with the binding's timeout as the deadline.
  • openshell-supervisor-middleware: EvaluateHttpRequest, Describe and ValidateConfig do the same.
  • Evaluations for a fail-open binding are not resent, so a service that is down does not delay them.
  • A call the service may have processed is not resent, and streaming calls are unchanged.
  • Docs: gateway interceptors and supervisor middleware operations pages describe the behavior.

Release Notes

Gateway interceptor and supervisor middleware calls no longer fail when an extension service is replaced by a rolling restart. A call that the service did not process is sent again within the call's timeout.

Testing

  • Checks appropriate to the affected code and behavior pass
  • Unit tests added/updated (if applicable)
  • E2E tests added/updated (if applicable)

cargo fmt --all -- --check, cargo clippy --all-targets -- -D warnings and cargo test pass for the three changed crates. The tests include a call that the service received and whose connection is then reset, which is delivered once, and a fail-open binding that is not retried.

Also run on a kind cluster against a build without this change, before the review changes to the deadline and to fail-open bindings, with egress requests and sandbox creations in loops while an extension service that serves an interceptor and a middleware is restarted:

Scenario Traffic Without this change With this change
Rolling update, new instance ready before the old one stops (40 restarts) Egress requests 5 of 98,974 failed 0 of 99,179 failed
Rolling update, new instance ready before the old one stops (40 restarts) Sandbox creations 2 of 15,563 failed 0 of 15,654 failed
One of two instances killed without a grace period (20 kills) Egress requests 1 of 31,412 failed 0 of 31,599 failed
One of two instances killed without a grace period (20 kills) Sandbox creations 3 of 4,951 failed 0 of 4,929 failed
Single instance down about 9 s, less than the 10 s middleware timeout (10 restarts) Egress requests 164 of 15,113 failed 10 of 14,937 failed
Single instance down about 9 s, longer than the 500 ms interceptor timeout (10 restarts) Sandbox creations 149 of 2,487 failed 128 of 2,452 failed

The interceptor used the default 500 ms timeout. The middleware was registered with a 10 s timeout, not the 500 ms default; with the default, the row for a single instance down about 9 s would show no improvement for egress requests either. The table counts calls that failed in the transport. When the service is down for longer than the call's timeout, calls still fail closed, as the last row shows.

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)
  • Architecture docs updated (if applicable)

@copy-pr-bot

copy-pr-bot Bot commented Nov 19, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added the state:accepted A maintainer decided OpenShell should pursue this issue label Nov 19, 2026

@pimlock pimlock 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.

Thanks for this. The design is sound: resending only when the transport proves the call never reached a handler is the same rule grpc-go and grpc-java use for transparent retry. I traced the hyper 1.9 / h2 0.4.19 / tonic 0.14 error paths and they hold up: is_canceled comes only from a still-queued envelope, and a remote GOAWAY(NO_ERROR) errors only streams above last_stream_id. I also ran a local harness against RemoteMiddlewareService. An abrupt close after the handler ran, a GOAWAY covering an accepted stream, and an Unavailable answer were each delivered exactly once. Ported to the base commit, the hand-over test fails, and at head it passed 200 of 200 runs.

Three things I'd like addressed before merge, inline below:

  1. Tie the retry window to the caller's deadline and keep the transport reason.
  2. Add a deterministic test that a call the service received is never resent.
  3. Move the middleware restart note out of the legacy accordion.

Optional nits

  • call_was_not_processed has no caller outside transport.rs, so it could drop out of the pub use in lib.rs (or become pub(crate)).
  • The PR description mentions a 10 s middleware timeout. The default is 500 ms (openshell-core/src/middleware.rs), so the rows in your results table may reflect a non-default configuration. Worth saying so.

@dvavili
dvavili force-pushed the fix/5713-extension-call-retry/dvavili branch from 5325c7a to 145382b Compare November 21, 2026 05:13
@pimlock
pimlock self-requested a review November 30, 2026 23:31
pimlock
pimlock previously approved these changes Nov 30, 2026
@dvavili
dvavili force-pushed the fix/5713-extension-call-retry/dvavili branch from 145382b to 035b599 Compare December 1, 2026 00:00
@pimlock
pimlock enabled auto-merge December 1, 2026 02:52
A gateway interceptor or supervisor middleware call failed closed when
its connection to the extension service closed as the service
restarted, even with a replacement instance already serving.

Unary extension calls are now sent again when the transport reports
that the service did not process them: a connect failure, a request
cancelled before it was sent, a graceful GOAWAY, or a refused stream.
Attempts back off from 5 ms to 100 ms until the call's timeout, and
the last transport failure is reported in place of a timeout. A call
the service may have processed is not sent again, and evaluations for
a fail-open binding are not sent again, so a service that is down does
not delay them.

Closes ai-openshell#5713

Signed-off-by: Divya Vavili <dvavili@nvidia.com>
auto-merge was automatically disabled December 1, 2026 05:36

Head branch was pushed to by a user without write access

@dvavili
dvavili force-pushed the fix/5713-extension-call-retry/dvavili branch from 035b599 to 6455ca5 Compare December 1, 2026 05:36

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state:accepted A maintainer decided OpenShell should pursue this issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: extension calls fail closed while a gateway interceptor or supervisor middleware service restarts

2 participants