Problem
An agent task may outlive the HTTP request or job that started it.
Code
Start the request asynchronously and store the rr_ id with your own task record.
const response = await reqrun.chat.completions.create({
model: "gpt-5-nano",
messages: [{ role: "user", content: "Run the agent task." }],
wait: false,
idempotency_key: "agent-task-991",
});
if (response.object === "chat.completion.async") {
const request = await reqrun.requests.get(response.id);
console.log(request.status, request.attempts);
}