Error Messages from Command Executions Get Mixed with Regular Output and May Be Truncated

Resolved 💬 1 comment Opened Jan 19, 2026 by charles-wang888 Closed Jan 19, 2026

What version of Codex is running?

v0.87.0

What subscription do you have?

None

Which model were you using?

gpt-5-codex

What platform is your computer?

Microsoft Windows NT 10.0.26100.0 x64

What terminal emulator and version are you using (if applicable)?

Powershell

What issue are you seeing?

When formatting exec tool call outputs for model consumption, large outputs containing both normal content and error messages need to be truncated. The current implementation applies truncation to the entire output as a single block, which can result in critical error information being truncated away when the combined output exceeds token budgets. Error messages from compilation failures, test results, or runtime exceptions get mixed with regular output, making it difficult to quickly identify and address failures. Users must manually search through truncated output to find error messages, or the errors may be completely lost if they appear in sections that get truncated.

What steps can reproduce the bug?

To reproduce this issue, execute a command that produces a large output containing both normal output and error messages. For example, run a compilation command that produces hundreds of lines of compilation output followed by compilation errors, or run a test suite that produces extensive logging before encountering test failures. When the total output exceeds the token budget and truncation is applied, observe that the error messages are mixed with regular output and may be truncated away if they appear in sections that exceed the budget. Attempt to identify the errors in the truncated output and notice that it is difficult to quickly locate error information because it is interspersed with normal output. In some cases, the error messages may be completely lost if they appear in truncated sections, making it impossible to diagnose failures without re-running the command with different truncation settings.

What is the expected behavior?

The system should implement error extraction and prioritization by separating error lines from regular output, ensuring errors are always preserved even when budget is limited, and then truncating the remaining non-error content separately. When formatting exec output, the system should first extract all error lines by scanning through all lines and filtering those containing error patterns such as "error", "failed", "exception", "fatal", "panic", "abort", "warning:", "error:", and "failure". If errors are found, the system should calculate the token cost of error lines, reserve budget for them, and then truncate the remaining content (with errors removed) using the remaining budget. The result should combine error lines at the top with a clear separator (such as "--- Other Output ---") followed by truncated regular output, ensuring errors are always visible and easy to identify. If the error information itself exceeds the budget, only the errors should be returned (truncated). This would make it easy for users to quickly identify failures even in truncated outputs and ensure that critical error information is never lost.

Additional information

_No response_

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗