Commit Graph

6 Commits

Author SHA1 Message Date
Sina Nejati
56701152a8 fix: prevent orphan tool_result errors from streaming failures
When a streaming error occurs mid-tool-call (e.g., JSON parse error),
the tool call gets recorded with `partialJson` and `stopReason: "error"`.
Previously, the transcript repair function would insert synthetic
tool_results for these incomplete tool calls, but the API rejected them
as orphans because the original tool_use block was malformed.

This fix:
1. Adds `stripIncompleteToolCalls()` to filter out tool calls with
   `partialJson` from assistant messages that have `stopReason: "error"`
2. Updates `extractToolCallsFromAssistant()` to skip any tool call
   block that has `partialJson` property

Now when a streaming error happens mid-tool-call:
- The incomplete tool call is stripped from the message
- No synthetic tool_result is inserted for it
- The API request remains valid

Fixes issue where sessions became permanently broken after a single
streaming error, requiring manual session file deletion to recover.
2026-01-27 20:18:23 -08:00
Peter Steinberger
6d16a658e5 refactor: rename clawdbot to moltbot with legacy compat 2026-01-27 12:21:02 +00:00
Peter Steinberger
c379191f80 chore: migrate to oxlint and oxfmt
Co-authored-by: Christoph Nakazawa <christoph.pojer@gmail.com>
2026-01-14 15:02:19 +00:00
Peter Steinberger
f5d5661adf fix: guard session tool results 2026-01-12 17:28:46 +00:00
Peter Steinberger
6668805aca fix(agents): enforce single-writer session files 2026-01-11 02:25:45 +00:00
Peter Steinberger
08cc8f2281 refactor(agents): extract transcript repair module 2026-01-10 22:07:25 +00:00