If you've been watching AI coding agents work, you've probably seen it happen: the agent fires off a test suite, tests fail, and then—rather than grepping through what just scrolled past—it re-runs the whole thing to recover the failure output. Minutes burned. Loops compounded. This is such a common pattern that developer tacoda documented a clean fix that's been hiding in plain sight since 1973.

The Core Problem: Attention vs. Retention

The agent isn't being lazy when it re-runs. It's being honest about how attention works at scale. Test output is voluminous—the failure summary gets buried at the bottom, and by the time the agent finishes reasoning about what to do next, those critical lines have scrolled out of whatever context window it's actually retaining. The cheapest way to get that information back feels like running the command again. But a full suite takes minutes, and doing it twice (or three times) to learn something the first run already told you is pure waste.

The Fix: tee Everything to .test-output/

The solution is brutally simple: pipe every test command through tee into a gitignored directory. Run make test 2>&1 | tee .test-output/full.log and the agent gets real-time streaming feedback in the terminal while simultaneously persisting the entire output to disk. When it needs to know which assertion failed, it runs grep -n FAIL .test-output/full.log instead of burning another suite run. The directory stays gitignored because it's ephemeral—overwritten on every run, never reviewed in a PR, never meant for human inspection.

Why tee Is the Right Tool

Redirecting to a file with > loses interactive feedback; tailing it adds complexity. Telling the agent to "remember the output" is exactly the failure mode this fixes. Increasing context window size treats symptoms instead of causes. But tee forks the stream without replacing it—STDOUT still flows to the terminal in real time, letting the agent react to hangs or obvious early failures, while also persisting everything for later grepping. It's been in every Unix shell since 1973, costs nothing, and works regardless of what framework your project uses.

Stable Filenames Remove Ambiguity

The author keeps filenames stable: full.log, parallel.log, vitest.log—no timestamps needed. The agent never has to ask which file is the latest because the latest is the only one. If history matters, the agent copies it before re-running. By default, nobody needs a log archive; they need the most recent failure ready for inspection.

This Pattern Generalizes Far Past Tests

Wherever an agent re-runs a command to recover information that was already produced, there's a tee waiting to be added. Build output, type-check results, linter warnings, long-running scripts with progress prints—any time the command is expensive and the output is the artifact you care about, persist it. The shape of the fix stays constant: fork the stream, save the artifact, grep the file.

Key Takeaways

  • Agents re-run commands to recover information they already produced—this wastes minutes per loop
  • Piping through tee preserves output while maintaining real-time terminal feedback
  • Keep .test-output/ gitignored and filenames stable (full.log, not timestamped)
  • The pattern applies to builds, type checks, linters—any expensive command with important artifacts

The Bottom Line

Your agent doesn't need a bigger context window or better memory—it needs you to stop letting the harness throw away information that was already on screen. One Unix utility, deployed deliberately. Sometimes the boring fix is the right one.