Skip to content

Spill large hook outputs from context#21069

Merged
abhinav-oai merged 10 commits intomainfrom
abhinav/hook-output-spill
May 5, 2026
Merged

Spill large hook outputs from context#21069
abhinav-oai merged 10 commits intomainfrom
abhinav/hook-output-spill

Conversation

@abhinav-oai
Copy link
Copy Markdown
Collaborator

@abhinav-oai abhinav-oai commented May 4, 2026

Why

Large hook outputs can enter model-visible context through hook-specific paths such as additionalContext and Stop continuation prompts. Without a dedicated cap, one hook can inject a large blob directly into conversation history instead of leaving a bounded preview for the model and preserving the full text elsewhere.

What

  • spill hook text once it exceeds a fixed 2_500-token budget, preserving the full output on disk and leaving a head/tail preview plus saved path in context
  • add shared hook-output spilling under CODEX_HOME/hook_outputs/<thread_id>/<uuid>.txt
  • apply the cap to both additionalContext, feedback_message, and Stop continuation fragments

@abhinav-oai abhinav-oai marked this pull request as ready for review May 4, 2026 20:44
@abhinav-oai abhinav-oai requested a review from a team as a code owner May 4, 2026 20:44
@abhinav-oai
Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0ed973a25e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

);
}

if let Err(err) = fs::write(path.as_ref(), &text).await {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Bound spilled hook output retention

Every oversized hook output is written to a fresh UUID file, but this change adds no retention, quota, or cleanup for $CODEX_HOME/hook_outputs. A noisy or malicious hook that emits large text on each turn will leak disk indefinitely and can fill the user's home directory; add a size/age cap or cleanup path.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we're currently leaving in rollouts unbounded and other paths like imagegen artifacts have no cleanup I think we can punt on this

Copy link
Copy Markdown
Contributor

@eternal-openai eternal-openai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably more sturdy to write these files to a nice cross-os /tmp thing? tmp files are often cleaned up automatically by the OS. this solves several problems here:

  • your codex home directory growing indefinitely, especially if there's lots of hook runs
  • ephemeral threads shouldn't really have anything out of memory, but seems fine to stash some stuff in tmp that'll be deleted quickish

downside of this is that the spilled data could be lost if you come back to the thread after an os reboot, but that seems okay in this case

Copy link
Copy Markdown
Collaborator

@pakrym-oai pakrym-oai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢 core

@abhinav-oai abhinav-oai enabled auto-merge (squash) May 5, 2026 04:44
@abhinav-oai abhinav-oai merged commit dca105c into main May 5, 2026
26 checks passed
@abhinav-oai abhinav-oai deleted the abhinav/hook-output-spill branch May 5, 2026 05:03
@github-actions github-actions Bot locked and limited conversation to collaborators May 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants