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)
This commit is contained in:
Russell Valentine
2025-09-17 04:54:06 -05:00
committed by GitHub
parent 5a8bc88147
commit f3738b06f1

View File

@ -414,7 +414,7 @@ def agents_completion_openai_compatibility(tenant_id, agent_id):
tenant_id, tenant_id,
agent_id, agent_id,
question, 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, stream=True,
**req, **req,
), ),
@ -432,7 +432,7 @@ def agents_completion_openai_compatibility(tenant_id, agent_id):
tenant_id, tenant_id,
agent_id, agent_id,
question, 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, stream=False,
**req, **req,
) )