Skip to content

perf(shell): keep small external replay inline - #671

Open
beruro wants to merge 1 commit into
developfrom
junyu/external-shell-inline-replay
Open

perf(shell): keep small external replay inline#671
beruro wants to merge 1 commit into
developfrom
junyu/external-shell-inline-replay

Conversation

@beruro

@beruro beruro commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Problem

Completed external-provider shell events always create a .slog artifact and replay-table rows before EventStore compaction, even when the entire output already fits inside the bounded terminal preview. Turns with many small commands therefore perform redundant filesystem and SQLite work for output that does not need paging.

Solution

When the combined external shell output is no larger than SHELL_REPLAY_PREVIEW_BYTES, attach a complete inline replay state directly to the event and skip replay storage. The state keeps every output byte in terminal_preview and reports zero range-readable bytes because no backing artifact exists. Outputs above the threshold continue through the existing framed .slog and SQLite path without behavior changes.

Potential risks

Consumers must interpret a complete state with zero visible_bytes as preview-only rather than attempting a range read. Existing bounded display uses terminal_preview, and the new unit test verifies the state and absence of replay rows, but a packaged app import of a real provider transcript has not been profiled end to end. The storage invariant and large-output compatibility path are covered by targeted tests; packaged import/display smoke testing remains follow-up verification. The threshold is the existing preview limit, so memory remains bounded. Rollback is a source-only revert; no schema or stored-format migration is introduced, and existing replay artifacts remain readable.

Performance guard

docs/org2-performance-guard-2026-08-04/ExternalShellInlineReplay.md records the lifecycle/resource review. Verdict: the small path is bounded and creates no retained background state; unit coverage proves replay storage is skipped. No end-to-end speedup claim is made without a real-device I/O profile.

Verification

  • cargo test --manifest-path src-tauri/Cargo.toml -p agent_core small_external_shell_stays_complete_without_replay_storage — 1 passed.
  • cargo test --manifest-path src-tauri/Cargo.toml -p agent_core completed_external_shell_is_imported_before_eventstore_compaction — 1 passed; the existing large-output storage path remains covered.
  • cargo check --manifest-path src-tauri/Cargo.toml -p agent_core — passed.
  • rustfmt --edition 2021 on the changed Rust file — passed.
  • git diff --cached --check before commit — passed.
  • Compared the file list with current origin/develop; only the external replay implementation/test and its performance report are included.

Not run: packaged desktop import/display smoke test and real filesystem/SQLite benchmark. No visual layout changes are included, so screenshots are not useful evidence.

@beruro
beruro force-pushed the junyu/external-shell-inline-replay branch from 5368772 to b054d51 Compare August 4, 2026 05:26
@beruro
beruro marked this pull request as ready for review August 4, 2026 05:28
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.

1 participant