Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/lore/cli/commands/capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,23 @@ def _spawn_subagent(
# 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"],
# being extracted into memories.
#
# `--permission-mode bypassPermissions` is also required:
# without it the subagent inherits a fresh permission state
# where mcp__lore__remember_observation isn't pre-approved, so
# every save call returns "Claude requested permissions … but
# you haven't granted it yet" and the subagent finishes
# PROCESSED_THROUGH_SEQ=N without persisting any memories.
# The capture prompt is internally generated and only invokes
# mcp__lore__* tools (read + write own memory store), so
# bypassing permission prompts is the correct trust posture.
[
"claude", "-p", prompt,
"--output-format", "stream-json",
"--verbose",
"--permission-mode", "bypassPermissions",
],
stdin=subprocess.DEVNULL,
stdout=log_fh,
stderr=subprocess.STDOUT,
Expand Down
18 changes: 13 additions & 5 deletions src/lore/cli/commands/dream.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,19 @@ def _spawn_subagent(
log_fh = extract_log.open("a", encoding="utf-8")
try:
return subprocess.Popen( # noqa: S603 — internal prompt
# 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"],
# See cli/commands/capture.py for why both flags are required:
# --verbose unblocks stream-json on Claude Code 2.1.x, and
# --permission-mode=bypassPermissions stops every
# mcp__lore__remember/supersede/consolidate_memories/forget
# call from being denied with "you haven't granted it yet".
# Dream is a trusted internal subagent; bypassing prompts is
# the correct trust posture.
[
"claude", "-p", prompt,
"--output-format", "stream-json",
"--verbose",
"--permission-mode", "bypassPermissions",
],
stdin=subprocess.DEVNULL,
stdout=log_fh,
stderr=subprocess.STDOUT,
Expand Down
7 changes: 7 additions & 0 deletions tests/test_capture_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,13 @@ def __init__(self, cmd, **kwargs):
assert "--output-format" in flag_args
assert "stream-json" in flag_args
assert "--verbose" in flag_args
# --permission-mode=bypassPermissions is also required: without it
# the subagent's mcp__lore__remember_observation calls hit "you
# haven't granted it yet" prompts (the subagent inherits a fresh
# permission state, not the parent's allowlist) and the
# extraction completes with zero memories saved.
assert "--permission-mode" in flag_args
assert "bypassPermissions" in flag_args
# Detached invocation hygiene.
assert captured["kwargs"]["stdin"] is subprocess.DEVNULL
assert captured["kwargs"]["start_new_session"] is True
Expand Down
5 changes: 5 additions & 0 deletions tests/test_dreams.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ def __init__(self, cmd, **kwargs):
assert "--output-format" in flag_args
assert "stream-json" in flag_args
assert "--verbose" in flag_args
# --permission-mode=bypassPermissions is also required: without it
# the subagent's mcp__lore__* save calls hit "you haven't granted
# it yet" prompts and silently produce zero memories.
assert "--permission-mode" in flag_args
assert "bypassPermissions" in flag_args
# Detached invocation hygiene.
assert captured["kwargs"]["stdin"] is subprocess.DEVNULL
assert captured["kwargs"]["start_new_session"] is True
Expand Down
Loading