Skip to content

Pipe producer is rewritten (git log | head, git diff 2>&1 | head) #4364

Open

Description

@devin-ai-integration

Problem

rtk rewrite rewrites the left-hand side of a pipeline, even though that segment's stdout is consumed by a program (the next pipe stage), not by the model. This breaks common commands like git log | head and git diff 2>&1 | head:

  • rtk git diff outputs a --stat summary instead of the patch, so head gets truncated output — and rtk itself panics with failed printing to stdout: Broken pipe (os error 32) when the downstream reader closes the pipe early.

Measured behavior (2025-09-30)

Command rtk 0.38.0 rtk 0.50.0
git diff | head rtk git diff | head rtk git diff | head
git diff 2>&1 | head rewritten rtk git diff 2>&1 | head
git log --oneline | head -3 rewritten rtk git log --oneline | head -3
grep FOO a > b rtk grep FOO a > b not rewritten (fixed in 0.50)
git diff | tee x rewritten not rewritten (fixed in 0.50)

Version 0.50 already stopped rewriting segments whose stdout is redirected to a file (>) or read by tee — but a regular pipe to head/grep/etc. is still rewritten.

exclude_commands can't express "this command only when piped": the pattern is matched against the segment with redirections and pipes stripped.

Request

Either:

  1. Don't rewrite a segment whose stdout goes into a pipe (same reasoning as the > / tee fixes in 0.50 — the output is consumed by a program, not an LLM), or
  2. Expose a config option to disable rewriting for piped segments.

Optionally, also handle SIGPIPE/broken-pipe gracefully on the consumer side — the failed printing to stdout: Broken pipe panic is noisy regardless.

Activity

  1. rtk-wshm-sync-bot commented on Sep 30, 2026

    @rtk-wshm-sync-bot

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟠 Priority high
    🎯 Confidence 90%

    Summary

    rtk rewrite mangles pipeline producer stages (e.g. git diff | head), causing wrong output and a broken-pipe panic; should skip rewriting when stdout feeds a pipe.

    📁 Relevant files
    • src/rewrite.rs
    • src/pipeline.rs

    Suggested Actions

    1. Extend the existing >/tee redirect-detection fix from 0.50 to also skip rewriting when stdout feeds a pipe stage
    2. Add SIGPIPE/broken-pipe handling on the consumer side to silence the noisy 'failed printing to stdout' panic
    3. Add regression tests for git diff | head, git diff 2>&1 | head, and git log --oneline | head -3
    4. Consider whether exclude_commands needs a 'piped-only' matcher per the reporter's alternative proposal

    Triaged automatically by wshm · This is an automated analysis, not a human review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:clibugpriority:high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions