diff --git a/src/khoj/routers/api_chat.py b/src/khoj/routers/api_chat.py index a9086dd0..e9f31ea9 100644 --- a/src/khoj/routers/api_chat.py +++ b/src/khoj/routers/api_chat.py @@ -682,7 +682,7 @@ async def chat( cmd_set = set([cmd.value for cmd in conversation_commands]) chat_metadata = chat_metadata or {} chat_metadata["conversation_command"] = cmd_set - chat_metadata["agent"] = conversation.agent.slug if conversation.agent else None + chat_metadata["agent"] = conversation.agent.slug if conversation and conversation.agent else None chat_metadata["latency"] = f"{latency:.3f}" chat_metadata["ttft_latency"] = f"{ttft:.3f}"