Skip to content

Fix: roll back conversation history after LLM hard errors#104

Merged
jamiepine merged 1 commit intospacedriveapp:voicefrom
Marenz:fix/history-rollback
Feb 21, 2026
Merged

Fix: roll back conversation history after LLM hard errors#104
jamiepine merged 1 commit intospacedriveapp:voicefrom
Marenz:fix/history-rollback

Conversation

@Marenz
Copy link
Collaborator

@Marenz Marenz commented Feb 21, 2026

When a CompletionError, ToolError, or ToolServerError occurs during an agent turn, Rig has already mutated the history Vec in-place (appending a tool-call message) before returning the error. The caller was writing that mutated history back unconditionally, leaving a dangling tool-call entry with no corresponding result.

On the next user turn the provider rejects the entire history with "tool call result does not follow tool call", making the channel permanently unresponsive until restarted.

The fix snapshots the history length before each agent call and truncates back to that point on hard errors. MaxTurnsError and PromptCancelled are unaffected — Rig carries a valid updated history in those variants, so they continue to be written back normally.

Found while testing local Whisper STT on top of #98. Claude and MiniMax were both failing with provider errors during initial model loading, which triggered the bug on every subsequent voice message.

@Marenz
Copy link
Collaborator Author

Marenz commented Feb 22, 2026

Closes #104

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.

2 participants