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