Skip to content

Allow opted-in Actions to resume agent threads when they finish #13

Closed

Description

@lastobelus

Problem

Agents currently have to poll, spend turns sleeping, or ask the user to relay
completion when they start a process that outlives the current turn. LastCode
already owns configured Actions, thread identity, provider sessions, terminals,
and terminal-exit events, but it does not bridge one addressed Action result
back into the originating thread.

This feature should prove that bridge with one narrow, useful tracer before
introducing a general task or orchestration framework.

Proposed delivery

Slice 1: Quick-CI exit tracer

Add a local, per-Action setting, default off:

Allow this Action to resume agent threads

The permission is local LastCode state. A checked-in or imported t3.json
cannot enable it. Enabling it makes the Action eligible; it does not make normal
UI clicks or arbitrary terminal exits resume threads.

An agent explicitly invokes one dedicated, resume-capable LastCode MCP tool for
one configured Action. LastCode:

  1. derives the originating thread and provider session from the authenticated
    MCP invocation;
  2. opens a dedicated thread-scoped terminal and attaches its exit listener
    before launching the configured command;
  3. returns an arming receipt immediately and instructs the agent to finish
    its current turn; and
  4. after the Action reaches a terminal state and the thread is idle, starts
    exactly one follow-up turn on that same thread.

The arming receipt is a structured acknowledgement containing a server-generated
run ID, the wake condition, and the first-cut durability boundary. armed
describes the one-shot wake registration, not whether the process is still
running. It is not a polling handle, and the MCP surface supplies no wait or
status-poll operation.

The automated follow-up must be represented as LastCode machine activity, not
as a fake human message. Provider input contains only fixed LastCode-authored
control text, server-generated identifiers, and validated status values.

Output handoff

On exit, LastCode finalizes a bounded output artifact under T3 home in a
server-generated thread/run directory. The artifact contains a size-limited
suffix of terminal output after replay-unsafe control sequences are removed.
The wake supplies an artifact descriptor with its path, byte and line counts,
completion state, and truncation state, plus the exit code or signal and
duration.

No terminal output or generic last-line preview is inserted into the automatic
provider input. The resumed agent decides whether and how much of the completed
file to read. Its contents remain untrusted data.

The current Action terminal is a PTY and exposes a combined output stream. One
combined artifact is sufficient for the tracer. Separate stdout and stderr
artifacts would require a runner that pipes and tees both child streams back
into the visible terminal and are not required for this slice.

Retain artifacts through thread archive because archive is reversible. Delete
them with permanent thread deletion. Archived threads must not be resumed
automatically; the exact treatment of an Action still running when its thread
is archived must be fixed before implementation.

Slice 2: restart durability

The first tracer may truthfully report durability: current_lastcode_process.
A LastCode restart may terminate the Action and lose its in-memory wake
registration; persisted terminal evidence and a manual user resume are the
initial recovery.

The required second cut makes Action execution and its wake durable across a
full LastCode restart. Its finite test is:

  1. start an Action and finish the originating turn;
  2. restart LastCode while the Action is running;
  3. verify that the Action continues;
  4. recover a completion that occurs during or after the restart; and
  5. resume the originating thread exactly once when it is eligible.

Choose the smallest reattachable process-ownership and persisted-correlation
model that passes this test. Do not use this requirement to build a general
scheduler.

Slice 3: retention controls

Because archived threads may remain indefinitely, LastCode Settings should
report the count and disk use of completed Action artifacts and provide an
explicit cleanup command for artifacts belonging to archived threads. Cleanup
excludes running Actions and pending wakes and warns that an unarchived thread
will no longer have those logs.

An optional automatic retention policy may follow and defaults off. It is not a
prerequisite for the Quick-CI tracer.

Acceptance criteria

  • One real, locally opted-in Quick CI Action runs in a real LastCode-hosted
    terminal.
  • The originating agent turn ends before the Action finishes and consumes no
    polling turns while waiting.
  • The Action's terminal result and idle-thread state produce exactly one
    follow-up turn on the originating thread.
  • Ordinary Action clicks, unrelated terminals, and Actions without the local
    permission never arm a wake.
  • The arming receipt and visible machine activity truthfully distinguish the
    automated source from a human message.
  • Automatic provider input contains structured result metadata and an artifact
    descriptor, not terminal output.
  • The output artifact is readable on demand, bounded, marked as untrusted, and
    retained through archive until explicit cleanup or permanent thread deletion.
  • The first-cut restart limitation is visible and recoverable; the second-cut
    restart test above subsequently passes.
  • LastCode Settings eventually exposes artifact size and safe manual cleanup.

Explicit non-goals

  • A general task database, scheduler, or orchestration framework.
  • Arbitrary-command adoption or waking on every terminal exit.
  • Polling-based MCP Tasks emulation.
  • Readiness and input-required protocols, development-loop supervision, or
    Markover feedback wakeups in the first tracer.
  • Provider-neutral adapter machinery before the Codex-backed tracer proves the
    process-to-thread seam.
  • Separate stdout/stderr capture in the first slice.

MCP Tasks remains a later compatibility target when relevant hosts expose the
extension; the local tracer does not depend on host Tasks support.

Activity

  1. added
    enhancement
    on Aug 15, 2026
  2. lastobelus commented on Aug 17, 2026

    @lastobelus
    OwnerAuthor

    Work intent

    phase: implementing
    summary: "Deliver the first Codex-backed Action resume tracer: agents can discover locally configured Project Actions, explicitly run one opted-in Action, wait without polling, and receive exactly one honest same-thread machine follow-up, with web/desktop Waiting and cancellation UX."
    touch-points:
      - "Project Action local eligibility settings and web/desktop Actions UI"
      - "authenticated LastCode MCP discovery and run-tool contracts"
      - "thread-scoped Action terminal ownership, cancellation, exit handling, and bounded output artifacts"
      - "persisted Action-run and one-shot delivery state, machine-originated follow-up dispatch, restart reconciliation, archive/delete cleanup"
      - "web/desktop sidebar Waiting status, recovery notice, context-menu/popover cancellation, and desktop quit safeguard"
      - "focused contract, server, orchestration, terminal, web, and desktop tests plus user/internals documentation"
    done-when:
      - "An agent can list all configured Actions with stable IDs and local resume eligibility, then explicitly invoke one eligible Action from a prompt or skill-guided workflow."
      - "One Action per originating thread runs in a dedicated visible terminal; the originating turn ends and consumes no polling turns."
      - "While the thread is otherwise idle, web/desktop shows a yellow Waiting state; active work, approval, and input states take priority."
      - "Success, nonzero exit, signal, launch failure, or manual cancellation finalizes a bounded combined-output artifact and delivers exactly one visibly machine-originated follow-up on the same thread; terminal output is never injected."
      - "Waiting popover, thread context menu, and terminal close share one idempotent cancellation path; manual cancellation resumes once with cancelled_by_user."
      - "Archive cancels the Action and disposes its wake; delete removes managed artifacts; unarchive never re-arms."
      - "Interactive desktop quit warns that quitting will cancel the exact running-Action count; intentional shutdown does not nag on restart."
      - "Unexpected process loss is reconciled without replay: no automatic wake or unread flood, one dismissible aggregate notice, and per-thread on-demand Resume agent recovery."
      - "Focused tests prove idempotency, single-Action-per-thread rejection, status priority, cancellation races, restart reconciliation, and ordinary click/non-opted Action isolation."
    excludes:
      - "Action process survival or automatic wake delivery across a LastCode restart"
      - "time-based Action expiry or timeout"
      - "more than one concurrent resume-capable Action per thread"
      - "mobile Waiting or cancellation UI and mobile QA"
      - "provider-neutral adapters beyond the Codex-backed tracer"
      - "general task, scheduler, arbitrary-command, readiness, input-required, or Orchestrator V2 compatibility frameworks"
      - "separate stdout and stderr capture"
      - "slice 3 aggregate artifact size reporting, archived-artifact cleanup UI, and automatic retention"
    blocked-by: []
    may-block:
      - "concurrent edits to Action configuration, MCP registration, terminal ownership, orchestration turn start, desktop quit flow, or thread deletion"
    branch: "lastcode/action-resume-quick-ci"
  3. lastobelus commented on Aug 17, 2026

    @lastobelus
    OwnerAuthor

    Slice 2 work intent

    • Phase: implementing
    • Summary: add the mobile-facing controls for the Action-resume lifecycle already merged in slice 1
    • Touch points: mobile thread status/list rows, thread recovery card, mobile cancel menus, and the shared settled-thread classifier
    • Done when: mobile shows Waiting for a running Action, lets the user cancel it, and offers Resume agent / Discard after an interrupted Action
    • Excludes: server or persistence redesign, V2 orchestration work, a general scheduler, user documentation, and Android-specific QA
    • Branch: lastcode/action-resume-mobile

    This remains a deliberately small, temporary, single-user-first implementation pending the V2 orchestrator.

  4. lastobelus commented on Aug 17, 2026

    @lastobelus
    OwnerAuthor

    Completed in #28 and #29. Slice 1 delivered the scoped Action-resume tracer and desktop/web lifecycle; slice 2 added the mobile Waiting, cancellation, and interrupted-run recovery controls.

  5. 76 remaining items

  6. lastobelus commented on Sep 28, 2026

    @lastobelus
    OwnerAuthor

    Closure clarification: this issue should remain closed as the delivered, scoped one-shot Action-resume tracer, implemented in #28 (web/desktop and server lifecycle) and #29 (mobile controls), both merged on August 17.

    The accepted work-intent comment narrowed the original proposal: one resumable Action per thread, a same-thread follow-up after completion, cancellation, and explicit interrupted-run recovery. It explicitly excluded process survival/automatic wake delivery across a restart, concurrency, and aggregate artifact retention controls. The later comment's “slice 2” meant mobile controls; it did not implement the original body's “slice 2: restart durability.” Closure should not be read as claiming that restart-survival test or the original retention-controls proposal passed. Those remain separate outstanding scope; they are not silently waived by this clarification.

    The next direction is complementary work on (1) independent concurrent Action runs with serialized, durable follow-up delivery to the originating thread and (2) multi-condition Action tooling, initially with an explicit completion policy and one final report preserving each condition's outcome. PR #222 addresses sequential stacked-PR waits and does not implement either general concurrency or multi-condition observation.

    Intermediate actionable results that wake the thread while the Action continues waiting are a possible later enhancement. Keep execution state separate from delivery state so this remains possible, but intermediate-event behavior and any acknowledgment/response protocol still need design. They are not part of the completed tracer or a claim of current functionality.

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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions