Skip to content

fix(session): sanitize interrupted tool calls on transport error (#51117) - #52684

Closed
JerryLiu369 wants to merge 1 commit into
anomalyco:devfrom
JerryLiu369:fix/51117-autofix
Closed

JerryLiu369 wants to merge 1 commit into
anomalyco:devfrom
JerryLiu369:fix/51117-autofix

Conversation

@JerryLiu369

@JerryLiu369 JerryLiu369 commented Oct 2, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #51117

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When a tool call is interrupted mid-stream (e.g. by a provider transport decode error), the partial tool item in history was left un-settled without a paired tool result. On subsequent turns/drains, converting session messages to LLM request format either failed schema validation or produced dangling tool calls without corresponding tool results, permanently bricking the session.

  1. publish-llm-event.ts:
    • In failAssistant, immediately publish SessionEvent.Tool.Failed for any uncalled/unsettled tools so that incomplete tool calls interrupted mid-stream do not linger as pending and poison future session drains.
  2. to-llm-message.ts:
    • In toolResult, ensure that any incomplete tool calls (pending/running) that never reached durable settlement synthesize a paired error result (ToolResultPart.make) so every tool call is guaranteed to have a corresponding tool result.

How did you verify your code works?

  • Ran bun test on affected test suites:
    • Updated session-runner-message.test.ts and session-runner.test.ts to reflect proper partial flush and paired tool results on failure.
    • Added session-transport-poison.test.ts unit tests covering interrupted/transport-error tool sanitization across models.

Screenshots / recordings

N/A (session transport and tool call settlement bugfix)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Oct 2, 2026
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Oct 2, 2026
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@thdxr

thdxr commented Oct 10, 2026

Copy link
Copy Markdown
Member

This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2.

— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

@thdxr thdxr closed this Oct 10, 2026
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.

[server]: provider transport decode error during tool call permanently poisons session "Schema validation failed"

2 participants