This commit is contained in:
2026-02-21 22:37:57 -05:00
parent 32af96b365
commit 478dbb9b86
3 changed files with 34 additions and 20 deletions

View File

@@ -411,16 +411,26 @@ def _send_gemini(md_content: str, user_message: str, base_dir: str, file_items:
_ensure_gemini_client()
mcp_client.configure(file_items or [], [base_dir])
system_text = _get_combined_system_prompt() + f"\n\n<context>\n{md_content}\n</context>"
if _gemini_chat is None:
_gemini_chat = _gemini_client.chats.create(
model=_model,
config=types.GenerateContentConfig(
system_instruction=_get_combined_system_prompt(),
system_instruction=system_text,
tools=[_gemini_tool_declaration()]
)
)
else:
_gemini_chat = _gemini_client.chats.create(
model=_model,
config=types.GenerateContentConfig(
system_instruction=system_text,
tools=[_gemini_tool_declaration()]
),
history=_gemini_chat.get_history()
)
payload_to_send = f"<context>\n{md_content}\n</context>\n\n{user_message}"
payload_to_send = user_message
_append_comms("OUT", "request", {
"message": f"[context {len(md_content)} chars + user message {len(user_message)} chars]",
@@ -612,20 +622,19 @@ def _send_anthropic(md_content: str, user_message: str, base_dir: str, file_item
_ensure_anthropic_client()
mcp_client.configure(file_items or [], [base_dir])
context_blocks = _build_chunked_context_blocks(md_content)
system_text = _get_combined_system_prompt() + f"\n\n<context>\n{md_content}\n</context>"
system_blocks = _build_chunked_context_blocks(system_text)
user_content = context_blocks + [
{"type": "text", "text": user_message}
]
user_content = [{"type": "text", "text": user_message}]
_strip_cache_controls(_anthropic_history)
_repair_anthropic_history(_anthropic_history)
_anthropic_history.append({"role": "user", "content": user_content})
n_chunks = len(context_blocks)
n_chunks = len(system_blocks)
_append_comms("OUT", "request", {
"message": (
f"[{n_chunks} chunk(s), {len(md_content)} chars context] "
f"[system {n_chunks} chunk(s), {len(md_content)} chars context] "
f"{user_message[:200]}{'...' if len(user_message) > 200 else ''}"
),
})
@@ -636,13 +645,7 @@ def _send_anthropic(md_content: str, user_message: str, base_dir: str, file_item
response = _anthropic_client.messages.create(
model=_model,
max_tokens=8096,
system=[
{
"type": "text",
"text": _get_combined_system_prompt(),
"cache_control": {"type": "ephemeral"},
}
],
system=system_blocks,
tools=_build_anthropic_tools(),
messages=_anthropic_history,
)