fix(gateway): re-read terminal.cwd on session reset; use TERMINAL_CWD in environment hints#27488
Open
pinguarmy wants to merge 1 commit into
Open
Conversation
19 tasks
1 task
Contributor
|
Thanks for the focused fix. I checked this against current main: the prompt half has landed, but the gateway refresh half needs updating before it can be salvaged cleanly. Problems
Suggested changes
Automated hermes-sweeper review. |
… in environment hints Fixes two related bugs: 1. **agent/prompt_builder.py** — now prefers the env var (bridged from config.yaml by the gateway) over , which reflects the daemon's launch directory rather than the user's configured workspace. 2. **gateway/run.py** — (called per-turn) now re-reads from config.yaml and updates the env var, so long-lived gateways pick up config changes on or without needing a restart. 3. **tests/agent/test_prompt_builder.py** — Two new tests: - - Fixes NousResearch#27383 References NousResearch#24882
f351dbd to
fbe33d1
Compare
Author
|
Updated this branch against current Changes made:
Focused tests run:
|
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
Fixes two related bugs that prevent configured
terminal.cwdfrom being used after/newor/resetin messaging gateway sessions.Changes
1.
agent/prompt_builder.py— Use TERMINAL_CWD in environment hintsbuild_environment_hints()now prefers theTERMINAL_CWDenv var (bridged from config.yaml by the gateway) overos.getcwd(), which reflects the daemon's launch directory rather than the user's configured workspace.2.
gateway/run.py— Re-read terminal.cwd on each turn_reload_runtime_env_preserving_config_authority()(called per-turn) now re-readsterminal.cwdfrom config.yaml and updates theTERMINAL_CWDenv var. This ensures long-lived gateways pick up config changes on/newor/resetwithout needing a restart.3.
tests/agent/test_prompt_builder.py— Two new teststest_build_environment_hints_prefers_terminal_cwd: verifies TERMINAL_CWD appears in the system prompt when settest_build_environment_hints_falls_back_to_getcwd: verifiesos.getcwd()is used when TERMINAL_CWD is unsetRoot Cause
The comment on #27383 identified the issue: "The
/newcommand resets the session but the gateway may not re-readterminal.cwdfrom config for the new session." Additionally, PR #24888 identified thatbuild_environment_hints()usesos.getcwd()directly instead of checking theTERMINAL_CWDenv var.Testing
All 10
TestEnvironmentHintstests pass (including 2 new).Fixes #27383
References #24882