Skip to content

fix(proxy): protect exact Responses tool outputs during compression#1140

Open
ianks wants to merge 2 commits into
headroomlabs-ai:mainfrom
ianks:ianks/protect-openai-responses-file-tool-outputs
Open

fix(proxy): protect exact Responses tool outputs during compression#1140
ianks wants to merge 2 commits into
headroomlabs-ai:mainfrom
ianks:ianks/protect-openai-responses-file-tool-outputs

Conversation

@ianks

@ianks ianks commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Description

Previously, the OpenAI Responses live-output compression path could compress exact file-tool outputs before applying Headroom's existing Read/Edit/Write-style exclusions. Responses output items only carry call_id + output, so the compressor needs to resolve the originating function_call.name before deciding whether an output is safe to rewrite.

This patch builds a call_id -> normalized tool name map for Responses input items and protects exactness-sensitive outputs (read, edit, write, glob, grep, including namespaced names like functions.read). Other tool outputs, such as shell/build logs, still flow through the existing compression path.

Type of Change

  • Bug fix (non-breaking change fixes an issue)
  • New feature (non-breaking change adds functionality)
  • Breaking change (fix or feature would cause existing functionality change)
  • Documentation update
  • Performance improvement
  • Code refactoring (no functional changes)

Changes Made

  • Added Responses helper logic to normalize tool names and map function_call.call_id back to tool names.
  • Skip compression for exactness-sensitive function_call_output items before they enter the router.
  • Preserve existing compression behavior for non-sensitive outputs, with regression coverage proving shell output still compresses.

Testing

  • Unit tests pass (pytest)
  • Linting passes (ruff check .)
  • Type checking passes (mypy headroom)
  • New tests added new functionality
  • Manual testing performed

Test Output

$ uv run --extra dev pytest -q tests/test_openai_codex_routing.py tests/test_compression_units.py tests/test_openai_responses_exact_tool_outputs.py
23 passed in 0.21s

$ uv run --extra dev ruff check .
All checks passed!

$ uv run --extra dev mypy headroom
Success: no issues found in 378 source files

Real Behavior Proof

  • Environment: macOS, local Headroom checkout, OpenAI Responses compression path.
  • Exact command / steps: added a regression test with two Responses tool outputs: a namespaced functions.read output and a shell output. The router compression function is patched to rewrite any output it receives.
  • Observed result: the functions.read output remains byte-identical, while the shell output is passed to compression and rewritten.
  • Not tested: full manual Pi/proxy session against a real editing workflow; this PR covers the Responses payload behavior directly with unit tests.

Review Readiness

  • I performed self-review
  • This PR ready for human review

Checklist

  • My code follows project's style guidelines
  • I performed self-review my code
  • I commented my code, particularly in hard-to-understand areas
  • I made corresponding changes documentation
  • My changes generate no new warnings
  • I added tests prove fix is effective or feature works
  • New and existing unit tests pass locally my changes
  • I updated CHANGELOG.md if applicable

Screenshots (if applicable)

N/A

Additional Notes

No docs update; this is a small proxy bug fix. Changelog not updated.

@github-actions

Copy link
Copy Markdown
Contributor

PR governance

This PR does not yet satisfy the required template fields:

  • Check I have performed a self-review before requesting human review.
  • Check This PR is ready for human review or convert the PR back to draft.

Please update the PR body, or move the PR back to draft while it is still in progress.

@github-actions github-actions Bot added the status: needs author action Pull request body or readiness checklist still needs author updates label Jun 18, 2026
@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.85714% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
headroom/proxy/handlers/openai.py 92.85% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@JerrettDavis JerrettDavis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This PR is not merge-ready because CI is currently red: lint=FAILURE, commitlint=FAILURE. Please fix or rerun the failing checks after updating from current main.

@chopratejas

Copy link
Copy Markdown
Collaborator

Hi - can you help fix the conflicts for this? Thanks!

@github-actions github-actions Bot added status: has conflicts Pull request has merge conflicts with the base branch status: ci failing Required or reported CI checks are failing labels Jun 19, 2026
@JerrettDavis JerrettDavis changed the title Protect exact Responses tool outputs from compression fix(proxy): protect exact Responses tool outputs during compression Jun 23, 2026
@github-actions github-actions Bot removed status: has conflicts Pull request has merge conflicts with the base branch status: ci failing Required or reported CI checks are failing labels Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: needs author action Pull request body or readiness checklist still needs author updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants