From aefc2a734006607fadcadcf1c8de23cfe87dc0c9 Mon Sep 17 00:00:00 2001 From: Amit Paz Date: Fri, 8 May 2026 11:07:33 +0300 Subject: [PATCH] fix(capture+dream): pass --verbose to claude -p stream-json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Claude Code 2.1.x rejects `--print --output-format stream-json` without `--verbose`: Error: When using --print, --output-format=stream-json requires --verbose Without it, both the dream subagent and the capture-extract hook exit immediately. Visible symptom: session buffers grow into hundreds of JSONL events but `extract.log` is just a wall of the error and zero memories ever get extracted — the user reported "still only 2 memories shown in the UI" after a full day of work that should have produced many. Fix: add `--verbose` to both Popen invocations (`cli/commands/dream.py` and `cli/commands/capture.py`). Tests in `test_dreams.py` and `test_capture_hook.py` now pin the flag list so this can't silently regress when Claude Code adds another required flag in a future release. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/lore/cli/commands/capture.py | 7 ++++++- src/lore/cli/commands/dream.py | 6 +++++- tests/test_capture_hook.py | 8 ++++++++ tests/test_dreams.py | 7 +++++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/lore/cli/commands/capture.py b/src/lore/cli/commands/capture.py index 9d16676..80c0188 100644 --- a/src/lore/cli/commands/capture.py +++ b/src/lore/cli/commands/capture.py @@ -583,7 +583,12 @@ def _spawn_subagent( log_fh = extract_log.open("a", encoding="utf-8") try: proc = subprocess.Popen( # noqa: S603 — input is internal, not user-supplied - ["claude", "-p", prompt, "--output-format", "stream-json"], + # Claude Code 2.1.x rejects `--print --output-format stream-json` + # without `--verbose`. Without it the subagent exits immediately + # ("When using --print, --output-format=stream-json requires + # --verbose") and the session buffer keeps growing without ever + # being extracted into memories — silent capture-pipeline death. + ["claude", "-p", prompt, "--output-format", "stream-json", "--verbose"], stdin=subprocess.DEVNULL, stdout=log_fh, stderr=subprocess.STDOUT, diff --git a/src/lore/cli/commands/dream.py b/src/lore/cli/commands/dream.py index f0a0905..901a12f 100644 --- a/src/lore/cli/commands/dream.py +++ b/src/lore/cli/commands/dream.py @@ -415,7 +415,11 @@ def _spawn_subagent( log_fh = extract_log.open("a", encoding="utf-8") try: return subprocess.Popen( # noqa: S603 — internal prompt - ["claude", "-p", prompt, "--output-format", "stream-json"], + # Claude Code 2.1.x rejects `--print --output-format stream-json` + # without `--verbose`. Without it the subagent exits immediately + # with "When using --print, --output-format=stream-json requires + # --verbose" and the buffer never gets extracted into memories. + ["claude", "-p", prompt, "--output-format", "stream-json", "--verbose"], stdin=subprocess.DEVNULL, stdout=log_fh, stderr=subprocess.STDOUT, diff --git a/tests/test_capture_hook.py b/tests/test_capture_hook.py index 877a4f5..84d5479 100644 --- a/tests/test_capture_hook.py +++ b/tests/test_capture_hook.py @@ -271,6 +271,14 @@ def __init__(self, cmd, **kwargs): assert "Help me refactor" in prompt assert "Already saved A" in prompt assert "PROCESSED_THROUGH_SEQ=" in prompt + # Claude Code 2.1.x requires --verbose alongside stream-json; without + # it the extraction subagent exits immediately ("requires --verbose") + # and the session buffer keeps growing without ever being extracted + # into memories. + flag_args = cmd[3:] + assert "--output-format" in flag_args + assert "stream-json" in flag_args + assert "--verbose" in flag_args # Detached invocation hygiene. assert captured["kwargs"]["stdin"] is subprocess.DEVNULL assert captured["kwargs"]["start_new_session"] is True diff --git a/tests/test_dreams.py b/tests/test_dreams.py index a6a6f89..1b9b59e 100644 --- a/tests/test_dreams.py +++ b/tests/test_dreams.py @@ -226,6 +226,13 @@ def __init__(self, cmd, **kwargs): prompt = captured["cmd"][2] assert "PHASE_3_CONSOLIDATE_COMPLETE" in prompt assert "RUN_ID:" in prompt + # Claude Code 2.1.x requires --verbose alongside stream-json; without + # it the subagent exits immediately and the session buffer never + # gets extracted. Pin the flag so it can't silently regress. + flag_args = captured["cmd"][3:] + assert "--output-format" in flag_args + assert "stream-json" in flag_args + assert "--verbose" in flag_args # Detached invocation hygiene. assert captured["kwargs"]["stdin"] is subprocess.DEVNULL assert captured["kwargs"]["start_new_session"] is True