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:
kshitijk4poor 2026-06-19 14:03:49 +05:30
parent 27a6e188c4
commit 2d4046c6de

View file

@ -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",
})