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 authored and GitHub committed 2026-08-25 15:33:55 -04:00
1 parent 28f2965934
commit ac85b0f2a2
1 file changed
+4 -3
+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') reasoning_tags_param = metadata.get('params', {}).get('reasoning_tags')
DETECT_REASONING_TAGS = reasoning_tags_param is not False DETECT_REASONING_TAGS = reasoning_tags_param is not False
# Mirror the five gates from utils/tools.py get_builtin_tools so the # Legacy tool-calling only: native FC gets execute_code as a builtin tool.
# legacy XML-tag path enforces the same authz as native FC. # Same five authz gates as utils/tools.py get_builtin_tools.
features = metadata.get('features', {}) or {} features = metadata.get('features', {}) or {}
model_capabilities = model.get('info', {}).get('meta', {}).get('capabilities') or {} model_capabilities = model.get('info', {}).get('meta', {}).get('capabilities') or {}
builtin_tools_meta = model.get('info', {}).get('meta', {}).get('builtinTools', {}) builtin_tools_meta = model.get('info', {}).get('meta', {}).get('builtinTools', {})
DETECT_CODE_INTERPRETER = ( 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 builtin_tools_meta.get('code_interpreter', True)
and await Config.get('code_interpreter.enable') and await Config.get('code_interpreter.enable')
and model_capabilities.get('code_interpreter', True) and model_capabilities.get('code_interpreter', True)