Expose Goal APIs in the TypeScript SDK
Summary
Please expose first-class Goal mode APIs in @openai/codex-sdk for TypeScript.
The app-server protocol already has thread goal RPCs:
thread/goal/setthread/goal/getthread/goal/clear
But the current TypeScript SDK primarily exposes Thread.run() / Thread.runStreamed() and wraps codex exec --experimental-json. That makes it difficult for SDK users to set, read, pause, resume, or clear goals programmatically without relying on prompt text such as "create a goal".
Proposed API shape
A possible high-level TypeScript API could be:
await thread.setGoal("Finish the migration and add tests", {
tokenBudget: 200_000,
});
const goal = await thread.getGoal();
await thread.pauseGoal();
await thread.resumeGoal();
await thread.clearGoal();
Possible lower-level status support:
await thread.setGoalStatus("paused");
await thread.setGoalStatus("active");
Why this matters
Goal mode is useful for long-running Codex work, but SDK users need a stable typed surface rather than prompt-level workarounds. A typed API would let integrations:
- create goals deterministically
- inspect current goal state and usage accounting
- pause/resume/clear active goals from external controllers
- avoid sending
/goal ...or natural-language instructions throughThread.run()and hoping they are interpreted as control commands - build long-running automation around Goal mode using the same primitives as the app-server protocol
Current workaround
Today, an SDK user can only approximate this by doing something like:
await thread.run(`Create a Codex goal with this exact objective: ${objective}`);
That depends on model/tool behavior rather than a typed SDK contract, and it does not provide direct getGoal, pauseGoal, resumeGoal, or clearGoal operations.
Related issues
- #23854 discusses that the TypeScript SDK currently wraps local
codex exec --experimental-jsonand does not expose a remote app-server / worker protocol client. - #25565 mentions the app-server thread goal RPCs and generated protocol/schema gap for Python SDK types.
- #28144 discusses long-running goals and SDK/app-server integrations that drive them.
Expected behavior
The TypeScript SDK should expose stable Goal APIs backed by the existing app-server goal RPCs, or otherwise document the intended TypeScript integration path for programmatic Goal mode control.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗