Skip to content

fix: sanitize orphan tool results in continue history#183

Open
ki113r4bbi7 wants to merge 1 commit intolsdefine:mainfrom
ki113r4bbi7:fix-continue-orphan-tool-result
Open

fix: sanitize orphan tool results in continue history#183
ki113r4bbi7 wants to merge 1 commit intolsdefine:mainfrom
ki113r4bbi7:fix-continue-orphan-tool-result

Conversation

@ki113r4bbi7
Copy link
Copy Markdown

What

  • Sanitize native /continue history before restoring it.
  • Preserve orphan tool_result content as plain text instead of replaying it as a protocol tool result.
  • Keep valid tool_use / tool_result pairs unchanged.

Why

If an agent crashes while a tool call is in flight, a recovered session can contain a tool_result without the matching prior assistant tool_use. Replaying that history can make providers reject the next request with errors such as No tool call found for function_call_output.

Testing

  • python -m py_compile frontends/continue_cmd.py
  • Focused import test for _parse_native_history:
    • orphan tool_result is converted to text
    • matching tool_result remains intact

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