agent_sdk: write sandbox files as utf-8, not the locale default - #110
Draft
amburger66 wants to merge 1 commit into
Draft
agent_sdk: write sandbox files as utf-8, not the locale default#110amburger66 wants to merge 1 commit into
amburger66 wants to merge 1 commit into
Conversation
setup_sandbox_directory wrote CLAUDE.md, validate_sandbox.py, settings.json
and notes.md with bare Path.write_text(), which encodes using the locale's
preferred encoding. VALIDATE_SANDBOX_SCRIPT contains an em dash at index
3026, so under a C/POSIX locale the write died with
'ascii' codec can't encode character '—' in position 3026
Sandbox setup runs once per agent query, so this was not a single bad
query: every query and every final-submission nudge failed identically,
and the task ended with "no captured plan after 0 completed agent
queries" after exhausting all solve attempts. The traceback never named
the sandbox, because the approach catches the failure per query and logs
only the message.
The system-prompt write a few lines further down already passed
encoding="utf-8"; this makes the rest of the function consistent with it.
Verified by running setup_sandbox_directory under LC_ALL=C with C-locale
coercion disabled: origin/master raises the error above, this commit
completes and writes every file.
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.
What
setup_sandbox_directorywroteCLAUDE.md,.claude/validate_sandbox.py,.claude/settings.jsonandnotes.mdwith a barePath.write_text(), which encodes using the locale's preferred encoding. All four now passencoding="utf-8"explicitly.Why
VALIDATE_SANDBOX_SCRIPTcontains an em dash at index 3026, so on a C/POSIX locale the write raised:Sandbox setup runs once per agent query, so this was not one unlucky query — every query and every final-submission nudge failed the same way, and the run ended with:
The cause is invisible from the logs:
agent_model_based_approachcatches the exception per query and logs only the message, so the failure reads like an agent/planning problem rather than a file write. It was found while bringing uppybullet_domino_realon real hardware, where it blocked the run entirely.The system-prompt write further down the same function already passed
encoding="utf-8"; this makes the rest consistent with it.Verification
Ran
setup_sandbox_directorydirectly underLC_ALL=C LANG=C PYTHONCOERCECLOCALE=0 PYTHONUTF8=0(preferred encodingANSI_X3.4-1968):origin/master— raises the error aboveCLAUDE.md,.claude/validate_sandbox.py,notes.md, subdirectories)yapf --diffclean against.style.yapf; file compiles.Note for reviewers
PYTHONUTF8=1is an equivalent workaround for anyone hitting this before the fix lands, but the explicit encoding is the right fix — these files are always UTF-8 regardless of the operator's locale.