Commit 0184d8d
committed
session: classify litellm exceptions raised inside user callables
The rollout isolation in the previous commit converts target-side
LLMInputError into a recorded transcript event with
stop_reason="target_input_refused". It only fires when the exception
reaches the rollout helpers as an already-classified LLM error class.
For callable: targets (LangGraph agents, framework wrappers, raw
litellm callers, etc.) the user's own code makes the provider calls
and bypasses generate()/_with_retries entirely, so provider errors
bubble up as raw litellm exceptions (BadRequestError,
ContentPolicyViolationError, RateLimitError, ...). The rollout's
isinstance(_, LLMInputError) checks miss them and the stage aborts on
the first content-filter rejection \u2014 the same failure pattern the
isolation was supposed to fix.
Fix CallableSession.run_turn so any exception escaping invoke_callable
is passed through _classify_llm_error before propagating. Classified
errors are re-raised with __cause__ preserved; unclassified errors
(user agent crashes, ValueError from misconfigured tools, etc.) pass
through unchanged so they don't get smuggled into one of the four LLM
error classes.
Tests:
- test_run_turn_reclassifies_litellm_bad_request_as_input_error: a
fake litellm BadRequestError raised from inside the user callable
emerges as LLMInputError with cause preserved.
- test_run_turn_passes_through_unclassified_exceptions: a custom
RuntimeError from inside the user callable propagates as itself,
not as any LLM*Error class.
All 50 rollout + exception-handling tests pass. Local smoke against
azure/gpt-5.4-mini with the LangGraph travel-planner callable
(30 prompts + 10 scenarios, C=4) completed end-to-end in 176.9s.1 parent 82cf339 commit 0184d8d
2 files changed
Lines changed: 98 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
512 | 513 | | |
513 | 514 | | |
514 | 515 | | |
515 | | - | |
516 | | - | |
517 | | - | |
518 | | - | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
519 | 534 | | |
520 | | - | |
521 | | - | |
522 | | - | |
523 | | - | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
524 | 545 | | |
525 | 546 | | |
526 | 547 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
126 | 195 | | |
127 | 196 | | |
128 | 197 | | |
| |||
0 commit comments