Skip to content

🐛 mocactl subagents shows a misleading failed: fetch failed for any leaf that runs longer than 5 minutes #515

Closed

Description

@maia-iyer

Describe the bug

mocactl spawn's detached worker holds a synchronous POST /v1/runs until the server finishes the run. That fetch (LeafTransport.submitLeafTurn in packages/mocactl/src/transport/leaf-turn.ts) sets no timeout, so it inherits undici's default headersTimeout of 300s. Any leaf whose turn runs longer than five minutes is cut off client-side, and the worker writes a terminal failed / fetch failed to the ledger (runSpawnWorker in packages/mocactl/src/subagent.ts).

The server-side run is unaffected — it completes and stores its result, and mocactl get collects it (responded, exit 0). But because terminal ledger states are sticky, mocactl subagents reports failed: fetch failed forever for a run that succeeded. Observed on mocactl edge-a02b9db / Node 24: a leaf that completed at ~10.5 minutes still shows failed in subagents; the ledger flip happened at exactly ~301s after dispatch, twice.

Steps To Reproduce

  1. mocactl spawn "Run 'sleep 400' and then reply done." --kind prompt --tag repro --json
  2. Watch the ledger at ~/.local/state/mocactl/subagents.jsonl: at ~301s the entry flips to "lastKnownState":"failed","stateDetail":"fetch failed", and mocactl subagents shows failed.
  3. Keep polling mocactl get <sessionId> --json: at ~400s it prints "status":"responded" and writes the result files (exit 0). The run succeeded — only subagents is wrong.

Expected Behavior

mocactl subagents should not report a terminal failed for a run that is still executing, or that completed, server-side. Either the worker's fetch should not time out at five minutes (an explicit AbortSignal.timeout, or an undici Agent with a headersTimeout matching the server's 24h result TTL), or a worker-side fetch error should not be recorded as a terminal state — the entry should stay non-terminal and reconcile against /runs/status, which subagents and get already query.

Rossoctl Version

No response

Additional Context

No response

Activity

  1. pdettori commented on Oct 14, 2026

    @pdettori
    Member

    thanks @maia-iyer - would you like to submit a PR for this issue ?

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions