guides/async-tool-calling.md +62 −1
517 {517 {
518 "type": "function",518 "type": "function",
519 "name": "wait_for_tasks",519 "name": "wait_for_tasks",
520520 "description": "Wait for selected tasks whose results you need. Pass a nonempty list of distinct task_handles from your earlier lookup_price calls. Results arrive on their original calls; this tool returns status only. Do not wait again for results that have already arrived.", "description": "Wait for selected tasks whose results you need. Pass a nonempty list of distinct task_handles from your earlier async tool calls. Results arrive on their original calls; this tool returns status only. Do not wait again for results that have already arrived.",
521 "strict": true,521 "strict": true,
522 "parameters": {522 "parameters": {
523 "type": "object",523 "type": "object",
600 600
601Set `previous_response_id` to the latest response ID, and include the tools and instructions in the continuation request. Your application can also deliver results as they become available, without a wait call. Only use the wait tool when the model's next step depends on results that haven't arrived.601Set `previous_response_id` to the latest response ID, and include the tools and instructions in the continuation request. Your application can also deliver results as they become available, without a wait call. Only use the wait tool when the model's next step depends on results that haven't arrived.
602 602
603## Add a tool to ask the user for input
604
605An async tool can ask the user a question while the model continues independent work. For example, the model can ask who a report is for, gather facts while the user answers, and use the answer to tailor the report.
606
607Define a function with `async: true` to request missing information or a preference. Your application displays the question, collects the reply, and returns it as the tool result. Its schema and behavior belong to your application. `request_user_input_async` isn't a built-in Responses tool.
608
609Add this definition to the request's `tools` array alongside `wait_for_tasks`:
610
611```json
612{
613 "type": "function",
614 "name": "request_user_input_async",
615 "async": true,
616 "description": "Ask the user for missing information or a preference. Choose a fresh task_handle unique within this conversation, including completed tasks. Continue independent work while the answer is pending. Use wait_for_tasks when your next step depends on the answer.",
617 "strict": true,
618 "parameters": {
619 "type": "object",
620 "properties": {
621 "question": { "type": "string" },
622 "task_handle": { "type": "string" }
623 },
624 "required": ["question", "task_handle"],
625 "additionalProperties": false
626 }
627}
628```
629
630### Display the question
631
632When the complete call item arrives, register the question's `task_handle` and original `call_id`, then display the question to the user. The following illustrative output item asks about the report's audience:
633
634```json
635{
636 "type": "function_call",
637 "name": "request_user_input_async",
638 "async": true,
639 "call_id": "call_audience",
640 "arguments": "{\"question\":\"Who is the report for: executives or engineers?\",\"task_handle\":\"report_audience_1\"}"
641}
642```
643
644Keep the question pending in the same registry used by the wait tool. While the user answers, continue consuming the model's response. Don't complete the tool call with an acknowledgment that you displayed the question; its result is the user's answer.
645
646### Return the user's answer
647
648When the user replies, send the answer on the question's original `call_id`. For example, include this output item in the next request's `input` array:
649
650```json
651[
652 {
653 "type": "function_call_output",
654 "call_id": "call_audience",
655 "output": "{\"task_handle\":\"report_audience_1\",\"answer\":\"Executives\"}"
656 }
657]
658```
659
660Set `previous_response_id` to the latest response ID, and include the tools and instructions in the continuation request. If the model called `wait_for_tasks` for `report_audience_1`, return the answer before the wait status, as in the [wait tool example](#deliver-results-before-wait-status).
661
662Async execution doesn't keep a response open until the user replies. Instruct the model to continue independent work and wait before taking a step that requires the answer. If your application supports dismissing or timing out a question, return an explicit no-answer result so the model can decide how to proceed.
663
603## Compatibility664## Compatibility
604 665
605Async tool calling is supported by GPT-6 Astra and later models.666Async tool calling is supported by GPT-6 Astra and later models.