Learn then Bet: Learning Interpretable Rules for Reliable Agent Intervention
Organizations: Amazon · Yale University
Abstract
Autonomous agents now run for hundreds of steps with little or no human supervision. In practice, practitioners use runtime monitors such as turn limits and keyword filters to decide when a run should be stopped, upgraded, or assisted. However, these heuristics may stop runs that would otherwise succeed or allow failing runs to continue. To address this limitation, we introduce LeBet (Learn then Bet), a statistical learning framework that derives its learning objective from sufficient conditions for valid and powerful intervention. In particular, LeBet learns an interpretable OR-of-AND monitor and accumulates evidence through a fixed betting statistic, intervening when the evidence reaches a prescribed threshold. Under finite within-class exchangeability and leave-one-out stability, we derive finite-sample guarantees for false-positive control (validity) and detection power conditional on the training data, using the same trajectories for learning and calibration without assuming independent and identically distributed trajectories. To address the intractable combinatorial optimization problem in our learning formulation, we use stochastic local search that leverages the monitor's Boolean structure to propose rule edits aimed at improving empirical separation. On SWE-bench Lite with Ministral 3 8B, the learned monitor saves of input-plus-output tokens and increases output precision from to . The empirical false-positive rate is . Our results show how to formalize the learning problem over interpretable rule sets with statistical conditions and establish training-conditional guarantees for reliable intervention based on partial histories.
Figures & tables
| Split | TP | FP | TN | FN | Stop prec. | FPR | TPR | Output prec. | Tokens saved |
|---|---|---|---|---|---|---|---|---|---|
| Train | 46 | 1 | 33 | 100 | 97.87 | 2.94 | 31.51 | 24.81 | 38.80 |
| Eval | 29 | 3 | 19 | 69 | 90.62 | 13.64 | 29.59 | 21.59 | 34.46 |
| Eval (no early stop) | 0 | 0 | 22 | 98 | – | 0.00 | 0.00 | 18.33 | 0.00 |
Appendix figures & tables13 assets
Supplementary material from the paper’s appendix.
Appendix
| Symbol | Brief meaning | Additional details |
|---|---|---|
| ; | Sample sizes | Fixed training and extension counts in class ; , . The next trajectory is separate. See Section 3 . |
| Monitoring endpoints | Earliest intervention time and maximum execution horizon, with . See Section 4 . | |
| Monitor capacities | Predicate count, maximum predicates per rule, and maximum rules per monitor. See Section 4 . | |
| Comparison levels | Population levels in Section 4 ; is also the fixed betting reference in Section 5 . | |
| Chosen betting reference | Reference used by and in Proposition 3 ; describe the conditional-mean bounds. | |
| Betting parameters | Positive stake and betting error budget; intervention requires evidence at least . See equation 2 . |
| Symbol | Brief meaning | Additional details |
|---|---|---|
| Integer index sets | and , respectively. See Section 2 . | |
| Interaction spaces | Space of single interactions and class- subset . See Section 3 . | |
| Joint sample space | , including the next interaction. See Section 3 . | |
| Information structures | Ambient and time- -algebras, and the -algebra generated by . See Section 2 . | |
| History spaces | Histories of length and all finite histories, with . See Section 3 . | |
| Interaction component spaces | Spaces of reasoning traces, tool-call actions, and observations, respectively, in Section 3 . |
| Pattern | Observable signals | Example candidate rule |
|---|---|---|
| Tool failures | Error status, nonzero exit code, consecutive errors, or recent error fraction. | Three consecutive tool calls fail. |
| Repeated actions | Recurrence of the same tool name and input, with or without a failed result. | The current action fails and has occurred at least three times. |
| Edit–test cycles | Counts of edit calls, repeated edits to one file, and failed test or reproduction commands. | At least three matching commands have failed, and the current call edits a file for at least the fourth time. |
| Lack of edits | No edit by a given step, or many calls since the last edit. | At step 60 or later, no edit has occurred. |
| Resource use | Tool-call count, output tokens per model turn, and cumulative output tokens. | At least 120 tool calls and more than 20,000 output tokens have been used. |
| Reported difficulty | Fixed text patterns indicating difficulty, such as “stuck” or “confused.” | A difficulty pattern matches and the current test or reproduction command fails. |
| Construction | Meaning | Example |
|---|---|---|
| Lag | Evaluate a predicate at an earlier observed step. | A difficulty pattern matched eight steps ago. |
| Cumulative count | Threshold the event count through the current or a lagged step. | At least three edits occurred through step . |
| Initial-segment count | Count events in the first fixed number of steps, using the available prefix. | At least two errors occur in the first steps. |
| Recent-window count | Require at least or at most a given count in a window, possibly ending at a lagged step. | At least eight repeated failed actions occur in the last 50 steps. |
| Available-history count | Allow a recent window to use fewer steps before its full length is available. | At least two repeated failed actions occur in the latest five observed steps. |
| Unresolved failures | Count failed attempts for one action or distinct failed actions until a matching success; optionally expire old failures. | At least three failed attempts of the same action remain unresolved. |
| Rules | ||||||
|---|---|---|---|---|---|---|
| 13 | Track ordering constraints across media lists. | Edit : replace the merge method. | Rejected: file_path is missing. | 1 | 2.28 | 5, 6 |
| 14 | Track all ordering constraints. | Edit : update the merge method. | File updated. | 1 | 2.43 | 6 |
| 17 | Try a different approach. | Retry Edit with the file path. | Source string not found. | 1 | 2.94 | 6, 7 |
| 21 | Try a different approach. | Read : inspect the merge method. | Code now tracks ordering constraints. | 1 | 3.79 | 7 |
| 32 | Try a different approach. | Repeat the same Edit . | Source string not found. | 1 | 7.61 | 2, 7 |
| 73 | Try a different approach. | Repeat the same Edit . | Source string not found. | 1 | 102.57 | 2, 7 |
| Rules | ||||||
|---|---|---|---|---|---|---|
| 12 | Check the current behavior. | Bash : run the reproduction script. | Django settings are not configured. | 1 | 2.14 | 4, 5, 6 |
| 18 | — | Bash : rerun the reproduction script. | Temporary uploads use 0o600 ; memory uploads use 0o644 . | 1 | 3.13 | 5, 6, 7 |
| 19 | Use a consistent default permission. | Edit : set upload permissions to 0o644 . | Settings file updated. | 1 | 3.34 | 5, 6, 7 |
| 28 | — | Bash : run the settings test. | Both upload types use 0o644 ; cleanup raises an exception. | 1 | 5.91 | 6, 7 |
| 32 | Run tests with unittest . | Bash : discover storage tests. | Tests fail: settings are not configured. | 1 | 7.61 | 6, 7 |
| 73 | Check collectstatic documentation. | Grep : search command documentation. | No files found. | 1 | 102.57 | 6, 7 |
| Rules | ||||||
|---|---|---|---|---|---|---|
| 4 | Examine the migration. | Read : inspect the migration file. | Code updates proxy model permissions. | 1 | 1.29 | 4, 5, 6 |
| 19 | Reproduce the migration error. | Write : create a reproduction script. | File created. | 1 | 3.34 | 5, 6, 7 |
| 26 | Run the test script. | Bash : run the reproduction script. | Django settings are not configured. | 1 | 5.20 | 3, 5 |
| 30 | Simplify the migration test. | Write : replace the reproduction script. | File created. | 0 | 4.83 | — |
| 37 | Simplify the migration test. | Write : replace the reproduction script. | File created. | 1 | 1.06 | 7 |
| 72 | Simplify the migration test. | Write : replace the reproduction script. | File created. | 1 | 9.72 | 7 |
| Rules | ||||||
|---|---|---|---|---|---|---|
| 30 | — | Bash : run the reproduction script. | Empty matrix succeeds; empty array raises an unpacking error. | 1 | 6.71 | 5 |
| 34 | Test again. | Bash : run the reproduction script. | Empty matrix and array tests succeed. | 1 | 8.64 | 5 |
| 40 | Test again. | Bash : test edge cases. | Zero-sized multidimensional arrays raise division errors. | 1 | 12.65 | 5 |
| 41 | Handle zero-sized arrays. | Edit : update array bounds checks. | File updated. | 0 | 9.71 | — |
| 59 | Handle zero-sized arrays. | Edit : modify array creation. | Rejected: new_string is missing. | 1 | 0.12 | 3 |
| 122 | Try a different approach. | Edit : modify array creation. | Source string not found. | 1 | 2.36 | 2 |
| Edit | Conditions | Proposed rule set | Effect |
|---|---|---|---|
| Add AND predicate | |||
| Delete rule | |||
| Add singleton OR | |||
| Remove AND predicate |
AI Agent Monitoring
AI agent monitoring tracks actions, tool use, and execution traces to detect failures, misuse, drift, and policy violations during operation.
See all 300 papers