Commit aabb8db
Yogthos
feat(agent): phase 4 — scavenge tool calls from reasoning content
Faithful port of DeepSeek-Reasonix src/repair/scavenge.ts (201 LOC).
ScavengeToolCalls scans reasoning_content for tool calls the model
forgot to emit in the structured tool_calls field. Three patterns:
1. DSML invoke blocks (<|DSML|invoke name="tool">...</>)
with full-width-pipe (U+FF5C) and ASCII pipe variants
2. Raw JSON objects: {name, arguments}
OpenAI-style: {type:"function", function:{name,arguments}}
R1 free-form: {tool_name, tool_args}
3. Deduplication by (name, args) signature prevents double-counting
Integration: after extracting declared tool calls, the loop scans
reasoning content (Thinking blocks) + assistant text (Text blocks),
calls scavenge_tool_calls with the context's tool names as the
allowlist, and merges novel calls. Port of repair/index.ts:65-85.
Safety: 100KB input cap, max-calls=4 cap, allowed-names gate.
Tests: 13 tests ported from Reasonix tests/repair/scavenge.test.ts.
All 190 agent_loop tests pass. Build + fmt + clippy clean.1 parent 714a29a commit aabb8db
3 files changed
Lines changed: 525 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
260 | | - | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
261 | 331 | | |
262 | 332 | | |
263 | 333 | | |
| |||
0 commit comments