Skip to content

Run resumable Claude native goals with steering and model changes #2013

Closed as not planned

Description

@integry

Context

Part of #2004 and #2002. Depends on #2007. Claude Code itself owns planning and continuation through native /goal; ProPR hosts one resumable session.

Official behavior: /goal works non-interactively and active goals restore on every resume route. The Dockerfile.agent pin is Claude Code 2.1.220 at this issue revision and exposes streaming input/output, explicit session IDs, and resume.

Scope

Add a thin Claude transport using the existing unified agent container. Preserve current one-shot Claude behavior and do not introduce a Claude-specific database or supervisor.

Runtime contract

  • Allocate and persist the goal's UUID/session intent in the Sub-epic: Durable control surface for agent-native goals #2003 SQL controller before starting the external process.
  • Start the pinned CLI with native goal input, semantically:
    claude --print "/goal <objective>" --session-id <uuid> --input-format stream-json --output-format stream-json --verbose --replay-user-messages --permission-mode auto.
    Use argument arrays/stdin; never interpolate the objective into a shell command.
  • Keep normal ProPR credential/config mounts and worktree/container isolation. Do not use --no-session-persistence.
  • Parse the closed Claude stream into bounded terminal, assistant/tool, native task/plan when available, usage, checkpoint/status, and completion events for the shared durable sink.
  • Deliver one SQL-claimed FIFO correction through stream-json stdin and acknowledge only after Claude's replay/acceptance event.
  • On daemon/process/container loss, reconnect the exact session with --resume <uuid> and the restored provider-state mount/worktree. Native /goal restoration is authoritative; never replay the original objective as a second goal.
  • Pause by quiescing/terminating at the documented recoverable boundary and leaving the active goal/session durable; resume the same session. Cancel uses native goal clear/cancel semantics and remains distinct from pause.
  • Apply supported model/reasoning changes on a documented resume/turn boundary and report requested/effective values. Unsupported live changes must be capability-gated.
  • Fail closed if the running CLI version/capabilities differ from the pinned image or /goal is unavailable because hooks/workspace policy disables it.
  • Bound retention and redact credentials/sensitive values.

Acceptance

  • A pinned-image smoke proves /goal appears in the initialization capabilities and a streamed invocation yields a session ID before work.
  • Contract tests cover native start, FIFO stream input acknowledgement, active-goal resume after SIGTERM and fresh-container replacement, pause/resume, model/reasoning boundary, cancel/clear, and completion.
  • Forced kills before and after first output deterministically reconnect the same controller-chosen session UUID without a second goal.
  • Concurrent goals have isolated writable Claude state and cannot resume each other's sessions.
  • Existing Claude one-shot, abort, reasoning, credential, and Docker tests remain green.

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

    Provider preflight refinement for implementation:

    • Keep the current one-shot Claude path exactly separate: it intentionally uses -p - --no-session-persistence --output-format stream-json, and tests assert that. A goal-specific builder/entrypoint must omit only the goal path's no-persistence flag and use provider-supported --resume <session> discrete invocations.
    • Existing Claude entrypoint and repo setup expect /home/node/workspace, while Introduce a thin resumable native-goal session and container contract #2007's generic supervisor currently mounts /workspace. Align a goal-specific workspace contract/entrypoint and test real editing/resume; do not start outside the mounted worktree.
    • Existing one-shot mounts .claude and optional .claude.json RW, chowns them, and creates mutable dirs. Define a Claude-specific read-only credential/config source plus per-goal writable session home; no chown/write to RO credentials, no cross-goal transcript/session data, and no secrets in argv/events/recovery metadata.
    • Claude steering/pause/model change should default to documented next-turn/safe-boundary semantics: finish/checkpoint the current -p invocation, pause dispatch, then invoke the same session on resume. Do not keep stdin open or map kill/SIGSTOP to checkpoint. Only advertise active-turn behavior if the pinned CLI proves it.
    • Strictly validate/persist the first session_id (not conversation_id) before recoverability. Define deterministic pre-ID and post-ID kill handling. Use an incremental bounded stream-JSON parser with stable message/tool IDs, per-attempt deduplication, and a policy preventing cumulative usage double counts.
    • Carry existing Docker security/resource/network/repo-setup/ownership hardening into the goal path. Reconcile epoch/container, branch/head, expected dirty diff/hash, and external GitHub side effects before resume.
    • Add pinned Claude 2.1.220 create/resume smoke, legacy no-session-persistence regression, workspace and RO-credential discovery tests, pre/post-ID kill, FIFO next-turn steering, pause/restart, supported/unsupported model+effort change with CLI-version gating, cross-goal isolation, parser chunk/malformed/dedup/usage cases, and secret-redaction checks.
  3. 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.

    Claude session protocol decisions

    • For pinned Claude Code 2.1.220, probe explicit --session-id and exact --resume; declare nativeSessionId: 'eager', steering: 'next_turn', pause: 'after_turn', modelChange: 'next_turn'.
    • Generate/durably bind one goal UUID before first invocation; create with --session-id <uuid> and always resume with --resume <same uuid>. Never use bare --continue; if explicit ID is unsupported, fail compatibility. Omit --no-session-persistence.
    • Limit recovery metadata to session UUID, pinned protocol/CLI version, goal-relative transcript key, durable cursor, effective model/reasoning, and usage watermark. Split writable session/transcript state from minimum read-only auth/config; do not reuse current one-shot shared writable .claude/.claude.json mounts.
    • Treat each invocation as a discrete turn on the same session. Include FIFO corrections with stable markers; acknowledge only after the exact transcript accepts them and inspect transcript before retrying response loss. Pause waits for terminal invocation and prevents the next; cancellation targets exact container/attempt idempotently.
    • Apply model/reasoning only on next invocation and require effective provider evidence. Normalize stable messages/content blocks/tool uses/todos/results with cursor dedupe; emit usage/cost once per accepted turn.
    • Reconciliation verifies exact session files, transcript tail, active invocation, worktree fingerprint, and partial external effects. Missing/corrupt/foreign state blocks or fails; never create a replacement session.
    • Pinned-image tests cover pre-invocation crash, post-bind crash, partial transcript, duplicate message retry, stale output, after-turn pause, model/reasoning switch, missing/corrupt state, reverse cancel/recovery completion, isolated concurrent homes, and fresh-container exact-session resume.
  4. 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.

    Claude-specific acceptance:

    • Pin Claude Code 2.1.220. Use a deterministic pre-generated provider UUID for eager identity, exact --session-id on creation, and exact --resume thereafter; never replace or guess an identity after an ambiguous call.
    • Run every invocation through the shared hardened supervisor with isolated per-goal writable Claude home/session state and only explicitly approved read-only auth material.
    • Consume only the ordered/backpressured supervised output observer. Parse stream-json incrementally across chunk boundaries into closed assistant/tool/todo/checkpoint/usage events; bound lines/records/bytes and redact hostile output without raw metadata leakage.
    • Steering, pause, and model changes follow the documented after-turn/next-invocation boundary. Pass stable message/model IDs to the next invocation and settle only from authoritative invocation evidence tied to exact execution/attempt/occurrence.
    • Persist a versioned credential-free codec for CLI/protocol version, session/reasoning/transcript identity, stream cursor, accepted messages, and usage watermarks; reject corrupt/missing/cross-goal/version-drift state.
    • Every spawn/resume/cancel effect atomically enforces the shared provider barrier and stable idempotency identity.
    • Test fresh-container resume, kill/response-loss windows around first and resumed invocations, rapid model changes, FIFO corrective messages, cancellation, credential isolation, corrupt recovery, parser/backpressure/oversize/hostile streams, exact usage replay, and existing one-shot Claude behavior.
  5. changed the title [-]Resume, pause, steer, and switch models in Claude goal sessions[/-] [+]Run resumable Claude native goals with steering and model changes[/+] on Sep 2, 2026
  6. 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