feat: add git policy - never auto commit without user permission

- Add git policy section in system prompt (gadget.py): no auto git add/commit
- Add policy warning in git_operation tool description (coder.py)
- LLM must ask user before running git add or git commit
- Safe commands (git status, git diff, git log) can run without asking
- When user asks to commit: show changes first, then wait for confirmation
This commit is contained in:
Dita Aji Pratama 2026-06-10 11:27:59 +07:00
parent 41ec8287f7
commit dc5fb67ac1
2 changed files with 11 additions and 1 deletions

View File

@ -33,6 +33,13 @@ def build_system_prompt(tools_definition):
f"Your workspace directory is: {os.getcwd()}. " f"Your workspace directory is: {os.getcwd()}. "
"All file operations are relative to this directory.", "All file operations are relative to this directory.",
"", "",
"⚠️ GIT POLICY — IMPORTANT:",
"- NEVER run 'git add' or 'git commit' automatically after making changes.",
"- After editing/creating files, always ASK the user first before committing.",
"- Only run git commands when the user explicitly asks you to commit.",
"- You may run 'git status', 'git diff', 'git log' freely to inspect state.",
"- When user asks to commit: show them the changes first, then wait for confirmation.",
"",
"RAG capabilities (knowledge retrieval):", "RAG capabilities (knowledge retrieval):",
"- list_collections → see available collections & doc counts.", "- list_collections → see available collections & doc counts.",
"- create_collection → create a new collection for a new topic.", "- create_collection → create a new collection for a new topic.",

View File

@ -146,7 +146,10 @@ schema_git_operation = {
"type": "function", "type": "function",
"function": { "function": {
"name": "git_operation", "name": "git_operation",
"description": "Run a git command. Pass the git arguments as a list (e.g., ['status', '--short'] for 'git status --short').", "description": "Run a git command. Pass the git arguments as a list (e.g., ['status', '--short'] for 'git status --short'). "
"POLICY: Never run 'git add' or 'git commit' without explicit user permission. "
"Safe to run without asking: git status, git diff, git log. "
"Always ask first before committing.",
"parameters": { "parameters": {
"type": "object", "type": "object",
"properties": { "properties": {