fix: pass chat_id to internal task calls for consistent function context (#20585)

Ensure chat_id is reliably passed to function pipelines/manifolds during internal task invocations (web search query generation, RAG query generation, image prompt generation).

This allows stateful functions to maintain per-chat state without fragmentation, as they will now receive a consistent chat_id for all chat-scoped invocations including internal tasks.

Backend changes:
- Pass chat_id in generate_queries call for web search
- Pass chat_id in generate_queries call for RAG/retrieval
- Pass chat_id in generate_image_prompt call

Frontend changes:
- Add optional chat_id parameter to generateQueries API function
- Add optional chat_id parameter to generateAutoCompletion API function

Fixes #20563
This commit is contained in:
Classic298
2026-02-12 22:36:42 +01:00
committed by GitHub
parent 0dcbd05e24
commit e8499ccdd1
2 changed files with 12 additions and 5 deletions

View File

@@ -1255,6 +1255,7 @@ async def chat_web_search_handler(
"messages": messages,
"prompt": user_message,
"type": "web_search",
"chat_id": extra_params.get("__chat_id__"),
},
user,
)
@@ -1585,6 +1586,7 @@ async def chat_image_generation_handler(
{
"model": form_data["model"],
"messages": form_data["messages"],
"chat_id": metadata.get("chat_id"),
},
user,
)
@@ -1691,6 +1693,7 @@ async def chat_completion_files_handler(
"model": body["model"],
"messages": body["messages"],
"type": "retrieval",
"chat_id": body.get("metadata", {}).get("chat_id"),
},
user,
)