Skip to content

fix(redact): preserve code-like tool output - #34666

Closed
zapabob wants to merge 1 commit into
NousResearch:mainfrom
zapabob:codex/redact-code-output
Closed

fix(redact): preserve code-like tool output#34666
zapabob wants to merge 1 commit into
NousResearch:mainfrom
zapabob:codex/redact-code-output

Conversation

@zapabob

@zapabob zapabob commented May 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • pass code_file=True when redacting execute_code and terminal output so code-like lines such as MAX_TOKENS=100 are not rewritten as secrets
  • keep prefix-based secret masking active for actual leaked tokens
  • add regression coverage for both terminal output and execute_code output

Context

This addresses the remaining code-output corruption reported in #33801. It is related to #33840, but includes behavior tests covering the user-visible regression.

Tests

  • .\.venv\Scripts\python.exe -m ruff check tools\code_execution_tool.py tools\terminal_tool.py tests\tools\test_code_execution.py tests\tools\test_terminal_output_transform_hook.py
  • .\.venv\Scripts\python.exe scripts\run_tests_parallel.py tests\tools\test_terminal_output_transform_hook.py tests\tools\test_code_execution.py tests\agent\test_redact.py -- --tb=short --timeout-method=thread -k redaction_preserves_code_like_env_names
  • .\.venv\Scripts\python.exe -m ruff check .

Closes #33801

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists tool/terminal Terminal execution and process management tool/code-exec execute_code sandbox labels May 29, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #33840 — identical fix (pass code_file=True to redact_sensitive_text in execute_code and terminal). Both close #33801. This PR adds regression tests that #33840 lacks; consider merging the test coverage into #33840 or vice versa.

@zapabob

zapabob commented May 29, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, agreed that #34666 overlaps with #33840 on the implementation: both pass code_file=True to redact_sensitive_text for execute_code and terminal output.

I rechecked the current diff and the practical options are:

Fresh local validation on Windows:

  • .\.venv\Scripts\python.exe -m ruff check tools\code_execution_tool.py tools\terminal_tool.py tests\tools\test_code_execution.py tests\tools\test_terminal_output_transform_hook.py -> passed
  • .\.venv\Scripts\python.exe scripts\run_tests_parallel.py tests\tools\test_terminal_output_transform_hook.py tests\tools\test_code_execution.py tests\agent\test_redact.py -- --tb=short --timeout-method=thread -> 121 passed, 0 failed

So my recommendation is to keep/merge #34666 unless #33840 absorbs those tests.

@teknium1

Copy link
Copy Markdown
Contributor

Closing as part of the #33801 secret-redaction-corrupts-code cluster, fixed at the root in #54061 (merged: 674e16e).

The real defect was _DB_CONNSTR_RE's password group matching greedily across newlines, corrupting displayed tool output (read_file/terminal/execute_code) for any source containing a postgresql:// f-string template. The fix forbids whitespace in the userinfo/password groups so the match can't span a line, preserves brace-only template passwords under code_file=True, and passes code_file=True at the terminal/execute_code output sites. Thanks for the contribution to this area.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Medium — degraded but workaround exists tool/code-exec execute_code sandbox tool/terminal Terminal execution and process management type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Secret redaction corrupts code syntax in tool output (write_file, execute_code, terminal)

3 participants