Repository navigation
fix(chat): give opencode a private TMPDIR so scratch work never lands in $HOME - #671
Merged
Merged
Conversation
… in $HOME OpenCode's bash tool tells the model to use os.tmpdir()/opencode for temporary work and says the directory already exists. The image build ran `opencode --version` as root, which left /tmp/opencode owned by root:root with mode 0755. The model's mkdir there failed, the cd after it failed as well, and the test script ran in the session directory ($HOME), leaving empty output files in the user's home. - Dockerfile: remove /tmp/opencode in the same layer that creates it. - opencode.sh: export TMPDIR=$STUDIO_RUNTIME_DIR/tmp (0700, per uid). This also covers shared hosts, where /tmp/opencode would otherwise belong to whichever user created it first.
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.
Closes #670
Problem
OpenCode's bash tool tells the model to do scratch work in
os.tmpdir()/opencodeand says the directory already exists. The image build runsopencode --versionas root, which leaves/tmp/opencodeowned by root:root with mode 0755. The model'smkdirthere failed, thecdafter it failed as well, and the test script ran in$HOME, leaving empty output files there. Evidence is in #670.Changes
/tmp/opencodein the sameRUNthat creates it, so a terminal-launched opencode doesn't hit it either.docker/supervisor/scripts/opencode.sh: exportTMPDIR=$STUDIO_RUNTIME_DIR/tmp(mode 0700, a separate directory per uid). This also fixes shared hosts (Open OnDemand binds the host/tmp), where/tmp/opencodewould belong to whichever user created it first. Commands the model runs inherit it, somktempstays private too. opencode honorsTMPDIR; verified in a pod withTMPDIR=$T opencode --version, which creates$T/opencodeowned by the user.studio-api/tests/test_opencode_launcher.py: runs the real launcher against a fakeopencodeand asserts thatTMPDIRis private and that the session cwd is still the workspace.Testing
pytest -q: 1062 passed.ls -ld /tmp/opencodein a new pod should fail, and the chat's scratch dir should be/tmp/studio-runtime-<uid>/tmp/opencode.