RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Fix KeyError in session listing endpoint when accessing conversation reference (#9419)
Mckennasora7ee5e0d15270
diff --git a/api/apps/sdk/session.py b/api/apps/sdk/session.pyindex c3c855ce7d..a066fa89c8 100644--- a/api/apps/sdk/session.py+++ b/api/apps/sdk/session.py@@ -589,14 +589,22 @@ def list_agent_session(tenant_id, agent_id):if "prompt" in info:info.pop("prompt")conv["agent_id"] = conv.pop("dialog_id")+ # Fix for session listing endpointif conv["reference"]:messages = conv["messages"]message_num = 0chunk_num = 0+ # Ensure reference is a list type to prevent KeyError+ if not isinstance(conv["reference"], list):+ conv["reference"] = []while message_num < len(messages):if message_num != 0 and messages[message_num]["role"] != "user":chunk_list = []- if "chunks" in conv["reference"][chunk_num]:+ # Add boundary and type checks to prevent KeyError+ if (chunk_num < len(conv["reference"]) and+ conv["reference"][chunk_num] is not None and+ isinstance(conv["reference"][chunk_num], dict) and+ "chunks" in conv["reference"][chunk_num]):chunks = conv["reference"][chunk_num]["chunks"]for chunk in chunks:new_chunk = {