fix(gateway): honor configured cwd in gateway sessions#29365
Conversation
d2a33b6 to
4a99677
Compare
|
Thanks for building this out — this looks like a more complete/generalized version of the root cause I was seeing in #27488. I especially like the gateway/tool cwd contract coverage and regression tests. My PR (#27488) was focused on the immediate production fix direction, but this seems like the broader/systemic approach. Happy to close or mark #27488 as superseded if maintainers prefer consolidating on this direction. If useful, I'm also happy to help test edge cases from the original repro. |
|
@pinguarmy Thanks — really appreciate the context, and especially the original production-fix direction in #27488. I tried to preserve that root-cause fix while adding a bit more contract coverage around the shared gateway/tool cwd behavior, so the #29265 QQBot/Weixin report does not end up as a platform-only regression test. I’ll defer to you and the maintainers on whether #27488 should stay open or be marked superseded. If you still have edge cases from the original repro, I’d be happy to check whether they’re covered here and add coverage if there’s a gap. |
…earch#29265) Port PR NousResearch#29365's tool-surface contract test: terminal/file/execute_code already honor TERMINAL_CWD (out of scope for the resolver cluster). Pinning the behavior makes the supersession of NousResearch#29365 airtight and guards against a future refactor silently regressing the workspace contract.
…earch#29265) Port PR NousResearch#29365's tool-surface contract test: terminal/file/execute_code already honor TERMINAL_CWD (out of scope for the resolver cluster). Pinning the behavior makes the supersession of NousResearch#29365 airtight and guards against a future refactor silently regressing the workspace contract.
What does this PR do?
Fixes gateway workspace drift for configured
terminal.cwd: gateway sessions should show and use the user's configured workspace, not the long-lived Hermes daemon/source checkout.This is based on the same root cause identified in #27488, but expands the regression coverage around the shared gateway/tool cwd contract instead of only testing the prompt-builder surface.
Related Issue
Fixes #29265
Related PRs / context:
TERMINAL_CWDin environment hints and re-readterminal.cwdfor long-lived gateway resets.TERMINAL_CWDprompt/cwd fixes in adjacent surfaces.Type of Change
Changes Made
agent/prompt_builder.pyTERMINAL_CWDwhen rendering the system prompt'sCurrent working directoryhint.os.getcwd()fallback whenTERMINAL_CWDis unset.gateway/run.pyterminal.cwdvalues fromconfig.yamlintoTERMINAL_CWDduring runtime env reloads, so long-lived gateway sessions can pick up cwd config changes without restart..,auto, orcwd.tests/gateway/test_gateway_cwd_contract.pytests/tools/test_gateway_cwd_contract.pyexecute_codeproject mode.tests/gateway/test_issue_29265_qqbot_weixin_cwd.pyHow to Test
/newor/resetafter changingterminal.cwd.Automated validation run locally:
Result:
Additional checks:
Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
Not applicable; this is a gateway runtime/env contract fix with automated regression coverage.