Add optional code_interpreter built-in tool to chat (opt-in)

Author: pamelafoxCreated Jun 25, 2026Updated Jun 25, 2026

Summary

Add an opt-in setting that attaches the OpenAI Responses code_interpreter built-in tool to chat answer calls, so the model can run Python for computational questions (math, data analysis over retrieved content).

Motivation

Some questions need real computation (percentages, aggregations, unit conversions). Wiring code_interpreter as an optional, off-by-default tool adds capability without changing how answers are normally generated — so existing answer-quality evals remain valid.

Proposed implementation

Follow the existing tool/override pattern (e.g. use_web_source):

  • Backend (app/backend/approaches):
    • In chatreadretrieveread.py, read overrides.get("use_code_interpreter") and, when true, append {"type": "code_interpreter", "container": {"type": "auto"}} to the tools list passed to create_response() for the final answer call.
    • create_response() in approach.py already forwards tools to responses.create — no change needed there.
    • Surface tool invocations as a ThoughtStep so they appear in the thought process panel.
  • Frontend:
    • Add use_code_interpreter?: boolean to the overrides in api/models.ts.
    • Add a toggle in components/Settings/Settings.tsx, wired through pages/chat/Chat.tsx like other override checkboxes.
  • Docs: note the setting in the relevant docs/ customization page.

Scope / out of scope

  • In scope: opt-in toggle, backend tool wiring, thought-process visibility.
  • Out of scope: changing default answer-generation prompts; enabling by default.

Acceptance criteria

  • Toggle in Settings; off by default.
  • When on, code_interpreter is attached to the answer call and the model can execute Python.
  • Tool runs visible in the thought process.
  • When off, request payload is unchanged (no eval impact); existing tests pass.

Source: Azure-Samples/azure-search-openai-demo