fix(cron): use TERMINAL_CWD for system prompt working directory#24985
Closed
luyao618 wants to merge 1 commit into
Closed
fix(cron): use TERMINAL_CWD for system prompt working directory#24985luyao618 wants to merge 1 commit into
luyao618 wants to merge 1 commit into
Conversation
When a cron job is registered with --workdir, the scheduler sets TERMINAL_CWD so tools run from the correct directory. However, build_environment_hints() in prompt_builder.py unconditionally uses os.getcwd(), which reports the scheduler's own cwd rather than the job's configured workdir. The model trusts the system prompt over `pwd`, so it often starts by cd-ing to the wrong directory. Fix: check TERMINAL_CWD env var first, falling back to os.getcwd(). Closes NousResearch#24969
52875a2 to
ab27a9b
Compare
19 tasks
Contributor
Author
|
Closing — open too long, no longer relevant. |
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
When a cron job is registered with
--workdir <PATH>, the scheduler correctly setsTERMINAL_CWDso terminal/file tools run from the right directory. However,build_environment_hints()inagent/prompt_builder.pyusesos.getcwd()unconditionally for theCurrent working directoryline in the system prompt, which reports the scheduler's own cwd (typically~/.hermes/hermes-agent) instead of the job's configured workdir.Since the model trusts the system prompt over
pwd, it often starts bycd-ing to the wrong directory, silently operating on the wrong filesystem location.Root Cause
prompt_builder.py:775callsos.getcwd()without checking theTERMINAL_CWDenvironment variable that the cron scheduler sets atscheduler.py:1265.Fix
Check
os.environ.get("TERMINAL_CWD")first, falling back toos.getcwd()— consistent with how the terminal tools already resolve working directory.Testing
TERMINAL_CWD=/tmp python -c "from agent.prompt_builder import build_environment_hints; print(build_environment_hints())"now shows/tmpCloses #24969