mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-28 06:51:16 +08:00
feat: add _should_sanitize_tool_calls() method
Adds a centralized method to determine when tool_calls need sanitization for strict APIs. Returns True for all APIs except codex_responses mode. This prevents 400 errors from providers like Fireworks that reject unknown fields (call_id, response_item_id) in tool_calls.
This commit is contained in:
13
run_agent.py
13
run_agent.py
@@ -5345,6 +5345,19 @@ class AIAgent:
|
||||
]
|
||||
return api_msg
|
||||
|
||||
def _should_sanitize_tool_calls(self) -> bool:
|
||||
"""Determine if tool_calls need sanitization for strict APIs.
|
||||
|
||||
Codex Responses API uses fields like call_id and response_item_id
|
||||
that are not part of the standard Chat Completions schema. These
|
||||
fields must be stripped when calling any other API to avoid
|
||||
validation errors (400 Bad Request).
|
||||
|
||||
Returns:
|
||||
bool: True if sanitization is needed (non-Codex API), False otherwise.
|
||||
"""
|
||||
return self.api_mode != "codex_responses"
|
||||
|
||||
def flush_memories(self, messages: list = None, min_turns: int = None):
|
||||
"""Give the model one turn to persist memories before context is lost.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user