hook: a 4xx with a decision body is a verdict, not an outage - #16
Merged
Conversation
The gateway answers rate-limit denies (429) and invalid-tool denies (400)
with {decision, reason}, but every non-2xx routed to the outage posture —
so interactive sessions failed OPEN on a deliberate deny (rate limits were
unenforced client-side) and unattended tiers denied with a misleading
"gateway unreachable" message. 4xx responses now parse the body first:
deny → denyByPolicy with the server's reason, ask → the ask path. Bodyless
4xx (the auth guard's 401) and all 5xx keep the outage posture unchanged.
Refs gatewaystack-connect#718, #719, #553.
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.
What
Every non-2xx from
/govern/tool-userouted to the outage posture (failPostureOnOutage). But the gateway's 429 rate-limit deny and 400 invalid-tool deny are deliberate verdicts carrying{decision, reason}— treating them as outages meant:Now: 4xx → try to parse the body;
deny→denyByPolicywith the server's reason;ask→ the ask path. Bodyless 4xx (auth guard's 401) and all 5xx keep the existing outage posture, unchanged.This is the correctness half of #553 — transparent absorption of short retry-afters can build on this (the reason string now reaches the agent intact).
Tests
New
test/429-is-a-verdict.test.mjs(same stub-gateway harness as the #690 retry test): 429-blocks-interactive, 429-real-reason-unattended, 400-verdict, 401-keeps-outage-posture, 503-keeps-outage-posture. Verified red on the unfixed hook (3/5 fail); full suite 66/66 green with the fix.Refs gatewaystack-connect#718, gatewaystack-connect#719, gatewaystack-connect#553.
🤖 Generated with Claude Code