Skip to content

fix: ga global command cwd should follow user launch directory#180

Open
wzql-qrs wants to merge 6 commits intolsdefine:mainfrom
wzql-qrs:fix/cwd-follow-user
Open

fix: ga global command cwd should follow user launch directory#180
wzql-qrs wants to merge 6 commits intolsdefine:mainfrom
wzql-qrs:fix/cwd-follow-user

Conversation

@wzql-qrs
Copy link
Copy Markdown

Problem

When ga is installed as a global command (e.g. via pip or symlink to /usr/local/bin/ga), the handler working directory is hardcoded to {script_dir}/temp, regardless of where the user actually runs the command.

This means:

  • file_read, file_write, code_run etc. all resolve relative paths against the GA installation directory instead of the user current directory
  • The system prompt shows cwd = /root/GA/GenericAgent/temp even when launched from ~/my_project/

Changes

agentmain.py: Use os.getcwd() for handler cwd instead of hardcoded os.path.join(script_dir, "temp")

ga.py:

  • Use os.getcwd() for cwd display in system prompt
  • Dynamically replace ../ in memory template paths with absolute script_dir paths, since these paths are shown to the agent as navigation instructions and must resolve correctly regardless of cwd

Notes

  • The temp .py files created by code_run will now be written to the user directory (they are auto-deleted in the finally block, so no residue)
  • The code change in this PR was entirely authored by the GenericAgent AI assistant (Claude), not by the repository owner or any human developer.

- /new: calls reset_conversation() to clear all history and start fresh
- /continue: lists recoverable sessions from model_responses/
- /continue N: restores the Nth session
- /resume: kept as alias for backward compatibility
- Lazy import from frontends.continue_cmd to avoid startup dependency

Rollback: git revert HEAD
When 'ga' is installed as a global command (e.g. via pip or symlink),
the handler's cwd was hardcoded to {script_dir}/temp, regardless of
where the user runs the command. This PR changes it to os.getcwd() so
the working directory matches the user's current directory.

Changes:
- agentmain.py: use os.getcwd() for handler cwd instead of hardcoded temp
- ga.py: use os.getcwd() for cwd display, dynamically replace ../ in
  memory paths with absolute paths to prevent resolution issues

Note: This code change was entirely authored by the GenericAgent AI
assistant (Claude), not by the repository owner or any human developer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant