Skip to content

Run Codex native goals through persistent App Server threads #2012

Closed as not planned

Description

@integry

Context

Part of #2004 and #2002. Depends on #2007. Codex App Server already provides native thread goal state and automatic continuation; ProPR must use it rather than recreate a planner.

Scope

Run one goal-scoped codex app-server session using generated protocol bindings. Start/resume a thread, set its native goal, stream state/output, and resume the exact thread after failure. Preserve existing codex exec one-shot behavior.

Requirements

  • Generate the used App Server bindings from the exact Dockerfile.agent Codex pin (0.151.0 at this issue revision); version-check the running image and required methods, and fail closed on drift.
  • Start a thread and call thread/goal/set with the objective. Use thread/goal/get, native status notifications, and thread/goal/clear as defined by the protocol.
  • Return the generated thread ID, distinct session ID, active turn identity, and required resume metadata to the Sub-epic: Durable control surface for agent-native goals #2003 SQL controller before recoverability is reported; the adapter owns no separate database.
  • Resume the same thread after daemon/container replacement and allow native automatic goal continuation.
  • Stream terminal, assistant/tool, native plan/todo, usage, checkpoint, status, and completion events in stable order.
  • Deliver FIFO corrections to the same thread and acknowledge after App Server acceptance.
  • Pause/resume through native goal status/turn boundaries; cancel separately.
  • Apply supported model/reasoning changes at the next native boundary and report requested/effective values.
  • Preserve the exact worktree/branch; isolate writable Codex state between goals.
  • Pass parallelism/Ultrafix preferences to Codex as goal policy. Codex owns its plan and any subagents.
  • Do not implement a ProPR goal planner, node hierarchy, or scheduler.

Acceptance

  • Contract tests cover thread start, thread/goal/set|get|clear, automatic continuation, persisted ID, fresh-container resume, FIFO steering, pause/resume, model acknowledgement, and completion.
  • Forced-kill tests resume the same thread without a second goal or duplicate accepted input.
  • Two goals cannot see/resume each other's thread.
  • Existing codex exec issue/review tests remain green.
  • Pinned-image smoke proves the native goal survives supervisor replacement.

Activity

  1. added
    enhancement
    base-2004-epic-goal-agent-runtimes
    and removed on Aug 31, 2026
  2. integry commented on Aug 31, 2026

    @integry
    OwnerAuthor

    Planning refinement from the current official Codex App Server contract: https://learn.chatgpt.com/docs/app-server

    Treat these as acceptance criteria in addition to the issue body:

    • Use the supported default stdio JSONL transport between the ProPR supervisor and the goal-scoped App Server process. Do not expose the experimental WebSocket listener as the production control path.
    • Perform the required initialize request plus initialized notification exactly once per transport connection before any thread method.
    • Generate TypeScript or JSON schemas from the exact pinned Codex CLI version using codex app-server generate-ts or generate-json-schema, and fail closed with an actionable version/schema diagnostic.
    • Persist the returned thread.id and read thread.sessionId rather than deriving either value.
    • Use thread/goal/set, get, and clear for the same durable goal state exposed by /goal; enforce the documented non-empty 4,000-character objective limit.
    • Use turn/steer with expectedTurnId for accepted corrections during an active turn. If a correction is designated for a safe boundary or there is no active turn, retain it durably and deliver it through the next turn/start instead of pretending turn/steer accepted it.
    • Model overrides belong at turn/start or thread/resume boundaries; record the documented warning and one-time switch behavior when resuming with a different model.
    • Handle initialization rejection, overload/protocol errors, unknown notifications, and turn/completed or interrupted states deterministically.

    The official contract confirms this is a deep product integration, not a replacement with one-shot codex exec. Keep App Server local to the goal container and expose only the authenticated ProPR goal API/realtime surface to remote or Dockerized clients.

  3. integry commented on Aug 31, 2026

    @integry
    OwnerAuthor

    Provider preflight refinement for implementation:

    • Target the repository-pinned Codex 0.146.0 and generate/consume that image's App Server schema. The pinned image exposes thread/start, thread/resume, thread/goal/{set,get,clear}, turn/{start,steer,interrupt}, but no pause RPC and no active-turn resume RPC. Implement pause at the completed discrete-turn boundary under Introduce a thin resumable native-goal session and container contract #2007's capability-aware after_turn mode; never use terminal turn/interrupt as pause or claim same-turn continuation.
    • Use a distinct duplex stdio JSON-RPC client with initialize/initialized handshake, request correlation, bounded NDJSON framing, event dispatch, approval/tool handling, and version/schema compatibility errors. Do not reuse the codex exec --ephemeral --json parser or legacy stdin-close executor, and keep that one-shot path unchanged.
    • Provider session identity is the Codex thread ID. Persist it plus credential-free goal/turn/model checkpoints before recoverability. Use turn/steer only with the exact active expectedTurnId; durable message acknowledgement follows successful RPC acceptance. Messages arriving without an active turn remain FIFO pending for the next turn.
    • Model/reasoning applies at turn/start or supported thread resume, so acknowledge next_turn; never pretend turn/steer changed it. Validate goal status/tokens/time fields and keep ProPR's scheduler authoritative for parallelism.
    • Use a per-goal writable CODEX_HOME/session volume. Existing one-shot mounts agent config RW and the entrypoint creates sessions there; goal auth/config must come from a vetted read-only source/bootstrap without sharing writable sessions across goals or chowning the credential mount.
    • Add pinned-image schema/handshake/thread-goal/restart smoke, fresh-container same-thread resume, cross-goal isolation, pause-after-turn, terminal interrupt distinction, exact-turn steering/idempotence, next-turn model change, protocol chunk/error/approval/rate-limit tests, and unchanged legacy codex exec tests.
  4. integry commented on Aug 31, 2026

    @integry
    OwnerAuthor

    Owner foundation-conformance addendum

    • Implement the merged GoalSessionAdapter directly and export an injectable factory plus literal capability descriptor. The goal-session supervisor and injected container/recovery ports remain authoritative; do not couple this adapter to routes, Redis, queues, or a provider database.
    • Honor exact durable identities for turns (goal/session/controllerEpoch/turn/execution/attempt), steering (messageId), model changes (modelChangeId + monotonic application generation), cancellation (cancellationId), and reconciliation (controllerEpoch/operationToken/execution/attempt). Same-ID retries are effect-idempotent; stale generations cannot resume, emit, acknowledge, or overwrite. Reconcile ambiguous provider success instead of blindly replaying.
    • Persist only a versioned minimal credential-free recovery schema. Normalize explicit safe event fields with stable provider occurrences/cursors, one terminal completion, and retry-safe goal-attributable usage watermarks. Never attribute account-wide usage.
    • Keep auth/config read-only and separate from goal-scoped writable state; no secrets, host paths, argv, arbitrary envelopes, or cross-goal IDs in state/events/errors/logs/labels/recovery metadata. Use the hardened goal container supervisor and exact goal/session/execution/attempt/worktree identity.
    • Probe versions/capabilities before side effects and return typed incompatibility/blocked failures instead of fallback. Preserve one-shot execution. Contract tests inject crashes before/after provider acceptance, checkpoint, ack, model application, cancellation, and terminal output; retry identical IDs, reverse old/new completions, reopen fresh, and prove isolation/no post-terminal output.

    Codex App Server protocol decisions

    Use the pinned Codex 0.146.0 schema generated from the installed image and the current official App Server contract.

    • Use supervised-container stdio JSONL only; do not expose experimental WebSocket or process/*. Declare nativeSessionId: 'eager', steering: 'active_turn', pause: 'after_turn', modelChange: 'next_turn'. Every replacement connection performs initialize then initialized and probes required stable methods/schema before thread/start.
    • providerSessionId is exactly returned thread.id, the resume key; persist returned thread.sessionId separately and never derive/substitute/fork it. Lost pre-persistence thread identity fails closed unless deterministic exact discovery is proven. Use an isolated writable goal-scoped Codex home/session store with minimum read-only auth/config; one goal's thread/list cannot reveal another's.
    • Reconcile thread/goal/get before thread/goal/set; set the objective once, persist its digest, and update status/budget without replacing the objective/resetting native usage. Reject a different provider goal bound to the same thread.
    • Preserve exact gpt-5.6-sol. Discover model and supported reasoning via model/list; absence is typed incompatibility, never permission to choose a default/Terra/other model. Apply requested model/reasoning at next turn/start; thread/resume uses last effective model. Record model/rerouted requested vs effective state.
    • Active steering uses turn/steer with exact threadId and expectedTurnId. Because App Server has no documented messageId idempotency, keep a goal-scoped acceptance ledger and reconcile thread items after response loss. Pause does not call turn/interrupt: wait for turn/completed and prevent another turn. Cancellation calls turn/interrupt, then waits/reconciles terminal interrupted idempotently.
    • On loss, use thread/read(includeTurns) then thread/resume to classify the last turn. Any fresh provider continuation remains the same fenced ProPR logical turn with a durable mapping; never duplicate accepted messages/external work.
    • Normalize authoritative item lifecycle, agent/tool/command/file events, plan updates, terminal turns, errors, reroutes, and thread/tokenUsage/updated; item completion is authoritative. Persist token watermarks and never use account-wide usage as goal usage.
    • Bound server-initiated approvals, tool input, MCP elicitation, and auth refresh. Configure them away when allowed or transition to typed blocked/failed; never hang or auto-approve beyond policy.
    • Pinned-image smoke tests cover schema generation, exact Sol model, thread/session IDs, goal usage preservation, right/wrong expectedTurnId, interrupt-vs-pause, death during tool/approval, accepted-steer response loss, token replay, reroute, and fresh-container resume.
  5. integry commented on Aug 31, 2026

    @integry
    OwnerAuthor

    Provider launch gate addendum — do not start until corrected #2007/#2017 is merged into 2004-epic-goal-agent-runtimes. Use Codex GPT-5.6 Sol only and target #2004. Rebase on the frozen shared supervisor/security/recovery contract; this leaf must not fork or duplicate it.

    Codex-specific acceptance:

    • Pin Codex 0.146.0 and use the generated App Server schema over supervised stdio JSONL. Do not use the experimental WebSocket transport.
    • Implement initialize/initialized then thread/start through the shared control-scoped supervised-open context. Persist the exact thread ID and thread.sessionId; never invent a fake turn/session.
    • Preserve exact gpt-5.6-sol selection. A next-turn model change is supplied to turn/start and settles only from authoritative response/event evidence for the exact modelChangeId/generation/execution/attempt.
    • Correlate JSON-RPC IDs through the shared ordered/backpressured output observer. Bound pending requests, lines, total bytes, timeouts, and unknown notifications; sanitize all error/result metadata.
    • Active steering uses turn/steer with exact expectedTurnId and a durable message acceptance ledger that reconciles response loss without duplicate steering. Pause is after-turn. Cancellation uses turn/interrupt and the shared terminal fence.
    • Persist a versioned credential-free codec for App Server/schema/CLI version, thread/session identity, active turn, accepted message IDs, stream cursor, and per-component usage watermarks.
    • Every App Server effect atomically enforces the shared provider barrier and stable operation identity.
    • Test crash/response loss before and after initialize, thread/start, turn/start, steer, interrupt, model evidence, and local commit; fresh-container resume; stale expectedTurnId; concurrent intents; hostile/chunked JSON-RPC; credential isolation; and existing one-shot Codex regressions.
  6. changed the title [-]Run Codex goals through persistent App Server threads[/-] [+]Run Codex native goals through persistent App Server threads[/+] on Sep 2, 2026
  7. integry commented on Sep 2, 2026

    @integry
    OwnerAuthor

    Superseded by #2071 and the simplified task-backed native /goal architecture. The unreleased branch is retained only for reference.

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

    base-2004-epic-goal-agent-runtimesenhancementllm-codex-gpt56-solpropr-planned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions