refac: gate code interpreter tag detection to legacy tool-calling mode (#29024)

Tag detection for the code interpreter ran regardless of the tool-calling mode, so a model in Native (Agentic) Mode that emitted <code_interpreter> blocks in ordinary reply text had that code sent to the executor. Native mode never teaches the tag format and exposes execute_code as a builtin tool, so the parser had nothing legitimate to pick up there.

Gates detection on the legacy mode, matching the condition that already decides whether the tag prompt is injected at all. The five authorization checks are unchanged, and native mode keeps executing through the tool.

Deployments on native mode whose models emit the tags unprompted will now see them rendered as text.
This commit is contained in:
Classic298
2026-08-25 21:33:55 +02:00
committed by GitHub
parent 28f2965934
commit ac85b0f2a2
+4 -3
View File
@@ -4583,13 +4583,14 @@ async def streaming_chat_response_handler(response, ctx):
reasoning_tags_param = metadata.get('params', {}).get('reasoning_tags')
DETECT_REASONING_TAGS = reasoning_tags_param is not False
# Mirror the five gates from utils/tools.py get_builtin_tools so the
# legacy XML-tag path enforces the same authz as native FC.
# Legacy tool-calling only: native FC gets execute_code as a builtin tool.
# Same five authz gates as utils/tools.py get_builtin_tools.
features = metadata.get('features', {}) or {}
model_capabilities = model.get('info', {}).get('meta', {}).get('capabilities') or {}
builtin_tools_meta = model.get('info', {}).get('meta', {}).get('builtinTools', {})
DETECT_CODE_INTERPRETER = (
bool(features.get('code_interpreter'))
metadata.get('params', {}).get('function_calling') == 'legacy'
and bool(features.get('code_interpreter'))
and builtin_tools_meta.get('code_interpreter', True)
and await Config.get('code_interpreter.enable')
and model_capabilities.get('code_interpreter', True)