fix(tool-execute-before): strip null bytes from bash commands to prevent crash (fixes #2220)#2801
Merged
code-yeongyu merged 1 commit intocode-yeongyu:devfrom Mar 24, 2026
Conversation
Contributor
Author
|
I have read the CLA Document and I hereby sign the CLA |
There was a problem hiding this comment.
No issues found across 1 file
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Auto-approved: Minimal, safe fix to prevent Node.js crashes when LLMs emit null bytes in bash commands. Logic is well-guarded and only targets the specific failure condition.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Problem
When context compaction or model fallback occurs, the LLM can hallucinate null bytes (\x00) in tool call arguments. Node.js child_process rejects these with:
The shell argument must be a string without null bytes. Received "\0". This crashes the bash tool and leaves the session in an error state.This affects long-running sessions with context management features enabled (aggressive_truncation, preemptive_compaction, dynamic_context_pruning) and model fallback chains.
Fix
Added null byte sanitization at the very beginning of the
tool.execute.beforehandler chain intool-execute-before.ts. When the tool isbashand the command string contains null bytes, they are stripped before any other hooks process the command. A log entry is emitted for debugging.This runs before all other hooks to ensure clean input for downstream processing.
Changes
src/plugin/tool-execute-before.tsFixes #2220
Summary by cubic
Removes null bytes from
bashtool commands before execution to stop Nodechild_processfrom rejecting the shell args and crashing. This prevents session failures when models emit\x00during context compaction or fallback. Fixes #2220.bashcommand strings in the earliesttool.execute.beforehandler by stripping\x00, and logs the event for debugging.Written for commit c56a01c. Summary will update on new commits.