Skip to content

🤖 fix: turn.end gets pre-tool text when a turn ends on a tool part #6067

Closed as not planned

Description

@ThomasK33

Problem

turn.end gets the finished turn's last reply text. When an assistant writes text, then calls a tool, and the turn ends (or is stopped) on that tool part with no text after it, the hook gets the pre-tool text ("Let me check ..."). The function's own contract says text before a later tool call is an intermediate step, not the reply.

Found by Codex review round 6 on #6042.

Fix

Return only a trailing text run. If the last part is not text, send text: null. Add tests for a turn that ends on a tool part, both completed and interrupted.


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

Activity

  1. self-assigned this
    on Oct 10, 2026
  2. ThomasK33 commented on Oct 19, 2026

    @ThomasK33
    MemberAuthor

    The turn.end hook from #6042 was closed without merging, so the bug it named no longer exists on main. The fix is on the turn.stop hook from #6148, where lastAssistantText returns only a trailing text run and null when the turn ends on a tool part, with a test for that case.

    Closing after a backlog triage pass: one agent found this done or no longer applicable on main (0cb3327), a second agent tried to disprove that and could not, and I checked the cited PRs' dates against this issue. Reopen if anything here is still broken.


    Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: xhigh • Cost: $16.25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions