Skip to content

feat(session): emit message.part.delta for tool-input-delta events#28815

Open
lexlian wants to merge 3 commits into
anomalyco:devfrom
lexlian:fix/tool-input-delta-emit-part-delta
Open

feat(session): emit message.part.delta for tool-input-delta events#28815
lexlian wants to merge 3 commits into
anomalyco:devfrom
lexlian:fix/tool-input-delta-emit-part-delta

Conversation

@lexlian
Copy link
Copy Markdown

@lexlian lexlian commented May 22, 2026

Issue for this PR

Closes #28800

Type of change

  • New feature

What does this PR do?

Replaced the no-op tool-input-delta handler in packages/opencode/src/session/processor.ts with the established delta pattern (mirrors the existing reasoning-delta handler).

The tool-input-delta case was silently dropping streaming tool argument fragments. The comment claimed state.raw had no consumer, but it is actually read by:

  • session-context-breakdown.ts — token counting via part.state.raw.length
  • subagent-data.ts — serializes part.state.raw
  • export.ts — includes part.state.raw in export output

Changes:

  • Accumulate delta text into part.state.raw (guarded to pending status)
  • Emit session.updatePartDelta with field: "raw" so downstream consumers receive real-time updates
  • Exported role, toolStartLine, toolArgsLine, finishLine from test helpers to enable tool streaming tests

How did you verify your code works?

  • Added test in test/session/processor-effect.test.ts: tool argument streaming accumulates into state.raw
  • bun typecheck passes (15/15 packages)
  • bun test ./test/session/processor-effect.test.ts passes (14/14)

Screenshots / recordings

N/A — internal session event behavior change.

Checklist

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

Closes anomalyco#28800

The tool-input-delta case was a no-op with a comment claiming there was
no consumer for state.raw. In reality, state.raw is consumed by the
context breakdown component (token counting), subagent data serialization,
and export output. This change follows the established reasoning-delta
pattern: accumulate delta text into state.raw and emit updatePartDelta
so downstream consumers receive real-time tool argument streaming events.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label May 22, 2026
@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 two potentially related PRs that address similar tool streaming/delta event functionality:

Potential Related PRs:

  1. PR #26678feat: stream tool call inputs in real time

    • Related because it also addresses streaming tool inputs in real-time, which is directly relevant to the tool-input-delta handling.
  2. PR #25245feat(processor): add plugin stream hooks for tool streaming lifecycle

    • Related because it adds streaming hooks for tool processing, which may overlap with the delta event emission for tool inputs.

However, PR #28815 is the current PR, so it shouldn't be marked as a duplicate of itself. These two PRs above appear to address related but distinct aspects of tool streaming and should be reviewed to ensure there's no conflicting work or opportunity to consolidate the implementation.

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

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

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.

[FEATURE]: Emit message.part.delta for tool-input-delta events

1 participant