conductor(checkpoint): Checkpoint end of Phase 3
This commit is contained in:
+29
-16
@@ -142,17 +142,30 @@ _SYSTEM_PROMPT: str = (
|
||||
)
|
||||
|
||||
_custom_system_prompt: str = ""
|
||||
_global_tool_instructions: str = ""
|
||||
_project_context_marker: str = ""
|
||||
|
||||
def set_custom_system_prompt(prompt: str) -> None:
|
||||
global _custom_system_prompt
|
||||
_custom_system_prompt = prompt
|
||||
|
||||
def set_global_tool_instructions(instructions: str) -> None:
|
||||
global _global_tool_instructions
|
||||
_global_tool_instructions = instructions
|
||||
|
||||
def set_project_context_marker(marker: str) -> None:
|
||||
global _project_context_marker
|
||||
_project_context_marker = marker
|
||||
|
||||
def _get_context_marker() -> str:
|
||||
return _project_context_marker if _project_context_marker.strip() else "[SYSTEM: FILES UPDATED]"
|
||||
|
||||
def _get_combined_system_prompt(preset: Optional[ToolPreset] = None, bias: Optional[BiasProfile] = None) -> str:
|
||||
if preset is None: preset = _active_tool_preset
|
||||
if bias is None: bias = _active_bias_profile
|
||||
base = _SYSTEM_PROMPT
|
||||
base = _global_tool_instructions if _global_tool_instructions.strip() else _SYSTEM_PROMPT
|
||||
if _custom_system_prompt.strip():
|
||||
base = f"{_SYSTEM_PROMPT}\n\n[USER SYSTEM PROMPT]\n{_custom_system_prompt}"
|
||||
base = f"{base}\n\n[USER SYSTEM PROMPT]\n{_custom_system_prompt}"
|
||||
if preset and bias:
|
||||
strategy = _BIAS_ENGINE.generate_tooling_strategy(preset, bias)
|
||||
if strategy:
|
||||
@@ -1005,8 +1018,9 @@ def _send_gemini(md_content: str, user_message: str, base_dir: str,
|
||||
if isinstance(r, dict) and "output" in r:
|
||||
val = r["output"]
|
||||
if isinstance(val, str):
|
||||
if "[SYSTEM: FILES UPDATED]" in val:
|
||||
val = val.split("[SYSTEM: FILES UPDATED]")[0].strip()
|
||||
marker = _get_context_marker()
|
||||
if marker in val:
|
||||
val = val.split(marker)[0].strip()
|
||||
if _history_trunc_limit > 0 and len(val) > _history_trunc_limit:
|
||||
val = val[:_history_trunc_limit] + "\n\n... [TRUNCATED BY SYSTEM TO SAVE TOKENS.]"
|
||||
r["output"] = val
|
||||
@@ -1108,7 +1122,7 @@ def _send_gemini(md_content: str, user_message: str, base_dir: str,
|
||||
file_items, changed = _reread_file_items(file_items)
|
||||
ctx = _build_file_diff_text(changed)
|
||||
if ctx:
|
||||
out += f"\n\n[SYSTEM: FILES UPDATED]\n\n{ctx}"
|
||||
out += f"\n\n{_get_context_marker()}\n\n{ctx}"
|
||||
if r_idx == MAX_TOOL_ROUNDS: out += "\n\n[SYSTEM: MAX ROUNDS. PROVIDE FINAL ANSWER.]"
|
||||
|
||||
out = _truncate_tool_output(out)
|
||||
@@ -1219,7 +1233,7 @@ def _send_gemini_cli(md_content: str, user_message: str, base_dir: str,
|
||||
file_items, changed = _reread_file_items(file_items)
|
||||
ctx = _build_file_diff_text(changed)
|
||||
if ctx:
|
||||
out += f"\n\n[SYSTEM: FILES UPDATED]\n\n{ctx}"
|
||||
out += f"\n\n{_get_context_marker()}\n\n{ctx}"
|
||||
if r_idx == MAX_TOOL_ROUNDS:
|
||||
out += "\n\n[SYSTEM: MAX ROUNDS. PROVIDE FINAL ANSWER.]"
|
||||
|
||||
@@ -1245,7 +1259,7 @@ def _send_gemini_cli(md_content: str, user_message: str, base_dir: str,
|
||||
_CHARS_PER_TOKEN: float = 3.5
|
||||
_ANTHROPIC_MAX_PROMPT_TOKENS: int = 180_000
|
||||
_GEMINI_MAX_INPUT_TOKENS: int = 900_000
|
||||
_FILE_REFRESH_MARKER: str = "[FILES UPDATED"
|
||||
_FILE_REFRESH_MARKER: str = _project_context_marker if _project_context_marker.strip() else "[SYSTEM: FILES UPDATED]"
|
||||
|
||||
def _estimate_message_tokens(msg: dict[str, Any]) -> int:
|
||||
cached = msg.get("_est_tokens")
|
||||
@@ -1552,13 +1566,12 @@ def _send_anthropic(md_content: str, user_message: str, base_dir: str, file_item
|
||||
refreshed_ctx = _build_file_diff_text(changed)
|
||||
if refreshed_ctx:
|
||||
tool_results.append({
|
||||
"type": "text",
|
||||
"text": (
|
||||
"[FILES UPDATED \u2014 current contents below. "
|
||||
"Do NOT re-read these files with PowerShell.]\n\n"
|
||||
+ refreshed_ctx
|
||||
),
|
||||
})
|
||||
"type": "text",
|
||||
"text": (
|
||||
f"{_get_context_marker()}\n\n"
|
||||
+ refreshed_ctx
|
||||
),
|
||||
})
|
||||
if round_idx == MAX_TOOL_ROUNDS:
|
||||
tool_results.append({
|
||||
"type": "text",
|
||||
@@ -1842,7 +1855,7 @@ def _send_deepseek(md_content: str, user_message: str, base_dir: str,
|
||||
file_items, changed = _reread_file_items(file_items)
|
||||
ctx = _build_file_diff_text(changed)
|
||||
if ctx:
|
||||
out += f"\n\n[SYSTEM: FILES UPDATED]\n\n{ctx}"
|
||||
out += f"\n\n{_get_context_marker()}\n\n{ctx}"
|
||||
if round_idx == MAX_TOOL_ROUNDS:
|
||||
out += "\n\n[SYSTEM: MAX ROUNDS. PROVIDE FINAL ANSWER.]"
|
||||
|
||||
@@ -2063,7 +2076,7 @@ def _send_minimax(md_content: str, user_message: str, base_dir: str,
|
||||
file_items, changed = _reread_file_items(file_items)
|
||||
ctx = _build_file_diff_text(changed)
|
||||
if ctx:
|
||||
out += f"\n\n[SYSTEM: FILES UPDATED]\n\n{ctx}"
|
||||
out += f"\n\n{_get_context_marker()}\n\n{ctx}"
|
||||
if round_idx == MAX_TOOL_ROUNDS:
|
||||
out += "\n\n[SYSTEM: MAX ROUNDS. PROVIDE FINAL ANSWER.]"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user