You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
wave -p was dumping auto-memory subagent system prompts, file manifests,
and streaming output to stdout. Remove all subagent callbacks from
print-cli.ts so only the main agent's response is printed, matching
Claude Code's behavior. Add spec 035-print-mode.
The `startPrintCli` function creates an `Agent` with a specific set of callbacks. Only main-agent callbacks are registered; subagent callbacks are omitted.
6
+
7
+
### Active Callbacks
8
+
9
+
```typescript
10
+
const callbacks: AgentCallbacks = {
11
+
onAssistantMessageAdded: () => { /* reset state flags */ },
**Input**: Feature specification from `/specs/035-print-mode/spec.md`
5
+
6
+
## Summary
7
+
8
+
Ensure `wave -p` (print mode) only outputs the main agent's response to stdout, suppressing all subagent output (user messages, reasoning, content). This matches Claude Code's print mode behavior where subagent output is internal and the main agent incorporates results in its own response.
9
+
10
+
## Technical Context
11
+
12
+
**Language/Version**: TypeScript (Node.js)
13
+
**Primary Dependencies**: Ink (React for CLI — not used in print mode), agent-sdk callbacks
14
+
**State Management**: Callback-driven streaming via `AgentCallbacks`
Print mode (`wave -p 'message'`) runs the agent non-interactively and outputs only the main agent's response to stdout. It is designed for scripting and piping.
5
+
6
+
## How to use
7
+
8
+
### Basic Usage
9
+
10
+
```bash
11
+
# Simple prompt
12
+
wave -p 'Explain what this project does'
13
+
14
+
# Pipe output to a file
15
+
wave -p 'List all TODO comments' > todos.txt
16
+
17
+
# Chain with other commands
18
+
wave -p 'What is the main entry point?' | grep -i index
19
+
```
20
+
21
+
### What you'll see
22
+
23
+
Print mode outputs:
24
+
- `💭 Reasoning:` — if the agent reasons before responding
25
+
- `📝 Response:` — the main agent's response text
26
+
- `🔧 <tool_name> <params>` — tool calls made by the main agent
27
+
- `❌ Error: <message>` — any errors
28
+
29
+
### What you won't see
30
+
31
+
Print mode suppresses all subagent output:
32
+
- No subagent system prompts or instructions
33
+
- No subagent file manifests (e.g., auto-memory extraction file lists)
34
+
- No subagent reasoning or streaming content
35
+
- No subagent tool call indicators
36
+
37
+
The main agent incorporates relevant subagent results in its own response.
38
+
39
+
## Example Session
40
+
41
+
```text
42
+
$ wave -p 'What does the build script do?'
43
+
44
+
💭 Reasoning:
45
+
Let me check the build configuration.
46
+
47
+
🔧 Read package.json
48
+
49
+
📝 Response:
50
+
The build script runs `rimraf dist && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json`, which cleans the output directory, compiles TypeScript, and resolves path aliases.
## Decision: Suppress all subagent output in print mode
4
+
- **Rationale**: Claude Code's print mode (`claude -p`) only outputs the main agent's final response. Subagent messages (both regular Agent tool and forked background agents like memory extraction) are internal — their results return to the main agent as tool_result content and get incorporated into the final answer. Printing subagent internals (system prompts, file manifests, reasoning) produces noisy, unusable output.
5
+
- **Alternatives considered**:
6
+
- Print subagent output with indentation: Rejected because subagent user messages contain massive system prompts (e.g., auto-memory extraction lists 200+ files) that pollute stdout and break piping.
7
+
- Selective suppression (only forked agents): Rejected because regular Agent tool subagent output is also internal — the main agent summarizes and incorporates it. Printing it separately creates duplicate/conflicting output.
- **Rationale**: This callback received `params.content` which contained the full subagent user message — including system prompts with instructions and file manifests. Dumping this to stdout was the primary source of the bug report.
11
+
- **Alternatives considered**:
12
+
- Truncate content: Rejected because even truncated system prompts are noise, and truncation doesn't solve the fundamental problem of leaking internal instructions.
13
+
- Check content length: Rejected because arbitrary length thresholds are fragile and still print unnecessary output.
14
+
15
+
## Decision: Remove `onSubagentAssistantContentUpdated` and `onSubagentAssistantReasoningUpdated` callbacks
16
+
- **Rationale**: Subagent streaming output (reasoning, content) is not useful in print mode. The main agent receives subagent results as tool_result and incorporates them in its own response. Printing subagent content separately creates confusing, interleaved output.
17
+
- **Alternatives considered**:
18
+
- Keep reasoning only: Rejected because subagent reasoning is also internal and not user-facing.
19
+
- Add a "verbose" flag for subagent output: Rejected as over-engineering; no user has requested this and it adds configuration complexity.
20
+
21
+
## Decision: Keep main agent tool block indicators
22
+
- **Rationale**: Showing `🔧 Agent Explore: <description>` for the main agent's tool calls provides useful progress feedback in print mode without leaking internals. This is a lightweight indicator, not subagent output.
23
+
- **Alternatives considered**:
24
+
- Remove all tool indicators: Rejected because users benefit from knowing which tools the main agent is calling, especially for long-running operations.
25
+
26
+
## Integration Points
27
+
- `print-cli.ts`: Consumes `AgentCallbacks` — controls what gets printed to stdout.
28
+
- `AgentCallbacks` (agent-sdk): Interface defines optional subagent callbacks; omitting them is valid.
29
+
- `SubagentManager` (agent-sdk): Forwards subagent events via callbacks; if no callback is registered, events are silently ignored.
30
+
- `ForkedAgentManager` (agent-sdk): Runs background agents (auto-memory) through SubagentManager; events flow through the same callback path.
0 commit comments