Commit a319483

benny-dou <60535774+benny-dou@users.noreply.github.com>
2026-04-13 02:02:00
feat(asr): disable appending tool results
1 parent 9105045
Changed files (2)
src/ai/texts/openai_response.py
@@ -40,6 +40,7 @@ async def openai_responses_api(
     openai_allow_file: bool = False,  # whether to allow file in input modalities
     openai_media_send_as: Literal["base64", "file_id"] = "file_id",
     skills: str = "",
+    openai_append_tool_results: bool = True,
     hide_thinking: bool = False,
     silent: bool = False,
     max_retries: int = 3,
@@ -107,6 +108,7 @@ async def openai_responses_api(
                 params=params,
                 prefix=prefix,
                 hide_thinking=hide_thinking,
+                openai_append_tool_results=openai_append_tool_results,
                 silent=silent,
                 max_retries=max_retries,
                 **kwargs,
@@ -149,6 +151,7 @@ async def single_api_response(
     *,
     prefix: str = "",
     hide_thinking: bool = False,
+    openai_append_tool_results: bool = True,
     silent: bool = False,
     retry: int = 0,
     max_retries: int = 3,
@@ -258,11 +261,13 @@ async def single_api_response(
                 prefix=prefix,
                 retry=retry + 1,
                 max_retries=max_retries,
+                openai_append_tool_results=openai_append_tool_results,
                 hide_thinking=hide_thinking,
                 silent=silent,
                 **kwargs,
             )
-        answers = add_tool_call_results_to_response(tool_calls, answers)
+        if openai_append_tool_results:
+            answers = add_tool_call_results_to_response(tool_calls, answers)
         if await count_without_entities(prefix + answers) <= TEXT_LENGTH - 10:  # short answer in single msg
             quoted = answers.strip()
             await modify_progress(message=status_msg, text=f"{prefix}{blockquote(quoted)}", force_update=True)
@@ -286,6 +291,7 @@ async def single_api_response(
                 prefix=prefix,
                 retry=retry + 1,
                 max_retries=max_retries,
+                openai_append_tool_results=openai_append_tool_results,
                 hide_thinking=hide_thinking,
                 silent=silent,
                 **kwargs,
src/asr/corrector.py
@@ -119,6 +119,9 @@ async def asr_corrector(inputs: str, reference: str | None = None, corrector_mod
             "responseMimeType": "application/json",
             "responseJsonSchema": JSON_SCHEMA,
         },
+        openai_append_tool_results=False,
+        gemini_append_grounding=False,
+        cache_response_ttl=0,
         silent=True,
     )
     with suppress(Exception):