Skip to content

fix(core): include a running tool's progress metadata when reading messages - #64929

Merged
jlongster merged 2 commits into
devfrom
live-tool-metadata
Nov 19, 2026
Merged

jlongster merged 2 commits into
devfrom
live-tool-metadata

Conversation

@jlongster

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #

Type of change

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

What does this PR do?

A running tool call's progress metadata (context.progress) only reaches clients through the ephemeral session.tool.progress event; the saved part gets metadata when the call settles. So a client that opens or reloads a session mid-call reads metadata: {} from GET /api/session/:id/message and misses e.g. a foreground execute's background/toolCalls (no Ctrl+B offer, inner shells shown as background shells) or a running subagent's sessionID.

The LLM event publisher now also records the latest progress in a small process-local map (session/runner/live-tool-metadata.ts), cleared when the call settles or fails. SessionStore message reads (messages, messagesWithRefs, message, messageWithRefs) overlay it onto tool parts that are still running. No new durable events or DB writes; settled parts are untouched.

How did you verify your code works?

  • New unit test packages/core/test/session-live-tool-metadata.test.ts; bun run typecheck:tsc in core.
  • Against a live isolated opencode serve (simulated LLM): a foreground execute running tools.shell now reads back as {"status":"running","metadata":{"toolCalls":[{"tool":"shell","status":"running",...}],"background":true}} (was {}).
  • A model-based test of the background pill (tear) that pinned this as a known failure now passes when the app is held to spec: a freshly opened client offers the running script to the background.

Screenshots / recordings

N/A

Checklist

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

…ssages

User decisions:
- Fix reloads losing a running tool's progress metadata (F1) by overlaying it on message reads
User decisions:
- Address review issues on the F1 fix
@jlongster
jlongster enabled auto-merge (squash) November 19, 2026 18:09
@jlongster
jlongster disabled auto-merge November 19, 2026 18:09
@jlongster
jlongster enabled auto-merge (squash) November 19, 2026 18:10

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix works and I found nothing that blocks it. I reproduced the problem on the base with opencode-drive and the simulated model: while an execute call running tools.shell("sleep 12") was still going, reading the session's messages returned metadata: {} for the running part. With this PR the same read returns { toolCalls: [{ tool: "shell", status: "running", … }], background: true }. The new test and the nearby store, execution and background tests pass, and typecheck:tsc in core is clean.

The map is cleared on every way a call settles (success, failure and bulk failure), and the overlay only touches parts that are still running, so settled parts are unchanged.

Public API: no endpoints, fields or events are added or removed. Message reads now return the same progress metadata for a running tool part that the session.tool.progress event already carries (backwards compatible).

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new commit is a refactor and doesn't change behaviour. The module now exports itself as LiveToolMetadata, overlay uses the real SessionMessage types instead of loose casts, and the test builds real SessionMessage.Assistant values. I re-ran the mid-call read with opencode-drive and the simulated model: the running execute part still comes back with its toolCalls and background metadata. The tests and typecheck:tsc in core pass. Public API: unchanged. No new concerns.

@jlongster
jlongster merged commit 9995279 into dev Nov 19, 2026
10 checks passed
@jlongster
jlongster deleted the live-tool-metadata branch November 19, 2026 18:13
@amrkmn amrkmn mentioned this pull request Nov 23, 2026
1 task
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