Picture Carl, a Data Analyst, asked to prepare a comparison of mean petal length across Iris species. Instead of manually writing SQL and charting logic, he prompts an internal GPT-5 Agent: “Compute species-level means, then visualize petal length.” Behind the scenes, his Agentic workflow has two custom tools:
- sql_exec_csv – accepts raw SQL and returns CSV results from an Iris dataset.
- code_exec_javascript – executes raw JavaScript inside a hardened vm sandbox, parsing the CSV and rendering iris_plot.svg.
GPT-5 emits a SQL query (that's not wrapped in JSON), receives CSV output, generates JavaScript code that builds a chart, and finally summarizes the workflow—all in a handful of turns. This smooth, multi-tool flow is enabled by GPT-5’s FreeForm (custom) tool calling.
What Is FreeForm?
FreeForm (custom) tool calling allows GPT-5 to issue tool invocations whose payload is arbitrary unstructured raw text - SQL queries, Python scripts, JavaScript programs, Bash, config files, without being bound to JSON arguments conforming to a defined schema.
Traditional structured function calling solves reliable argument passing workloads but introduces friction for code-heavy and DSL-heavy workflows. You'd have to wrap code inside JSON strings, escape characters, then unpack and execute. With Freeform tool calling, you eliminate this round trip by registering a tool with { "type": "custom" } and GPT-5 can emit the exact text payload the tool expects - without the JSON envelope.
Why does this matter?
- No schema friction: The model speaks in the tool's native language allowing you to run what it produces, rather than parsing JSON to recover string values.
- Improved intermediate reasoning: Freeform output lets GPT-5 interleave natural-language commentary, raw code, and tool calls in a single response.
- Multi-step chaining: Each tool output re-enters the conversation as plain text, and GPT-5 can reason on it directly.
Dimension |
Structured Function Tools (JSON Schema) |
FreeForm Custom Tools |
|
Payload Shape |
Example "arguments":{...}
} |
Raw text (code/query/script) |
|
Validation |
Automatic via schema (types, required) |
Semantic validation implemented in executor |
|
Parsing Overhead |
JSON parsing + argument mapping |
Minimal (string pass-through) |
|
Ease of Tool Evolution |
Schema changes would require code and prompt updates |
Only need to update tool/ prompt descriptions |
|
Readability in Logs (Observability) |
Nested JSON obscures code |
Natural language |
|
Chaining Complexity |
Each step returns JSON that must be parsed |
Directly feed raw output back for the model to reason over |
|
Errors |
JSON malformed or missing required fields |
Runtime execution errors |
|
Application |
|
|
|
Tool discoverability |
Model matches tool name, description and the expected schema |
Model matches tool name and description |
When Not to Use FreeForm
- When strict validation is required (Ex. financial transaction parameters, coordinates, PII-handling flags).
- For complex nested data (arrays of objects, deeply nested configs) where schema ensures shape.
- For mass extraction tasks where consistent JSON accelerates downstream parsing.
Note: Depending on the scenario, you can implement a hybrid design to use structured tools for parameter selection and strict validation, then pass to custom (freeform) tools for code/ query execution.
Implementation breakdown - How Carl's Iris workflow is assembled
Pre-requisites
- Azure AI Foundry project
- GPT-5 model deployment - v1 API is required to access the latest model features
A link to the full sample code will be provided at the end of this blog, but here’s a minimal explanation of the core logic.
User prompt asking the model to produce SQL/ JavaScript as code blocks: -
-
Write SQL to compute mean of sepal_length, sepal_width, petal_length, petal_width grouped by species. Return a tidy CSV with species and the four means (rounded to 2 decimals).
-
Then write JavaScript to read that CSV string (provided as tool output), pretty-print a table, and produce a bar chart of mean petal_length by species.
Tool registry: Two custom tools are defined for the Responses API:
-
sql_exec_csv
Wraps an in-memory Iris dataset and returns CSV for SELECT queries, including a specialized path for group-by averages.
-
code_exec_javascript
Executes Node.js-compatible JavaScript inside a hardened vm context, capturing console output and rendering SVG charts via helper utilities.
Tools configuration of type custom - sql_exec_csv and code_exec_javascriptSQL Query generation and execution: First, the model generates the raw SQL query ...
GPT-5 generated raw SQL query following the prompt... then it explicitly asks to call the sql_exec_csv tool, passing in the full SQL string as the payload.
In structured function calling, you’d expect to see JSON input like:
"arguments": "{\"query\":\"SELECT ...\"}"
but in freeform tool calling, our custom tool isn't restricted to formatting the input in a JSON wrapper. Instead, it executes the raw SQL and returns a tidy CSV with the mean values rounded to 2 decimals, which is then wrapped in a function_call_output and inserted back into the conversation to feed into the context.
sql_exec_function executes the SQL from the model and returns CSVJavaScript Code Execution: GPT-5 calls the code_exec_javascript tool to parse the CSV, pretty-print a table in the console, create and save the chart visual. The model provides full executable code as the tool argument there being no schema to tell it what fields to send. It simply writes the program
The JS code is executed using code_exec_javascript codeOur output is a mix of the requested result and commentary from the model
Output including a console table, commentary from GPT-5 and the location of the chart fileThe generated chart fileGPT-5 FreeForm tool calling elevates agentic development with less schema scaffolding, more expressive multi-step execution, and execute deterministically. Combined with Azure AI Foundry’s enterprise-grade governance stack, developers can prototype analytical workflows (like Carl's Iris example) and harden them for production quickly.