Skip to content

Cap in-band generator command output size (APP-4792)#13131

Draft
warp-dev-github-integration[bot] wants to merge 1 commit into
masterfrom
fix/app-4792-cap-in-band-generator-output
Draft

Cap in-band generator command output size (APP-4792)#13131
warp-dev-github-integration[bot] wants to merge 1 commit into
masterfrom
fix/app-4792-cap-in-band-generator-output

Conversation

@warp-dev-github-integration

Copy link
Copy Markdown
Contributor

Description

In-band generator commands (completions, syntax highlighting, prompt context chips) capture their entire stdout/stderr into a CommandOutput with no size cap. A misbehaving or very chatty generator therefore buffers its full output into a Vec<u8> that stays alive on the generator's pending future.

Heap profiles from the recurring "Excessive memory usage detected" alert (Sentry 7259255054) show ~8.8 GB live heap, with ~7.4 GB (78.6%) retained on the CurrentPrompt context-chip fetch path:

  • ModelContext<CurrentPrompt>::spawn_abortable::<...fetch_chip_value_once...> — 7.39 GB (78.6%)
  • CurrentPrompt::execute_session_command_with_timeout::{closure} — 5.79 GB (61.6%)
  • async_channel::Receiver<CommandOutput> drop — 1.60 GB (17.1%)

This PR caps retained in-band generator output at 1 MiB in InBandCommandExecutor::handle_executed_command_event, truncating and shrinking beyond the limit. Generator results are short strings (the prompt chip ultimately calls CommandOutput::to_string()), so the cap is safe while preventing the pathological multi-GB case.

This is a distinct facet from #13028 (which stops retaining hidden in-band command blocks); that PR explicitly notes the generator's output is captured separately from the block. This PR bounds that separately-captured output.

Linked Issue

APP-4792https://linear.app/warpdotdev/issue/APP-4792

  • The linked issue is labeled ready-to-spec or ready-to-implement.
  • Where appropriate, screenshots or a short video of the implementation are included below (not applicable — no UI change).

Testing

Added unit tests for the cap helper (test_cap_in_band_output_leaves_small_output_untouched, test_cap_in_band_output_truncates_oversized_output, test_cap_in_band_output_keeps_output_at_exact_limit).

  • cargo check -p warp --lib — passes
  • cargo clippy -p warp --lib --tests -- -D warnings — clean (compiles the new test code)
  • Not run here: full cargo nextest/./script/presubmit — building the warp test binary OOMs (SIGKILL) in this runner above a single build job, same limitation called out in Stop retaining hidden in-band generator command blocks (#12694) #13028. Worth a full CI pass before merge.
  • I have manually tested my changes locally with ./script/run

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

Conversation: https://staging.warp.dev/conversation/57c39a0f-32e7-478d-b352-08c3f801e0ed
Run: https://oz.staging.warp.dev/runs/019f0afd-6103-7c58-addd-00c058ed2f5b

This PR was generated with Oz.

In-band generator commands (completions, syntax highlighting, prompt
context chips) capture their entire stdout/stderr into a CommandOutput
with no size limit. A misbehaving or very chatty generator can therefore
buffer gigabytes that stay alive on the generator's pending future. Heap
profiles from "Excessive memory usage detected" (Sentry 7259255054) show
~7.4 GB retained on the CurrentPrompt context-chip fetch path through the
async_channel<CommandOutput> queue.

Cap retained in-band generator output at 1 MiB in
handle_executed_command_event, truncating and shrinking beyond the limit.
Generator results are short, so the cap is safe while preventing the
pathological multi-GB case.

Co-Authored-By: Oz <oz-agent@warp.dev>
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