From fc22a9712ca8f6d6d3626b62859ba892f3cf0052 Mon Sep 17 00:00:00 2001 From: michael Date: Mon, 23 Feb 2026 16:23:37 -0600 Subject: [PATCH] Fix ToolOutput calls for newer llama_index compatibility The metadata parameter was removed from ToolOutput in recent llama_index versions. Moved metadata fields into raw_input and use is_error flag for error cases. Co-Authored-By: Claude Opus 4.6 --- ai_core.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/ai_core.py b/ai_core.py index 453a78b..a4b0eea 100644 --- a/ai_core.py +++ b/ai_core.py @@ -1049,14 +1049,9 @@ async def initialize_global_index() -> bool: # Add a source_nodes property that routes.py will look for tool_output = ToolOutput( content=final_answer, - tool_name="GraphRAG", + tool_name="GraphRAG", raw_output=NodeWrapper(vector_nodes), - raw_input={"query": query_str}, - metadata={ - 'source': 'graphrag', - 'retrieval_stats': log_message, - 'original_result': modified_raw_output # Store the original result too - } + raw_input={"query": query_str, "source": "graphrag", "retrieval_stats": log_message} ) log_structured('debug', 'GraphRAG Tool: Including image metadata in response', @@ -1071,7 +1066,7 @@ async def initialize_global_index() -> bool: tool_name="GraphRAG", raw_input={"query": query_str}, raw_output={"error": str(graphrag_err)}, - metadata={'error': str(graphrag_err)} + is_error=True ) async def acall(self, input: str) -> ToolOutput: