-
Notifications
You must be signed in to change notification settings - Fork 7.8k
refactor(git): principled way to set git configuration for agents & re-enable git settings in UI #10293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Move git config from action execution server to runtime client - Add setup_git_config() method to Runtime base class - Update all runtime implementations to call git config after connection - Remove git parameters from ActionExecutor and startup commands - Ensure git config works for both fresh and warm runtimes This fixes the bug where git operations would fail in warm runtimes because git configuration was lost when warm runtimes were claimed.
- Replace environment variable check with explicit is_local_runtime parameter - Local and CLI runtimes pass is_local_runtime=True - Remote, Kubernetes, and Docker runtimes use default is_local_runtime=False - Cleaner and more explicit runtime type detection - Updated documentation to reflect the change
- Replace is_local_runtime with is_cli_runtime parameter - CLI runtime now skips git config to preserve user's local settings - Local runtime detection uses class name instead of parameter - CLI runtime runs on user's machine and should respect existing git config - Other runtimes (Local, Remote, Kubernetes, Docker) continue to set git config - Updated documentation to reflect CLI runtime behavior
- All runtimes (Local, Remote, Kubernetes, Docker) now use global git config - Removed complex platform-specific file-based config logic - CLI runtime still skips git config to preserve user settings - Simpler and more consistent approach across all runtime types - Remove documentation from git tracking
- Update global config with git_user_name and git_user_email from settings - Apply git configuration to all active runtimes when git settings are updated - Update session config to ensure consistency across runtime operations - Add error handling and logging for git configuration updates This completes the nested runtime settings workflow: 1. Warm runtime starts without git configuration (deploy repo change) 2. User settings sent via POST /api/settings when runtime is claimed 3. Git configuration now applied immediately to the runtime 4. All subsequent commits use correct user identity Fixes the issue where user git settings were received but not applied to the runtime's git configuration. Co-authored-by: openhands <openhands@all-hands.dev>
INIT_COMMANDS.append( | ||
f'git config --global user.email "{self.git_user_email}"' | ||
) | ||
# Git configuration is now handled by the runtime client after connection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Git configuration is now handled by the runtime client after connection |
- Chain git config commands together for efficiency (single cmd run instead of two) - Simplify settings route by removing complex session update logic - Remove documentation file and .gitignore entry as requested - Git configuration will be applied when new sessions are initialized This maintains the core functionality while making the code cleaner and more efficient. Co-authored-by: openhands <openhands@all-hands.dev>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice - setting the git user and email as part of the settings makes sense
- Git configuration now happens automatically during setup_initial_env() - Removed all manual setup_git_config() calls from runtime implementations - CLI runtime sets is_cli_runtime flag to skip git configuration - Simplified git configuration workflow for all runtime types Co-authored-by: openhands <openhands@all-hands.dev>
Looks like there are a few issues preventing this PR from being merged!
If you'd like me to help, just leave a comment, like
Feel free to include any additional details that might help me get this PR into a better state. You can manage your notification settings |
Co-authored-by: openhands <openhands@all-hands.dev>
git_user_email = self.config.git_user_email | ||
|
||
# Skip git configuration for CLI runtime to preserve user's local git settings | ||
is_cli_runtime = self.config.runtime == 'cli' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this special case include ‘local’ too? Or the local nested needs it set… hmm, globally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah - basically local nested runtime needs it set :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I liked the other option too, sending git user/email in the RecallObs, but this is okay too.
It does seem to mean that if users use ‘local’ runtime, their global git config will be overwritten, though?
@enyst yes.. but now with CLI, i wonder if there's an actual use case for the standalone usage of local runtime though? |
- Updated test_git_config_in_command_generation to test_git_config_not_in_command_generation - Updated test_git_config_with_special_characters to test_git_config_with_special_characters_not_in_command - Tests now correctly verify that git config is NOT passed as command-line arguments - Git configuration is handled by runtime base class via git config commands, not CLI args - All git config tests now pass (5/5) Co-authored-by: openhands <openhands@all-hands.dev>
That's a good point, except for Windows... I don't know if CLI works well on Windows |
@enyst happy to fix it follow-up PR if i eventually break it on windows.. But on the other hand, if CLI breaks on Windows, we should just fix the CLI, right 😄 |
- Removed '.git_config' assertions from test_multiple_multiline_commands and test_multi_cmd_run_in_single_line - Git configuration is now handled by runtime base class via git config commands, not by creating .git_config files - Windows tests now correctly reflect current architecture where git config is not stored as workspace files - Tests focus on command execution functionality rather than git file presence Co-authored-by: openhands <openhands@all-hands.dev>
Yes, headless mode with local runtime is how OpenHands works in terminal-bench harness. That being said, if openhands-cli can be made fully autonomous (non-interactive), I guess headless mode can be deprecated. CLI worked on windows when I used it last time so I don’t think windows will be a concern. |
…e-enable git settings in UI (#10293) Co-authored-by: openhands <openhands@all-hands.dev>
End-user friendly description of the problem this fixes or functionality this introduces.
refactor(git): principled way to set git configuration for agents;
Fixes a bug where git operations (like commits and pushes) would fail in warm runtimes due to missing git user configuration. This ensures that git commands work reliably in all runtime scenarios, including reused warm runtimes.
Summarize what the PR does, explaining any non-trivial design decisions.
This PR fixes a critical bug in the warm runtime system where git configuration was being lost when warm runtimes were claimed and reused.
Problem: Git configuration was set during action execution server initialization, but warm runtimes bypass this initialization step. When a warm runtime was claimed, the git user settings were missing, causing git operations to fail.
Solution: Move git configuration from the action execution server to the runtime client, ensuring git settings are applied after every runtime connection.
Key Changes:
setup_git_config()
method handles platform-specific git configurationTechnical Details:
CmdRunAction
to execute git config commands in the runtime environmentWorkflow Fix:
Screenshots:
Before setting anything in UI:

After setting (this pr also adjust the fontsize so it follow existing setting convention in LLM tab:


It is working
In CLI - does override user config:

Link of any specific issues this addresses:
This addresses the warm runtime git configuration bug reported in the deploy repository where git operations would fail when using warm runtimes due to missing user configuration. This is why #9942 didn't work
@xingyaoww can click here to continue refining the PR
To run this PR locally, use the following command:
GUI with Docker:
CLI with uvx: