Tool Calling — ML Junction docs
Tool definitions use the standard function-tool shape. Supplying tools automatically makes tool support a required route capability unless you explicitly selected another requirement before validation.
{
"model": "gpt-5.5",
"messages": [
{
"role": "user",
"content": "What is the weather in Kolkata?"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Return current weather for a city.",
"parameters": {
"type": "object",
"additionalProperties": false,
"properties": {
"city": { "type": "string" },
"units": {
"type": "string",
"enum": ["metric", "imperial"]
}
},
"required": ["city"]
}
}
}
],
"tool_choice": "auto",
"requirements": {
"tools": "required"
}
}
Preserve tool_call_id when sending a tool result back to the model.. Keep assistant tool calls and their tool responses together during context truncation.. Use capabilities.parallel_tools when your agent requires multiple calls in one model turn.. Treat tool arguments as untrusted input and validate them against your own schema before execution.
Continue a reasoning tool loop
When the response reasoning.phase is awaiting_tool_results, keep the original assistant tool calls, their reasoning_details, and the continuation token. Execute every required tool, append one tool message per call ID, and send input_type=tool_results. Do not replace the full history with only the newest tool result unless your integration deliberately uses the specialized tool-results-only contract.
{
"model": "gpt-5.5",
"messages": [
{
"role": "user",
"content": "Look up order 123 and tell me its status."
},
{
"role": "assistant",
"content": "",
"tool_calls": [
{
"id": "call_order_123",
"type": "function",
"function": {
"name": "lookup_order",
"arguments": "{\"order_id\":\"123\"}"
}
}
],
"reasoning_details": [
{
"type": "reasoning",
"encrypted_content": "provider-opaque-state"
}
]
},
{
"role": "tool",
"tool_call_id": "call_order_123",
"content": "{\"status\":\"shipped\",\"eta\":\"2026-07-18\"}"
}
],
"reasoning": {
"enabled": true,
"continuation_token": "gwrt_v3.opaque-routing-ticket",
"input_type": "tool_results",
"pending_turn_action": "continue"
},
"tools": [
{
"type": "function",
"function": {
"name": "lookup_order",
"description": "Look up an order by ID.",
"parameters": {
"type": "object",
"additionalProperties": false,
"properties": {
"order_id": { "type": "string" }
},
"required": ["order_id"]
}
}
}
]
}
Tool-loop problem · Gateway behavior · User action Required result is missing · HTTP 409 PENDING_TOOL_LOOP with expected, supplied, and missing IDs · Wait for or supply every result, or explicitly Cancel/Fork Unknown or duplicate result · Unsafe result is dropped and tool_history.dropped is returned · Fix the application mapping; inspect requested/effective IDs Normal user text interrupts a pending loop · PENDING_TOOL_LOOP prevents accidental continuation · Choose Continue, Cancel, or Fork intentionally Origin provider becomes unavailable · Native state is abandoned; eligible fallback receives portable visible history/tool messages · Accept the warning and fresh continuation state on success
Canonical URL: https://mljunction.com/docs/tools