From f3738b06f198754409c6a60875b63e2667d65119 Mon Sep 17 00:00:00 2001 From: Russell Valentine Date: Wed, 17 Sep 2025 04:54:06 -0500 Subject: [PATCH] Fixes session_id passing in agent_openai completion. (#10124) ### What problem does this PR solve? An exception happens if you give session_id to agent_open_ai completion. Because session_id is being given as well as **req so it tries to send session_id twice. But also the logic seemed odd on picking one of session_id, id, metadata.id. So cleaned it up a little. See #10111 ### Type of change - [X] Bug Fix (non-breaking change which fixes an issue) --- api/apps/sdk/session.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/apps/sdk/session.py b/api/apps/sdk/session.py index 80e45a778..8e4f5ee67 100644 --- a/api/apps/sdk/session.py +++ b/api/apps/sdk/session.py @@ -414,7 +414,7 @@ def agents_completion_openai_compatibility(tenant_id, agent_id): tenant_id, agent_id, question, - session_id=req.get("session_id", req.get("id", "") or req.get("metadata", {}).get("id", "")), + session_id=req.pop("session_id", req.get("id", "")) or req.get("metadata", {}).get("id", ""), stream=True, **req, ), @@ -432,7 +432,7 @@ def agents_completion_openai_compatibility(tenant_id, agent_id): tenant_id, agent_id, question, - session_id=req.get("session_id", req.get("id", "") or req.get("metadata", {}).get("id", "")), + session_id=req.pop("session_id", req.get("id", "")) or req.get("metadata", {}).get("id", ""), stream=False, **req, )