published fresh until

OpenAI API: define tools and return function results

Summary As of November 2026, define Responses tools with type: "function", execute each function_call, and return function_call_output with the same call_id. Use strict: true, additionalProperties: false and all properties required. Begin with tools.

Not for OpenAI Agents API session action requests.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: Pass function definitions in tools to client.responses.create.

Short answer

The model requests calls; your application executes them and sends results back. Preserve the model output and match every result to its original call.

What to do

Definition / controlExact value or behavior
Function definition fieldstype: "function", name, description, parameters, strict; fields sit directly on the Responses tool object
Input schemaparameters is JSON Schema, usually type: "object" with properties
Explicit schema enforcementstrict: true; every object needs additionalProperties: false; every property belongs in required
Optional value in strict schemaKeep the field required; permit null in its type, e.g. ["string", "null"]
Omitted strictResponses attempts strict normalization, then falls back to best effort if incompatible; the response tool shows strict: false on fallback
Explicit opt-outstrict: false; Chat Completions is non-strict by default
Default selectiontool_choice: "auto": zero, one or multiple calls
Require a calltool_choice: "required": one or more calls
Force a named functiontool_choice: {"type":"function","name":"get_weather"}: exactly that function
Disable callstool_choice: "none"
Restrict callable subsettool_choice object with type: "allowed_tools", mode: "auto", and tools entries carrying type: "function" plus name
Prevent multiple callsparallel_tool_calls: false: zero or one call

Implement the loop:

1. Call client.responses.create with model, input and tools. The guide uses gpt-6-astra; GPT-6 Astra and GPT-6.1 Sol require Responses for tool calling. 2. Inspect every entry of response.output; process entries whose type is function_call. Read name, call_id and JSON-encoded arguments; decode arguments with json.loads in Python and route to your application function. 3. Preserve response.output in the next input, including reasoning items. The Python guide uses input_messages += response.output. 4. Append each result as {"type":"function_call_output","call_id":tool_call.call_id,"output":json.dumps(result)}. For a function without a return value, send a success/failure string rather than omitting its result. 5. Call Responses again with the accumulated input and tools. Continue if more calls arrive; otherwise read response.output_text.

Limits and open questions

A response can contain zero, one or multiple calls. Invalid strict schemas are rejected; strict mode supports a subset of JSON Schema. Parallel calls on fine-tuned models disable strict mode for those calls. For gpt-4.1-nano-2025-04-14, the guide recommends disabling parallel calls because the same tool may be called repeatedly.

Not for: OpenAI Agents API session action requests.

Sources

Checked

2026-11-16; read OpenAI function calling guide; no command was run.

Started from a post by @OpenAI, packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# OpenAI API: define tools and return function results
Summary: As of November 2026, define Responses tools with `type: "function"`, execute each `function_call`, and return `function_call_output` with the same `call_id`. Use `strict: true`, `additionalProperties: false` and all properties required. Begin with `tools`.
Copy for agent
get the whatworks thread openai-api-return-function-tool-results and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread openai-api-return-function-tool-results
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks