feat: generic extra_sys_prompts slot replaces hardcoded commit_signature module

This commit is contained in:
Liang Jiaqing
2026-06-20 21:03:38 +08:00
parent 942bd315d7
commit c85b59e06e
4 changed files with 7 additions and 2 deletions
+2 -2
View File
@@ -60,6 +60,7 @@ class GenericAgent:
logid = f'{(time.time_ns() + random.randrange(1_000_000)) % 1_000_000:06d}'
self.log_path = os.path.join(script_dir, f'temp/model_responses/model_responses_{logid}.txt')
self.load_llm_sessions()
self.extra_sys_prompts = []
def load_llm_sessions(self):
mykeys, changed = reload_mykeys()
@@ -146,8 +147,7 @@ class GenericAgent:
raw_query = f'Long user prompt saved to {task_file}. Read and execute.'
rquery = smart_format(raw_query.replace('\n', ' '), max_str_len=200)
self.history.append(f"[USER]: {rquery}")
sys_prompt = get_system_prompt() + getattr(self.llmclient.backend, 'extra_sys_prompt', '')
sys_prompt = get_system_prompt() + '\n'.join(self.extra_sys_prompts) + getattr(self.llmclient.backend, 'extra_sys_prompt', '')
if self.peer_hint: sys_prompt += f"\n[Peer] 用户提及其他会话/后台任务状态时: temp/model_responses/ (只找近期修改的文件尾部)\n"
handler = GenericAgentHandler(self, self.history, os.path.join(script_dir, 'temp'))
if getattr(self, 'no_print', False): handler.print = lambda *a, **k: None
+1
View File
@@ -33,6 +33,7 @@ from typing import Optional
_USER_SHELL: tuple[list[str], str] | None = None
COMMIT_SIGNATURE_PROMPT = 'When you create a git commit, append "Co-Authored-By: GenericAgent <bot@gaagent.ai>" as the final line of the commit message.'
def detect_user_shell() -> tuple[list[str], str]:
"""Return `([executable, ...flags_for_-c], display_name)` for the user's
+2
View File
@@ -1373,6 +1373,8 @@ class AgentBridge:
self.agent.llmclient = self.agent.llmclients[llm_no % len(self.agent.llmclients)]
self.agent.inc_out = True
self.agent.verbose = True
from frontends.slash_cmds import COMMIT_SIGNATURE_PROMPT
self.agent.extra_sys_prompts.append(COMMIT_SIGNATURE_PROMPT)
# 默认普通模式:设 None 让 project_mode 插件不读 pid 文件锚(与 v2 一致)。
# /workspace 绑定时改为项目名 + 真实路径。
self.agent._ga_project_mode_name = None
+2
View File
@@ -2043,8 +2043,10 @@ class AgentSession:
def default_agent_factory() -> Any:
from agentmain import GenericAgent
from frontends.slash_cmds import COMMIT_SIGNATURE_PROMPT
agent = GenericAgent()
agent.inc_out = True
agent.extra_sys_prompts.append(COMMIT_SIGNATURE_PROMPT)
return agent