Skip to content

Feat/inflight tracking - #128

Merged
yogthos merged 2 commits into
mainfrom
feat/inflight-tracking
May 25, 2026
Merged

Feat/inflight tracking#128
yogthos merged 2 commits into
mainfrom
feat/inflight-tracking

Conversation

@yogthos

@yogthos yogthos commented May 25, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

Yogthos added 2 commits May 24, 2026 23:44
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.
Faithful port of DeepSeek-Reasonix src/core/inflight.ts (52 LOC).

InflightSet: authoritative running-id tracker. Thread-safe
(Mutex<HashSet<String>>). Cards derive spinner state from
inflight.has(call_id) instead of trusting end-event delivery.

- Loop creates InflightSet at run_loop start (Reasonix loop.ts:147)
- Sequential dispatch: inflight.add after ToolExecutionStart,
  inflight.delete after tool_result_message — finally-contract
- Parallel dispatch: inflight.add at preflight, inflight.delete
  inline for Immediate path and in spawned future for Prepared
- execute_tool_calls umbrella passes inflight through to children

Tests: 8 tests ported from Reasonix tests/inflight.test.ts.
All 198 agent_loop tests pass. Build + fmt clean.
@yogthos
yogthos merged commit b32abd6 into main May 25, 2026
1 check passed
allen-munsch pushed a commit to allen-munsch/dirge that referenced this pull request Jun 3, 2026
Merge feat/inflight-tracking with conflict resolution.
Fixes applied:
- inflight.rs: replace unwrap() with poison-safe lock handling
- tools.rs: move inflight.add() inside Prepared arm only, avoiding
  wasteful add-then-immediate-delete for Immediate outcomes
- run.rs: wire inflight through execute_tool_calls_with to both
  sequential and parallel dispatch paths, remove dead import
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant