fix
This commit is contained in:
@@ -341,13 +341,26 @@ async def _run_tool_loop(
|
||||
"tokens": (resp.get("prompt_tokens") or 0) + (resp.get("completion_tokens") or 0),
|
||||
})
|
||||
msg = resp.get("message", {})
|
||||
# Apply text replacements to content
|
||||
content = msg.get("content", "") or ""
|
||||
if content:
|
||||
from app.core.settings_service import apply_text_replacements
|
||||
content = await apply_text_replacements(db, content)
|
||||
msg = dict(msg)
|
||||
msg["content"] = content
|
||||
tool_calls = msg.get("tool_calls") or []
|
||||
if not tool_calls:
|
||||
# No tool calls — append assistant message and ask again
|
||||
# No tool calls — append assistant message and retry with a nudge.
|
||||
# Up to 3 retries.
|
||||
messages.append({"role": "assistant", "content": msg.get("content", "")})
|
||||
messages.append({
|
||||
"role": "user",
|
||||
"content": f"You must call a tool. Available terminal tool: {terminal_tool}. If you are done with your work, call {terminal_tool} now.",
|
||||
"content": (
|
||||
f"You did not call any tools in your previous response. "
|
||||
f"You MUST use the available tools to accomplish the task. "
|
||||
f"If you tried to call a tool but it didn't work, try again with proper JSON arguments. "
|
||||
f"When you are done, call {terminal_tool}."
|
||||
),
|
||||
})
|
||||
continue
|
||||
|
||||
|
||||
Reference in New Issue
Block a user