perf(shell): keep small external replay inline - #671
Open
beruro wants to merge 1 commit into
Open
Conversation
beruro
force-pushed
the
junyu/external-shell-inline-replay
branch
from
August 4, 2026 05:26
5368772 to
b054d51
Compare
beruro
marked this pull request as ready for review
August 4, 2026 05:28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Completed external-provider shell events always create a
.slogartifact 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 interminal_previewand reports zero range-readable bytes because no backing artifact exists. Outputs above the threshold continue through the existing framed.slogand SQLite path without behavior changes.Potential risks
Consumers must interpret a complete state with zero
visible_bytesas preview-only rather than attempting a range read. Existing bounded display usesterminal_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.mdrecords 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 2021on the changed Rust file — passed.git diff --cached --checkbefore commit — passed.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.