Skip to content

fix: wait for tool results before processor cleanup#27850

Closed
eatFirewood wants to merge 1 commit into
anomalyco:devfrom
eatFirewood:fix/wait-tool-results-before-cleanup
Closed

fix: wait for tool results before processor cleanup#27850
eatFirewood wants to merge 1 commit into
anomalyco:devfrom
eatFirewood:fix/wait-tool-results-before-cleanup

Conversation

@eatFirewood
Copy link
Copy Markdown

Summary

  • Wait for pending tool calls to settle during normal session processor cleanup instead of marking them aborted after 250ms.
  • Keep the fast abort path for interrupted runs so user cancellation still marks remaining tool calls as interrupted.
  • Add a regression test where the LLM stream finishes before a delayed tool result is committed.

Motivation

This addresses a race where long-running tools, especially task/subagent tools, can still be resolving after the model stream finishes. The previous 250ms cleanup grace period could mark those calls as Tool execution aborted and let the parent session continue before the tool result was recorded.

Related reports: #23404, #21250.

Test plan

  • bun test test/session/processor-effect.test.ts
  • bun run typecheck

@github-actions
Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label May 16, 2026
@github-actions
Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions
Copy link
Copy Markdown
Contributor

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

Based on my search, I found one potentially related PR:

Related PR:

This PR appears to be in the same domain (session processor and tool handling), though it focuses specifically on orphaned interrupted tools rather than pending tool results timing. It may provide context or have related logic worth reviewing.

All other searches returned only the current PR (#27850) itself. No exact duplicates found.

@github-actions
Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label May 16, 2026
@github-actions github-actions Bot closed this May 16, 2026
@eatFirewood eatFirewood deleted the fix/wait-tool-results-before-cleanup branch May 16, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant