mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-21 10:22:18 +00:00
refactor(openviking): reuse pre-scanned tool_input for pending tool calls
_messages_to_openviking_batch's pre-scan already parses and caches each tool call's arguments into tool_calls_by_id. The pending-tool-call branch re-parsed them via _tool_call_input(), a second parse and a second source of truth. Reuse the cached tool_input when the id was cached (non-empty), falling back to a parse only for the uncached empty-id case so arguments are never dropped. No behavior change.
This commit is contained in:
parent
27a6e188c4
commit
2d4046c6de
1 changed files with 10 additions and 1 deletions
|
|
@ -2548,11 +2548,20 @@ class OpenVikingMemoryProvider(MemoryProvider):
|
|||
continue
|
||||
if tool_id in completed_tool_ids:
|
||||
continue
|
||||
# Reuse the tool_input parsed in the pre-scan when available
|
||||
# (non-empty ids are cached); fall back to parsing for the
|
||||
# uncached empty-id case so we never drop arguments.
|
||||
prior_call = tool_calls_by_id.get(tool_id) if tool_id else None
|
||||
tool_input = (
|
||||
prior_call["tool_input"]
|
||||
if prior_call is not None
|
||||
else cls._tool_call_input(tool_call)
|
||||
)
|
||||
parts.append({
|
||||
"type": "tool",
|
||||
"tool_id": tool_id,
|
||||
"tool_name": tool_name,
|
||||
"tool_input": cls._tool_call_input(tool_call),
|
||||
"tool_input": tool_input,
|
||||
"tool_status": "pending",
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue