Repository navigation
Commit a266d02
committed
fix(opencode): recover from truncated tool calls instead of failing silently
When a model's output hits the token limit mid-tool-call, the JSON
arguments are truncated and tool parsing fails with 'expected string,
received undefined'. Two fixes:
1. experimental_repairToolCall now detects truncation: when the tool
name is a valid registered tool but args failed to parse, return an
actionable error telling the model to split its operation into
smaller pieces. Previously all parse failures were routed to a
generic 'invalid tool' handler with no recovery guidance.
2. The session loop now handles finishReason 'length': instead of
silently exiting when the model is cut off by the token limit,
inject a synthetic continuation message so the model can resume
where it left off.
Fixes anomalyco#18108
Fixes anomalyco#17471
Refs anomalyco#14519, anomalyco#131021 parent 46f243f commit a266d02
2 files changed
Lines changed: 51 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
329 | 329 | | |
330 | 330 | | |
331 | 331 | | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
332 | 354 | | |
333 | 355 | | |
334 | 356 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1376 | 1376 | | |
1377 | 1377 | | |
1378 | 1378 | | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
1379 | 1408 | | |
1380 | 1409 | | |
1381 | 1410 | | |
| |||
0 commit comments