Repository navigation
feat(guardrails): configurable check timeout, default 60 s - #29
Open
vrajp-lyzr wants to merge 1 commit into
Open
vrajp-lyzr wants to merge 1 commit into
vrajp-lyzr wants to merge 1 commit into
Conversation
ComputerAgent(guardrails_timeout_s=...), else COMPUTER_AGENT_GUARDRAILS_TIMEOUT_S, else 60 s (was a fixed 5 s). It bounds the input check and every tool-call check. A policy with slow checks (several seconds per call) failed closed with 'guardrails unreachable: ReadTimeout'. On claude-agent-sdk the policy PreToolUse hook's CLI budget is the timeout plus 30 s (the CLI default is 60 s), carried by EngineContext.policy_timeout_s, so the check's own timeout still decides.
This branch has not been deployed
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.
A policy with slow checks (e.g. a banned-topics list: ~3.4 s per tool call, over 5 s per message) hit the fixed 5 s guardrails timeout. The check then failed closed with
guardrails unreachable: ReadTimeout, which denied the tool or blocked the message.Setting:
ComputerAgent(guardrails_timeout_s=…)>COMPUTER_AGENT_GUARDRAILS_TIMEOUT_S> 60 s (was 5 s). Anything but a positive number is aSettingsError. It bounds the input check (SrsTurnGuard) and every tool-call check (SrsToolGate).Claude hook budget: on
claude-agent-sdkthe tool check runs inside aPreToolUsehook, and the CLI's default hook budget is 60 s. With a 60 s check the CLI could give up first, and its outcome is not the SDK's deny. The hook budget is now the check timeout + 30 s, carried by a new optionalEngineContext.policy_timeout_s.Tests:
ENV_VARSand missing-settings tests updated for the new optional setting.Full suite: 695 passed, 1 skipped. ruff clean. mypy: the error set is identical to
main's.Smoke: a real
ComputerAgentagainst a guardrails server answering in 2 s. With the env var at 1 s the message is blocked after 1.0 s. With the argument at 3 s it is allowed after 2.0 s, and the argument wins over the env var.Note: the UAT agent gateway's own
SRS_TIMEOUTis 10 s, so a check slower than that still ends at the gateway, whatever the SDK allows.