feat(detection): add opt-in structured triage contract - #135
Merged
barisozbas merged 3 commits intoSep 23, 2026
Merged
Conversation
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
This PR implements the second part of the maintainer's recommended plan in uber/ADR#50: S — structured triage option, following the P2 import-following source-coverage fix.
Add an opt-in structured Tier-1 routing contract while retaining stock text triage as the default, preserving existing behavior when disabled and escalating on invalid structured output.
What changed
decision_contract: structured_risk_route_v1underadr_framework.triage_llm. Omitting it preserves stock triage; invalid contract names fail explicitly.BENIGN_EXIT/ESCALATE, scenario/component risk, injection, unsafe plan/action/effect, authorization, provenance-needed, and evidence fields.structured_triageresult field and a per-task debug artifact, before Tier 2 runs. Preserve the artifact even if Tier 2 fails; an audit-write failure does not block escalation.Enable
The stock
to_dict()output key set remains unchanged. Opted-in structured results addstructured_triage; consumers enforcing an exact JSON schema must accept that optional field. Direct dataclass serialization also exposes the new field when it isNone.Validation
Evaluation results
Luna low at both tiers,
store:false. Final pipeline results:On AgentDojo, structured triage reduced benign escalations from 41 to 9 and Tier-2 tasks from 79 to 47, retaining all 38 malicious detections. Five structured responses exceeded the evidence-item limit and safely escalated; all five received correct final decisions.
ADR-Bench uses a frozen stock reference and frozen Tier-1 outputs with fresh structured Tier-2 calls; the structured implementation matches this branch. AgentDojo is a fresh paired run on the existing evaluated subset. These are separate development evaluations, not a single matched experiment or proof of generalization. Hosted calls use the Responses evaluation harness with product prompts, parsers, and handoffs, rather than the production Claude CLI transport.