Github agent addition
Python CI / test (3.10) (push) Waiting to run

This commit is contained in:
2026-05-30 16:30:25 -05:00
parent 65537c4174
commit c0cfeb2454
2 changed files with 22 additions and 2 deletions
+11 -2
View File
@@ -7,6 +7,7 @@ import re
from abc import abstractmethod
from openai import OpenAI
from tools.base_tool import BaseTool
from tools.github_tool import GitHubTool
from telegram_helper import TelegramHelper
import argparse
from inference_bot import InferenceBot
@@ -299,7 +300,11 @@ class OpenAICompatibleInferenceBot(InferenceBot):
if user_id not in self.conversation_history or not self.conversation_history[user_id]:
self.conversation_history[user_id] = []
if self.system_prompt:
self.conversation_history[user_id].append({"role": "system", "content": self.system_prompt})
github_tool = (GitHubTool)(self.github_tool)
repo_name = os.environ.get("GITHUB_REPOSITORY")
sysprompt = self.system_prompt.format(repo_name=repo_name,
branch=github_tool._get_current_branch())
self.conversation_history[user_id].append({"role": "system", "content": sysprompt})
self.conversation_history[user_id].append({"role": "user", "content": user_message})
messages = list(self.conversation_history[user_id])
@@ -405,7 +410,10 @@ class OpenAICompatibleInferenceBot(InferenceBot):
for name, obj in inspect.getmembers(module):
if inspect.isclass(obj) and issubclass(obj, BaseTool) and obj != BaseTool:
try:
tools.append(obj()) # This instantiation might be an issue for tools needing config
obj_to_add = obj()
if obj == GitHubTool:
self.github_tool = obj_to_add
tools.append(obj_to_add) # This instantiation might be an issue for tools needing config
except Exception as e:
logging.error(f"Error instantiating tool {name} from {filename}: {e}")
except Exception as e:
@@ -532,6 +540,7 @@ def main():
api_key = os.environ.get(f"{config_prepend.upper()}_API_KEY")
baseurl = os.environ.get(f"{config_prepend.upper()}_API_BASE_URL", "")
small_model_name = os.environ.get(f"{config_prepend.upper()}_SMALL_MODEL")
system_prompt_path = os.environ.get(f"{config_prepend.upper()}_SMALL_MODEL_SYSTEM_PROMPT_PATH")
large_model_name = os.environ.get(f"{config_prepend.upper()}_LARGE_MODEL")
small_model_max_tokens = os.environ.get(f"{config_prepend.upper()}_SMALL_MODEL_MAX_TOKENS")
large_model_max_tokens = os.environ.get(f"{config_prepend.upper()}_LARGE_MODEL_MAX_TOKENS")
+11
View File
@@ -0,0 +1,11 @@
You are a GitHub code agent. You read/write code in the repository {repo_name}.
CURRENT STATE:
- Branch: {branch}
RULES:
1. Call one tool at a time. Wait for results before proceeding.
2. When reading code, use search_code or find_files before read_file.
3. Always commit_file_patch for edits (not full file rewrites).
4. Report status after each tool call: what you did, what you learned, next step.
5. If uncertain, ask for clarification instead of guessing.