Commit b95e101
Fix ContextWindowExceededError after 3 retries in react loop (#9110)
* Initial plan
* Fix ContextWindowExceededError after 3 retries in react loop
When _call_with_potential_trajectory_truncation exhausts all retry
attempts, it now raises a clear ValueError instead of returning None.
This prevents the AttributeError: 'NoneType' object has no attribute
'next_thought' that occurred when accessing properties on the None
return value.
The ValueError is caught in forward/aforward and causes the loop to
break gracefully, allowing the extract phase to proceed with whatever
trajectory was collected.
Added tests for both sync and async versions of this scenario.
Co-authored-by: TomeHirata <33407409+TomeHirata@users.noreply.github.com>
* Address code review feedback: Fix comments and error messages
Co-authored-by: TomeHirata <33407409+TomeHirata@users.noreply.github.com>
* Remove unnecessary try-catch around truncate_trajectory
Co-authored-by: TomeHirata <33407409+TomeHirata@users.noreply.github.com>
* Remove docstrings from test functions
Co-authored-by: TomeHirata <33407409+TomeHirata@users.noreply.github.com>
* Combine sync and async context window tests into one test
Co-authored-by: TomeHirata <33407409+TomeHirata@users.noreply.github.com>
* Verify inputs passed to extract in test
Co-authored-by: TomeHirata <33407409+TomeHirata@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: TomeHirata <33407409+TomeHirata@users.noreply.github.com>1 parent f4a016e commit b95e101
2 files changed
+54
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
156 | 159 | | |
157 | 160 | | |
158 | 161 | | |
| |||
164 | 167 | | |
165 | 168 | | |
166 | 169 | | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
167 | 173 | | |
168 | 174 | | |
169 | 175 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
207 | 255 | | |
208 | 256 | | |
209 | 257 | | |
| |||
0 commit comments