codex icon indicating copy to clipboard operation
codex copied to clipboard

tools: truncate lines in session history

Open jobchong opened this issue 1 month ago • 1 comments

This PR applies the truncation policy to session history, and is a minimal fix for #7395. I chose not to simply omit gitignored files in capture_existing_untracked since that seems to be a deliberate design decision. I have changed the warning for format_large_untracked_warning somewhat, which may address similar reports like #7405, #7369, #7313 and #7067.

What

  • Persisted response items now use a single processing pass that truncates tool outputs according to the existing TruncationPolicy. The truncated copy is what goes into history/rollout; live output during the turn remains unchanged.
  • Reworded the large-untracked warning to accurately state that undo snapshots will stage large untracked/ignored dirs and may be slow.

Why

  • Large tool outputs were being inlined in rollout JSONL leading to session bloat. Bounding the persisted copy keeps session files small while retaining head/tail context.
  • Warning now reflects current behavior: snapshots still stage untracked/ignored content, so the cost is time/disk, not JSONL size.

How

  • context_manager/history.rs: centralized process_response_items, ensured processed items are used for persistence.
  • codex.rs, compact.rs: persistence now uses processed items. Live events are unchanged.

jobchong avatar Dec 01 '25 05:12 jobchong

@jif-oai thank you for the comments! I've addressed them and moved the processing back into the context manager.

jobchong avatar Dec 04 '25 12:12 jobchong

After some internal discussion, we've decided to pass on this change.

As noted above, the root cause of the ghost_commit issue was already fixed separately. And more importantly, the proposed change introduces truncation at a point where it doesn't belong.

etraut-openai avatar Dec 08 '25 18:12 etraut-openai

I get what you guys mean, especially with changes like https://github.com/openai/codex/commit/349734e38d91c6d70b7dd04e3e9c5d5319132323 and https://github.com/openai/codex/commit/2222cab9eafb5e8abd100be465515a4c6be028f2. This PR was raised a few days before these fixes came in. Thanks for the feedback @jif-oai, @etraut-openai!

jobchong avatar Dec 09 '25 03:12 jobchong