Skip to content

Expose Goal APIs in the TypeScript SDK #29283

Open

Description

@nil4u

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/set
  • thread/goal/get
  • thread/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 through Thread.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

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.

Activity

  1. Necmttn commented on Jun 21, 2026

    @Necmttn

    Goal APIs should expose state and accounting, not only set/clear. A typed surface could return goal id, objective, status, token budget, consumed tokens, created_at, updated_at, last turn id, and terminal reason. Integrations can then pause/resume or render progress without asking the model to describe its own goal state in natural language.


    Generated with ax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app-serverIssues involving app server protocol or interfacesenhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions