Skip to content

openclaw agent --local --json can emit final JSON but keep process/workers alive #92464

Description

@BrettHamlin

Environment:

  • OpenClaw image: ghcr.io/openclaw/openclaw:2026.6.1
  • Runtime: Docker container, Linux
  • Node: image default
  • Mode: openclaw agent --local --json
  • Memory corpus: generated synthetic corpus, 10,000 memory entries imported in
    100-entry chunks
  • Model used by the generated repro: openai/gpt-5.4-mini

Summary:

In a generated memory-recall workload, openclaw agent --local --json can emit
the final JSON payload with a correct assistant answer, but the CLI process
does not exit promptly. In the same investigation, child/worker processes could
outlive the parent process, and repeated CLI-local invocations appeared to load
separate model/worker copies.

This matters for automation: a runner that waits for process exit can exhaust
slots or memory even though the turn has already completed and emitted JSON.

Repro shape:

  1. Start an OpenClaw 2026.6.1 container with an initialized local-mode cell.

  2. Import a generated 10,000-entry memory corpus in 100-entry chunks, running:

    openclaw memory index --agent main

    after each chunk.

  3. Run a fresh-session local agent turn:

    openclaw agent \
      --local \
      --agent main \
      --session-key agent:main:generated-linger-repro \
      --model openai/gpt-5.4-mini \
      --thinking off \
      --timeout 600 \
      --json \
      --message "Use durable memory if available. What is the exact phrase for contact-00017? Reply with only the exact phrase token."

Observed:

  • The command emits a final JSON payload with the expected assistant text.
  • In a 10k one-probe diagnostic, JSON completed around 29.4s, but the CLI did
    not exit naturally after a 15s post-JSON grace window and required
    termination.
  • In the full corrected 10k run, every completed probe produced JSON and then
    failed to exit naturally within the post-JSON grace window.
  • A smaller 1k one-probe diagnostic exited naturally almost immediately after
    JSON, so the linger appears workload/scale-sensitive.
  • Process snapshots from related local-embedding diagnostics showed surviving
    openclaw-agent / embedding-worker style processes after parent termination
    unless the runner explicitly killed descendants and verified zero survivors.

Expected:

  • Once the final JSON payload is written and the turn is complete, the CLI
    process should exit promptly.
  • Terminating the parent should not leave orphaned agent/worker processes for
    that turn.
  • Repeated CLI-local invocations should not accumulate independent long-lived
    model/worker copies unless that is an intentional, documented behavior.

Impact:

  • Control-plane or CI runners that invoke openclaw agent --json cannot safely
    rely on process exit as the completion signal.
  • Managed runners need output-based JSON completion detection, process-group
    termination, and survivor verification as a workaround.
  • Memory/RSS measurements from repeated CLI-local invocations can overstate
    production memory pressure if orphaned workers accumulate.

Notes:

  • This report is based on generated synthetic data only.
  • No personal state, customer data, or raw provider keys are required for the
    repro.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority user-facing bug, regression, or broken workflow.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions