fix(tools): scale adversarial policy timeout by provider type#5881
Merged
Conversation
bug-ops
enabled auto-merge (squash)
July 10, 2026 16:27
bug-ops
force-pushed
the
fix/5870-policy-gate-timeout
branch
from
July 10, 2026 16:27
84b0aa4 to
3ee177e
Compare
The fail-closed adversarial policy gate used a fixed 3s default timeout for the policy LLM call, well below the 9-32s latency of local Ollama providers. Every policy check timed out and was denied as PolicyDecision::Error, which fail_open=false treats identically to a genuine deny, producing a 100% deny rate on benign tool calls when policy_provider pointed at a local model. timeout_ms is now optional and auto-scales from the resolved policy_provider's kind: 45s for local providers (ollama, candle, compatible), 3s for cloud providers, with headroom above the worst-case latency observed for local models. Explicit timeout_ms values still override the default. PolicyDecision::Error now carries a timed_out flag so the operator-facing audit log and tracing output can distinguish a timeout from a genuine LLM/network error; the message sent back into the main LLM's tool-call error is unchanged, preserving MED-03's opacity requirement. Also fixes the same provider-resolved-after-timeout-computed ordering bug in all three gate construction sites (runner.rs, acp.rs, daemon.rs), not just the one referenced in the issue. Closes #5870
bug-ops
force-pushed
the
fix/5870-policy-gate-timeout
branch
from
July 10, 2026 16:37
3ee177e to
b919856
Compare
This was referenced Jul 10, 2026
Closed
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
[tools.adversarial_policy]) used a fixed 3s (5s in testing.toml) timeout for the policy LLM call, well below the 9-32s latency observed with local Ollama models. Every policy check timed out, hitPolicyDecision::Error, and withfail_open = falsewas denied identically to a genuine policy violation — producing a 100% deny rate on benign tool calls wheneverpolicy_providerpointed at a local model.timeout_msis nowOption<u64>and auto-scales from the resolvedpolicy_provider's kind: 45s for local providers (ollama/candle/compatible — comfortably above the issue's own observed 31928ms worst case), 3s for cloud providers. An explicittimeout_msstill overrides the default.PolicyDecision::Errornow carries atimed_outflag so the operator-facing audit log / tracing output can distinguish an infra timeout from a genuine LLM/network error. The message returned to the main LLM's tool-call error is unchanged, preserving the MED-03 opacity requirement (the main LLM cannot tell timeout apart from a real deny).runner.rs,acp.rs,daemon.rs) — the issue referenced onlyrunner.rs./status'sAdv gate:line now also shows the effectivetimeout_ms.timeout_msexplicitly.Test plan
cargo +nightly fmt --checkcargo clippy --profile ci --workspace --all-targets --features "desktop,ide,server,chat,pdf,scheduler,testing" -- -D warningscargo nextest run --config-file .github/nextest.toml --workspace --features "desktop,ide,server,chat,pdf,scheduler" --lib --bins(12443 passed / 0 failed)RUSTFLAGS="-D warnings" RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links" cargo doc --no-deps --workspace --features "desktop,ide,server,chat,pdf,scheduler"cargo test --doc --workspace --features "desktop,ide,server,chat,pdf,scheduler"timed_outset correctly on timeout vs. genuine LLM error, MED-03 exact-message invariant on both branches, all three gate-construction sites verified for correct provider-before-timeout ordering