Skip to content

fix: make tool progress live-only - #38217

Merged
kitlangton merged 3 commits into
v2from
tool-progress-live
Jul 22, 2026
Merged

kitlangton merged 3 commits into
v2from
tool-progress-live

Conversation

@kitlangton

@kitlangton kitlangton commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

What

Make running tool progress a live replacement snapshot instead of durable session history, suppress unchanged shell snapshots, and preserve useful partial output when a tool fails.

The deterministic shell fixture (printf steady; sleep 3.4) improves from:

Metric Before After Change
Progress callbacks (median, 7 runs) 3 1 -66.7%
Progress text bytes (median, 7 runs) 18 6 -66.7%
MAD 0 0 stable

This proves deterministic work removal; it does not claim an exact CPU-time reduction.

Before / After

Before

  1. Shell polled cumulative output every second and published the same snapshot even when output had not changed.
  2. Every progress snapshot became a durable session.tool.progress.1 row and was projected, synchronized, and replayed.

After

  1. Shell publishes only when its output or truncation state changes.
  2. Running progress is ephemeral and replace-style; only called/success/failed remain durable.
  3. Existing durable progress rows are deleted without changing aggregate sequence watermarks; sequence gaps remain valid.
  4. The runner retains the latest progress snapshot in memory. If the tool fails, its durable failure includes non-empty partial content and progress metadata; both fields are omitted when no progress occurred.
  5. Existing reducers temporarily project failure metadata into the current state.structured field, so replayed and reconnected failures retain useful partial state.

How

  • packages/schema/src/session-event.ts makes SessionEvent.Tool.Progress ephemeral.
  • packages/schema/src/session-event.ts gives failures optional non-empty content and optional progress metadata without changing the terminal error outcome.
  • packages/core/src/session/runner/publish-llm-event.ts retains the latest snapshot in memory and attaches it to each failure path when present.
  • packages/core/src/tool/shell.ts suppresses exact duplicate { output, truncated } snapshots.
  • Core, CLI, ACP, TUI, noninteractive, and mini-stream reducers project terminal failure snapshots while retaining their live-state fallback.
  • packages/core/src/database/migration/20260722011141_delete_tool_progress_events.ts deletes obsolete session.tool.progress.1 rows and deliberately leaves event_sequence unchanged.
  • packages/client/src/promise/generated/types.ts is regenerated from the current protocol.

Scope

  • Does not add process-global subscription interest scoping; that larger fan-out optimization remains separate.
  • Does not add cursor-based shell reads; shell still polls cumulative output from offset zero.
  • Does not periodically re-emit unchanged running progress after reconnect.
  • Does not introduce a larger settlement union, remove result, rename projected state, or redesign void output.
  • Accepts removal of obsolete progress payloads from raw historical event reconstruction. Existing projections are not deleted.
  • Does not include the repository-wide stale OpenAPI snapshot refresh or legacy combined SDK regeneration; those produce unrelated baseline churn on the V2-only branch.

Testing

  • cd packages/core && bun test test/database-migration.test.ts test/session-runner-tool-events.test.ts test/session-runner.test.ts test/session-tool-progress.test.ts test/tool-shell.test.ts --only-failures (passed)
  • cd packages/tui && bun test test/mini/stream-v2.transport.test.ts test/cli/tui/data.test.tsx --only-failures (87 passed)
  • cd packages/cli && bun test test/acp/event-behavior.test.ts test/run/noninteractive.test.ts --only-failures (18 passed)
  • cd packages/client && bun run test (43 passed)
  • cd packages/schema && bun test test/event-manifest.test.ts --only-failures (6 passed)
  • cd packages/core && bun run script/migration.ts --check (passed)
  • Push hook bun turbo typecheck --concurrency=3 passed in all 33 applicable packages.
  • git diff --check passed.
  • bun run lint exits nonzero on repository-wide baseline warnings; no changed production file introduced a lint diagnostic.

Flow

sequenceDiagram
  participant Tool
  participant Runner
  participant Live as Live subscribers
  participant Log as Durable event log

  Tool->>Runner: progress(snapshot)
  Runner->>Runner: retain latest snapshot
  Runner-->>Live: session.tool.progress
  Note over Live,Log: progress is not persisted
  Tool->>Runner: failure
  Runner->>Log: durable error + optional partial snapshot
  Log-->>Live: replayable failure
Loading

@kitlangton
kitlangton force-pushed the tool-progress-live branch from 4f253c8 to bd9d07c Compare July 22, 2026 13:04
@kitlangton
kitlangton merged commit 5a9ed4d into v2 Jul 22, 2026
10 checks passed
@kitlangton
kitlangton deleted the tool-progress-live branch July 22, 2026 14:40
jinhuang712 pushed a commit to jinhuang712/opencode that referenced this pull request Sep 26, 2026
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