Skip to main content
The shape: you already have an agent — a loop around a model, in a framework you chose. What it lacks is a computer: somewhere to run the code it writes, keep files between steps, install a package. Give it one tool that hands a task to a Gobare session and returns what happened. Your framework stays in charge. Gobare is the hands, not the brain. Verified with ai 5.0.266, @openai/agents 0.18.0 and zod 4.6.5 on Node 24. The OpenAI Agents SDK requires zod 4; the AI SDK accepts 3.25 or 4, so use 4 for both.

The function

Framework-neutral: a task in, a result out. Three behaviours worth having are built in.
The question check reads the session, not the turn: while a question is pending the turn still reports working, and the session reports requires_action. A loop that watched the turn alone would never return.

Vercel AI SDK

OpenAI Agents SDK

session_id is nullable() rather than optional() here: the Agents SDK sends tool schemas to OpenAI in strict mode, where every property must be present and absence is spelled null.

Cleaning up

These tools do not delete their sessions, because the next call may continue on them. Delete them when the conversation ends — or, for a request-scoped agent, in a finally after the framework’s run returns:
An idle session pauses on its own and stops costing sandbox time, but it keeps its concurrency slot until it is deleted. See limits.

What was verified

Run against production. The outer model was the AI SDK’s own MockLanguageModelV2 — a scripted stand-in that emits a real tool call — so the framework’s tool loop ran for real and only the model’s choice was fixed:
  • A computed answer, checked independently. The tool was asked for the SHA-256 of the string gobare, written to /workspace/outputs/hash.txt. The digest in the tool result matched one computed locally, and files listed /workspace/outputs/hash.txt. The AI SDK recorded two steps: the tool call, then the answer.
  • Continuation. The OpenAI Agents SDK tool, invoked with the previous session_id, printed the same file back — same computer, file intact.
  • A question passed up and answered. Asked to check with the caller before choosing csv or json, the inner agent’s call returned status: "waiting" with its question; calling again with json and the same session_id completed with /workspace/outputs/data.json.
Not verified: a real model choosing to call the tool. That is the framework’s behaviour and your prompt’s, not this function’s.

Next