openclaw-code-agent 2.3.1 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: Code Agent Orchestration
3
- description: Skill for orchestrating coding agent sessions from OpenClaw. Covers launching, monitoring, multi-turn interaction, lifecycle management, notifications, and parallel work patterns.
3
+ description: Skill for orchestrating coding agent sessions from OpenClaw. Covers launching, monitoring, multi-turn interaction, lifecycle management, notifications, and worktree decision rules.
4
4
  metadata:
5
5
  openclaw:
6
6
  homepage: https://github.com/goldmar/openclaw-code-agent
@@ -15,378 +15,226 @@ metadata:
15
15
 
16
16
  # Code Agent Orchestration
17
17
 
18
- You orchestrate coding agent sessions via the `openclaw-code-agent`. Each session is an autonomous agent that executes code tasks in the background.
18
+ Use `openclaw-code-agent` to run Claude Code or Codex sessions as background coding jobs from chat.
19
19
 
20
- ---
21
-
22
- ## 1. Launching sessions
23
-
24
- ### Mandatory rules
25
-
26
- - **Notifications are routed automatically** via `agentChannels` config. Do NOT pass `channel` manually — it bypasses automatic routing.
27
- - **Thread-aware routing**: When launched from a Telegram thread/topic, notifications are routed back to that same thread via `originThreadId`. This is handled automatically.
28
- - **Always pass `multi_turn: true`** unless the task is a guaranteed one-shot with no possible follow-up.
29
- - **Name the sessions** with `name` in kebab-case, short and descriptive.
30
- - **Set `workdir`** to the target project directory, not the agent's workspace.
31
- - **Default mode is `plan`**: Sessions start in plan mode. When the user approves a plan (e.g. "looks good", "go ahead"), the plugin automatically switches to `bypassPermissions` mode.
32
-
33
- ### Essential parameters
34
-
35
- | Parameter | When to use |
36
- |---|---|
37
- | `prompt` | Always. Clear and complete instruction. |
38
- | `name` | Always. Descriptive kebab-case (`fix-auth-bug`, `add-dark-mode`). |
39
- | `channel` | **Do NOT pass.** Resolved automatically via `agentChannels`. |
40
- | `workdir` | Always when the project is not in the `defaultWorkdir`. |
41
- | `multi_turn` | `true` by default unless explicitly one-shot. |
42
- | `model` | When you want to force a specific model (`"sonnet"`, `"opus"`, `"gpt-5.4"`). Subject to `harnesses.<name>.allowedModels` restrictions if configured. |
43
- | `system_prompt` | To inject project-specific context. |
44
- | `permission_mode` | `"plan"` by default. `"bypassPermissions"` for trusted tasks. |
45
-
46
- ### Harness-scoped model restrictions
47
-
48
- The plugin config restricts models per harness via `harnesses.<name>.allowedModels`:
49
-
50
- - **Matching:** Case-insensitive substring matching (e.g., `"sonnet"` matches `"claude-sonnet-4-6"`)
51
- - **Explicit model blocked:** If a caller explicitly requests a model not in that harness's `allowedModels`, the launch fails with an error
52
- - **Default model blocked:** If no model is specified and the resolved `harnesses.<name>.defaultModel` is not in `allowedModels`, the launch fails with a config error
53
- - **Not configured:** If `allowedModels` is empty or undefined for that harness, all models are allowed for that harness
54
-
55
- **Example configuration:**
56
- ```json
57
- {
58
- "harnesses": {
59
- "claude-code": {
60
- "defaultModel": "sonnet",
61
- "allowedModels": ["sonnet", "haiku"]
62
- },
63
- "codex": {
64
- "defaultModel": "gpt-5.4",
65
- "allowedModels": ["gpt-5.4"]
66
- }
67
- }
68
- }
69
- ```
70
-
71
- This configuration allows Claude models containing "sonnet" or "haiku" in their identifier, and restricts Codex launches to `gpt-5.4`.
20
+ ## 1. Launch Rules
72
21
 
73
- **Interaction with harness compatibility:**
74
- When both `harnesses.<name>.allowedModels` and harness compatibility constraints apply, you must satisfy BOTH:
75
- 1. The model must be in `harnesses.<name>.allowedModels` (if configured)
76
- 2. The model must be compatible with the chosen harness
22
+ - Do not pass `channel` manually. Routing comes from `agentChannels`, the current chat context, and `fallbackChannel`.
23
+ - Sessions are multi-turn. All sessions stay open for follow-up messages via `agent_respond`.
24
+ - Always set a short kebab-case `name` when you care about later follow-up.
25
+ - Set `workdir` to the target repo, not to the agent's own workspace.
26
+ - Default behavior is `permission_mode: "plan"` plus `planApproval: "ask"` plus `defaultWorktreeStrategy: "off"`.
27
+ - Use `permission_mode: "plan"` whenever the user wants a real planning checkpoint, reviewable plan, or approval buttons before implementation.
28
+ - Use `permission_mode: "bypassPermissions"` only when the user wants autonomous execution. Do not try to recreate plan mode by stuffing "plan only" into the prompt unless you intentionally want a soft fallback rather than the primary UX contract.
29
+ - In `plan` mode, the plan should be emitted directly in normal session output so the user can review it in chat. Do not tell the coding agent to write a plan document or markdown file unless the user explicitly asked for a file.
77
30
 
78
- Example: If `harnesses.claude-code.allowedModels = ["sonnet", "gpt-4"]` and you use the default `claude-code` harness, only "sonnet" will work because "gpt-4" is not a Claude-compatible model.
31
+ Example:
79
32
 
80
- ### Examples
81
-
82
- ```
83
- # Simple task
33
+ ```text
84
34
  agent_launch(
85
- prompt: "Fix the null pointer in src/auth.ts line 42",
86
- name: "fix-null-auth",
87
- workdir: "/home/user/projects/myapp",
88
- multi_turn: true
89
- )
90
-
91
- # Full feature
92
- agent_launch(
93
- prompt: "Implement dark mode toggle in the settings page. Use the existing theme context in src/context/theme.tsx. Add a toggle switch component and persist the preference in localStorage.",
94
- name: "add-dark-mode",
95
- workdir: "/home/user/projects/myapp",
96
- multi_turn: true
35
+ prompt: "Fix the auth middleware bug and add tests",
36
+ name: "fix-auth",
37
+ workdir: "/home/user/projects/my-app"
97
38
  )
98
39
  ```
99
40
 
100
- ### Resume and fork
41
+ Resume and fork:
101
42
 
102
- ```
103
- # Resume a completed session
43
+ ```text
104
44
  agent_launch(
105
- prompt: "Continue. Also add error handling for the edge cases we discussed.",
106
- resume_session_id: "fix-null-auth",
107
- multi_turn: true
45
+ prompt: "Continue where you left off",
46
+ resume_session_id: "fix-auth"
108
47
  )
109
48
 
110
- # Fork to try an alternative approach
111
49
  agent_launch(
112
- prompt: "Try a completely different approach: use middleware instead of decorators.",
113
- resume_session_id: "refactor-db-repositories",
50
+ prompt: "Try a different approach",
51
+ resume_session_id: "fix-auth",
114
52
  fork_session: true,
115
- name: "refactor-db-middleware-approach",
116
- multi_turn: true
53
+ name: "fix-auth-alt"
117
54
  )
118
55
  ```
119
56
 
120
- ### Harness and model compatibility
57
+ ## 2. Anti-Cascade Rule
121
58
 
122
- | Harness | Supported Models | Examples |
123
- |---------|-----------------|---------|
124
- | `claude-code` | Anthropic only | `sonnet`, `opus`, `haiku`, `claude-sonnet-4-6` |
125
- | `codex` | OpenAI only | `gpt-4`, `gpt-5`, `o1`, `o3-mini` |
59
+ When you are woken because a session is waiting or completed, do not launch a new coding session in response. Only use the existing session with:
126
60
 
127
- - When user says "with sonnet/opus/haiku" → use `harness: "claude-code"` (or omit — it's the default)
128
- - When user says "with gpt-4/o1/o3" → use `harness: "codex"`
129
- - **Never** pass Anthropic models to codex harness or OpenAI models to claude-code harness
61
+ - `agent_output`
62
+ - `agent_respond`
63
+ - `agent_merge`
64
+ - `agent_pr`
65
+ - `agent_worktree_status`
130
66
 
131
- If `harnesses.<name>.allowedModels` is configured, both explicit model requests and default models outside that list are rejected with an error. When the default model is not allowed, the error message directs you to update the plugin config.
67
+ ## 2a. Resume vs. Spawn Rule (CRITICAL)
132
68
 
133
- ---
69
+ **Always resume — never spawn fresh — when a session already exists for the task.**
134
70
 
135
- ## 2. Anti-cascade rules (CRITICAL)
71
+ | Situation | Correct action |
72
+ |-----------|---------------|
73
+ | Session waiting for plan approval | `agent_respond(session, message, approve=true)` |
74
+ | Session waiting for a question answer | `agent_respond(session, message)` |
75
+ | Session killed/stopped by restart | `agent_respond(session, message)` — killed sessions auto-resume on next `agent_respond` |
76
+ | Session completed, user wants to extend/revise | `agent_launch(resume_session_id=session_id)` |
77
+ | Worktree has uncommitted work after a crash | `agent_respond` on the stopped session first; only if truly unrecoverable, relaunch with the worktree still in place |
136
78
 
137
- **When woken by a waiting-for-input or completion event, you MUST ONLY use `agent_respond` or `agent_output` for the referenced session. NEVER launch new sessions in response to wake events.**
79
+ **Never use `agent_launch` to start a fresh session when `agent_respond` would work.** Spawning fresh loses conversation history, may duplicate worktrees, and confuses the user.
138
80
 
139
- This prevents cascading session creation. The orchestrator exists to manage existing sessions, not to spawn new ones from wake events.
81
+ Only spawn a genuinely new session for work that is **completely independent** of any existing session.
140
82
 
141
- ---
83
+ ## 3. Monitoring
142
84
 
143
- ## 3. Monitoring sessions
85
+ Use:
144
86
 
145
- ### List sessions
146
-
147
- ```
148
- # All sessions
87
+ ```text
149
88
  agent_sessions()
150
-
151
- # Only running sessions
152
89
  agent_sessions(status: "running")
153
-
154
- # Completed sessions (for resume)
155
- agent_sessions(status: "completed")
90
+ agent_output(session: "fix-auth", lines: 100)
91
+ agent_output(session: "fix-auth", full: true)
156
92
  ```
157
93
 
158
- ### View output
94
+ Trust the latest output and current phase. Do not report an old planning state after the session has already moved into implementation.
95
+ Treat these wake fields as authoritative session state, not hints:
159
96
 
160
- ```
161
- # Summary (last 50 lines)
162
- agent_output(session: "fix-null-auth")
97
+ - `requestedPermissionMode`
98
+ - `effectivePermissionMode` / current permission mode (`currentPermissionMode` in plugin payloads)
99
+ - `approvalExecutionState`
163
100
 
164
- # Full output (up to 200 blocks)
165
- agent_output(session: "fix-null-auth", full: true)
101
+ Do not reinterpret approval behavior from transcript fragments when these fields are present.
166
102
 
167
- # Specific last N lines
168
- agent_output(session: "fix-null-auth", lines: 100)
169
- ```
103
+ Completion and approval state handling:
170
104
 
171
- ### Interpreting session state
105
+ - `approved_then_implemented` means normal approved execution. Do not frame it as rogue, surprising, or a bypass.
106
+ - `implemented_without_required_approval` means the session left a required approval gate. Treat that as the actual approval-bypass case.
107
+ - `awaiting_approval` means the session is still waiting at the gate. Do not describe implementation as started.
108
+ - If the plugin wake says it already sent the canonical approval or completion message, do not send a duplicate plain-text recap unless you are adding real synthesis, a risk callout, or concrete next-step guidance.
172
109
 
173
- The `agent_output` header shows status, phase, cost, and duration:
174
- ```
175
- Session: fix-auth [abc123] | Status: RUNNING | Phase: planning | Cost: $0.0312 | Duration: 2m15s
176
- ```
110
+ ## 4. Respond Rules
177
111
 
178
- The `Phase:` indicator for running sessions:
179
- - `Phase: planning` — the agent is writing a plan
180
- - `Phase: awaiting-plan-approval` — plan submitted, waiting for review
181
- - `Phase: implementing` — actively writing code
112
+ Auto-respond immediately only for:
182
113
 
183
- The `agent_sessions` listing also shows phase and cost when available:
184
- ```
185
- 🟢 fix-auth [abc123] (2m15s | $0.03) — multi-turn
186
- ⚙️ Phase: planning
187
- ```
114
+ - permission requests for file reads, writes, or shell commands
115
+ - explicit continuation prompts such as "Should I continue?"
188
116
 
189
- **Recency rule:** Always trust the Phase indicator and the *latest* (bottom) output lines. If earlier output mentions plan mode but Phase says `implementing`, the session has transitioned. Do NOT report it as "waiting for approval."
117
+ Forward everything else to the user:
190
118
 
191
- ---
119
+ - architecture or design choices
120
+ - destructive operations
121
+ - scope changes
122
+ - credentials or production questions
123
+ - ambiguous requirements
124
+ - anything you are not certain you should answer autonomously
192
125
 
193
- ## 4. Multi-turn interaction
126
+ When forwarding, quote the session's exact question. Do not add your own commentary.
194
127
 
195
- ### Send a follow-up
128
+ Examples:
196
129
 
197
- ```
198
- # Reply to an agent question
199
- agent_respond(session: "add-dark-mode", message: "Yes, use CSS variables for the theme colors.")
130
+ ```text
131
+ agent_respond(session: "fix-auth", message: "Yes, proceed.")
200
132
 
201
- # Redirect a running session (interrupts the current turn)
202
- agent_respond(session: "add-dark-mode", message: "Stop. Use Tailwind dark: classes instead of CSS variables.", interrupt: true)
133
+ agent_respond(
134
+ session: "fix-auth",
135
+ message: "Stop. Do not touch the database schema.",
136
+ interrupt: true
137
+ )
203
138
  ```
204
139
 
205
- ### Auto-respond rules (STRICT)
206
-
207
- **Auto-respond immediately with `agent_respond`:**
208
- - Permission requests to read/write files or run bash commands -> `"Yes, proceed."`
209
- - Explicit confirmations like "Should I continue?" -> `"Yes, continue."`
210
-
211
- **Forward to the user (everything else):**
212
- - Architecture decisions (Redis vs PostgreSQL, REST vs GraphQL...)
213
- - Destructive operations (deleting files, dropping tables...)
214
- - Ambiguous requirements not covered by the initial prompt
215
- - Scope changes ("This will require refactoring 15 files")
216
- - Anything involving credentials, secrets, or production environments
217
- - Questions about approach, design, or implementation choices
218
- - Codebase clarification questions
219
- - When in doubt -> always forward to the user
140
+ ## 5. Plan Approval
220
141
 
221
- **When forwarding to the user, quote the agent's exact question. Do NOT add your own analysis, interpretation, or commentary.**
142
+ Mode selection:
222
143
 
223
- ### Interaction cycle
224
-
225
- 1. Session launches -> runs in background
226
- 2. Wake event arrives when the session is waiting for input
227
- 3. Read the question with `agent_output(session, full: true)`
228
- 4. Decide: auto-respond (permissions/confirmations only) or forward
229
- 5. If auto-respond: `agent_respond(session, answer)`
230
- 6. If forward: relay the agent's exact question to the user, wait for their response, then `agent_respond`
231
-
232
- ---
144
+ - `permission_mode: "plan"` is the primary contract for planning sessions. It produces a plan-review stop and is the only mode you should rely on for explicit approval UX.
145
+ - `permission_mode: "bypassPermissions"` is for autonomous execution. Do not try to recreate plan mode by stuffing "plan only", "do not implement yet", or similar text into the prompt.
146
+ - If the user says "investigate first", "show me the plan", "plan only", or "wait for approval before coding", launch in `plan` mode.
147
+ - If the user says "just do it", "run autonomously", or wants uninterrupted execution, use `bypassPermissions`.
148
+ - In `plan` mode, the plan belongs in the agent's normal output stream. Do not ask the coding agent to write `PLAN.md`, investigation notes, or similar artifacts unless the user explicitly requested a file deliverable.
233
149
 
234
- ## 5. Lifecycle management
150
+ Approve a pending plan with:
235
151
 
236
- ### Stop or complete a session
237
-
238
- ```
239
- # Kill a stuck/looping session
240
- agent_kill(session: "fix-null-auth")
241
-
242
- # Mark a session as successfully completed
243
- agent_kill(session: "fix-null-auth", reason: "completed")
152
+ ```text
153
+ agent_respond(
154
+ session: "fix-auth",
155
+ message: "Approved. Go ahead.",
156
+ approve: true,
157
+ userInitiated: true
158
+ )
244
159
  ```
245
160
 
246
- Use `agent_kill` (no reason) when:
247
- - The session is stuck or looping
248
- - The user requests a stop
161
+ Rules:
249
162
 
250
- Use `agent_kill(reason: "completed")` when:
251
- - The turn output shows the task is done this sends a `✅ Completed` notification
252
- - Prefer this over letting the idle timer expire
163
+ - `approve: true` approves a pending plan or escalates a `default` mode session into `bypassPermissions`.
164
+ - Do not send approval and revision feedback in the same call.
165
+ - In `planApproval: "ask"`, the user is expected to approve or revise. Wait for that input.
166
+ - Telegram users may get inline `Approve`, `Reject`, and `Revise` buttons for plan review.
253
167
 
254
- ### Idle completion and auto-resume
168
+ ## 6. Worktree Decision Rules
255
169
 
256
- - After a turn completes without a question, the session is immediately **paused** (killed with reason `done`, auto-resumable).
257
- - On the next `agent_respond` to a completed or idle-killed session, the plugin **auto-resumes** by spawning a new session with the same session ID — conversation context is preserved.
258
- - Sessions idle for `idleTimeoutMinutes` (default: 15 min) are killed with reason `idle-timeout` and also auto-resume on next respond.
259
- - Sessions killed for any reason except `startup-timeout` auto-resume on next `agent_respond`. This includes user-killed sessions (`agent_kill`), shutdown-killed sessions (gateway restart), and idle-timeout sessions.
170
+ ### `ask`
260
171
 
261
- ### Timeouts
172
+ Do nothing after completion. The plugin already informed the user and attached 4 buttons:
173
+ - **✅ Merge** — merge branch locally
174
+ - **📬 Open PR** — create a GitHub PR
175
+ - **⏭️ Decide later** — snooze reminders for 24h
176
+ - **🗑️ Dismiss (deletes branch)** — permanently delete branch and worktree (irreversible)
262
177
 
263
- - Idle multi-turn sessions are automatically killed after `idleTimeoutMinutes` (default: 15 min)
264
- - Completed sessions are garbage-collected after 1h but remain resumable via persisted IDs
178
+ Do not call `agent_merge` or `agent_pr` unless the user explicitly asks after that.
265
179
 
266
- ### Check the result after completion
180
+ ### `delegate`
267
181
 
268
- When a session completes (completion wake event):
182
+ Read the diff context from the wake, then decide:
269
183
 
270
- 1. `agent_output(session: "xxx", full: true)` to read the result
271
- 2. Summarize briefly: files changed, cost, duration, any issues
272
- 3. If failed, analyze the error and decide: relaunch, fork, or escalate
184
+ - `agent_merge` for low-risk, clearly scoped changes that match the task
185
+ - **NEVER call `agent_pr()` autonomously** always escalate PR decisions to the user
186
+ - escalate to the user if scope or risk is unclear, or if a PR is the safer choice
187
+ - if the wake already says the plugin sent the canonical completion message, only add user-facing follow-up when you need synthesis, risk framing, or concrete next steps beyond that message
273
188
 
274
- ---
189
+ ### `manual`
275
190
 
276
- ## 6. Notifications
191
+ Wait for an explicit user request before calling `agent_merge` or `agent_pr`.
277
192
 
278
- ### Thread-based routing
193
+ ### Never
279
194
 
280
- Notifications are routed to the Telegram thread/topic where the session was launched. This is handled automatically via `originThreadId` no manual configuration needed. The `agentChannels` config handles chat-level routing, and the thread ID handles within-chat routing.
195
+ - never use raw `git merge` or raw PR commands in place of the plugin tools
196
+ - never clear a pending worktree decision by inventing your own workaround; use `agent_worktree_cleanup(session: "...", dismiss_session: true)` to permanently dismiss
197
+ - never call `agent_pr()` autonomously in `delegate` flows — always escalate to the user for PR decisions
281
198
 
282
- ### Events
199
+ ## 6b. Planning Document Policy
283
200
 
284
- | Event | What happens |
285
- |---|---|
286
- | Session starts | Silent (command response confirms launch) |
287
- | Session completed | Brief one-liner to originating thread |
288
- | Session failed | Error notification to originating thread |
289
- | Waiting for input | Wake event + `❓ Waiting for input` in thread (only when the agent actually asks a question) |
290
- | Turn completes without a question | `⏸️ Paused after turn | Auto-resumable` |
291
- | Session auto-resumes | `▶️ Auto-resumed` |
292
- | Session idle-times out | `💤 Idle timeout` |
293
- | Session is forcibly stopped | `⛔ Stopped ...` with the specific stop reason |
201
+ - Do NOT ask the coding agent to write planning documents, investigation notes, or analysis artifacts as files unless the user explicitly requested a file
202
+ - Do NOT commit planning documents, investigation notes, or analysis artifacts to the branch
203
+ - Only commit actual code, configuration, tests, and documentation changes that were explicitly requested as part of the task
294
204
 
295
- ### Plan Execute mode switch
205
+ ## 6c. Resume vs New Session
296
206
 
297
- Sessions start in `plan` mode by default. When you reply with **only** an approval keyword as the **entire message** (`"go ahead"`, `"implement"`, `"looks good"`, `"approved"`, `"lgtm"`, `"do it"`, `"proceed"`, `"execute"`, `"ship it"`), the plugin switches the session to `bypassPermissions` mode. The message must contain **only** the keyword — extra text will prevent the switch. To approve and also give instructions, send the approval keyword first, then send implementation details as a separate follow-up message.
207
+ - When resuming a session with an existing worktree, use `resume_session_id` with `agent_launch`
208
+ - Do not create a new session if the old worktree branch still has unmerged changes — resume instead
209
+ - If the user wants a fresh start, use `fork_session: true` to branch from the previous session state
298
210
 
299
- ### Permission escalation with `approve: true`
211
+ ## 7. Lifecycle Notes
300
212
 
301
- The `approve` parameter on `agent_respond` escalates session permissions to `bypassPermissions`. It works in two scenarios:
213
+ - `agent_respond` auto-resumes paused, idle-killed, and most other terminal sessions.
214
+ - The only common non-resumable path is `startup-timeout`.
215
+ - Terminal runtime sessions are evicted after `sessionGcAgeMinutes` (default 1440 minutes), but persisted metadata remains resumable.
216
+ - `agent_stats` is the quick operator view for aggregate cost and duration.
302
217
 
303
- 1. **Plan mode approval**: When a session has a pending plan approval (after `ExitPlanMode` / `set_permission_mode`), `approve: true` approves the plan and switches to `bypassPermissions`.
304
- 2. **`acceptEdits` / `default` mode escalation**: When a session is in `acceptEdits` or `default` mode and keeps prompting for shell/exec command permissions, `approve: true` escalates to `bypassPermissions` to skip all remaining prompts.
218
+ ## 8. Chat Commands
305
219
 
306
- If the session is already in `bypassPermissions` mode, `approve: true` is a no-op. In `plan` mode without a pending plan, it is ignored.
220
+ Common command equivalents:
307
221
 
222
+ ```text
223
+ /agent --name fix-auth Fix the auth middleware bug
224
+ /agent_sessions
225
+ /agent_output fix-auth
226
+ /agent_respond fix-auth Add tests too
227
+ /agent_kill fix-auth
228
+ /agent_resume --fork fix-auth Try a different approach
229
+ /agent_stats
308
230
  ```
309
- # Escalate an acceptEdits session that keeps prompting for bash permissions
310
- agent_respond(session: "fix-auth", message: "proceed", approve: true)
311
- ```
312
-
313
- ### Plan approval modes
314
-
315
- The `planApproval` config controls how the orchestrator handles plan-approval events:
316
-
317
- - **`delegate`** (default): The orchestrator autonomously decides whether to approve or escalate each plan to the user. Approve when the plan is low-risk, well-scoped, and matches the original task. Escalate when the plan involves destructive operations, credentials/production, architectural decisions, scope expansion, or ambiguous requirements. When in doubt, always escalate.
318
- - **`approve`**: The orchestrator can auto-approve straightforward, low-risk plans. Before approving, it verifies the working directory, codebase, and scope.
319
- - **`ask`**: The orchestrator always forwards plans to the user. It never auto-approves on the user's behalf.
320
-
321
- #### Delegate mode decision criteria
322
-
323
- When operating in `delegate` mode, **approve** the plan directly if ALL of the following are true:
324
- - The plan scope matches the original task request
325
- - The changes are low-risk (no destructive operations, no credential handling, no production deployments)
326
- - The plan is clear and well-scoped (no ambiguous requirements or open design questions)
327
- - No architectural decisions that the user should weigh in on
328
- - The working directory and codebase are correct
329
-
330
- **Escalate** to the user (forward with 👋 and wait) if ANY of the following are true:
331
- - Destructive operations (deleting files, dropping tables, force-pushing)
332
- - Credentials, secrets, or production environments
333
- - Architectural decisions not covered by the original task
334
- - Scope expanded beyond the original request
335
- - Ambiguous requirements or assumptions the user should confirm
336
- - When in doubt — always escalate
337
-
338
- ---
339
-
340
- ## 7. Best practices
341
231
 
342
- ### Launch checklist
343
-
344
- 1. `agentChannels` is configured for this workdir -> notifications arrive
345
- 2. `multi_turn: true` -> interaction is possible after launch
346
- 3. `name` is descriptive -> easy to identify in `agent_sessions`
347
- 4. `workdir` points to the correct project -> the agent works in the right directory
348
-
349
- ### Parallel tasks
350
-
351
- ```
352
- # Launch multiple sessions on independent tasks
353
- agent_launch(prompt: "Build the frontend auth page", name: "frontend-auth", workdir: "/app/frontend", multi_turn: true)
354
- agent_launch(prompt: "Build the backend auth API", name: "backend-auth", workdir: "/app/backend", multi_turn: true)
355
- ```
356
-
357
- - Respect the `maxSessions` limit (default: 5)
358
- - Each session must have a unique `name`
359
- - Monitor each session individually via wake events
360
-
361
- ### Reporting results
362
-
363
- When a session completes, keep summaries brief:
364
- - Files changed
365
- - Cost and duration
366
- - Any issues or remaining TODOs
367
-
368
- ---
369
-
370
- ## 8. Anti-patterns
371
-
372
- | Anti-pattern | Consequence | Fix |
373
- |---|---|---|
374
- | Launching new sessions from wake events | Cascading sessions | Only use `agent_respond`/`agent_output` when woken |
375
- | Adding commentary when forwarding questions | User gets noise, not the question | Quote the agent's exact question, nothing else |
376
- | Auto-responding to design/architecture questions | Decisions made without user input | Only auto-respond to permissions and explicit confirmations |
377
- | Passing `channel` explicitly | Bypasses automatic routing | Let `agentChannels` handle routing automatically |
378
- | Not checking the result of a completed session | User doesn't know what happened | Always read `agent_output` and summarize briefly |
379
- | Launching too many sessions in parallel | `maxSessions` limit reached | Respect the limit, prioritize, sequence if necessary |
380
-
381
- ---
232
+ ## 9. Anti-Patterns
382
233
 
383
- ## 9. Quick tool reference
234
+ - Do not pass a `multi_turn` or `multi_turn_disabled` parameter; all sessions are multi-turn and the parameter no longer exists.
235
+ - Do not pass `channel` manually unless you are debugging routing at a very low level.
236
+ - Do not auto-answer design or scope questions.
237
+ - Do not launch new sessions from wake events.
238
+ - Do not merge or PR an `ask` worktree behind the user's back.
384
239
 
385
- | Tool | Usage | Key parameters |
386
- |---|---|---|
387
- | `agent_launch` | Launch a session | `prompt`, `name`, `workdir`, `multi_turn` |
388
- | `agent_sessions` | List sessions | `status` (all/running/completed/failed/killed) |
389
- | `agent_output` | Read the output | `session`, `full`, `lines` |
390
- | `agent_kill` | Kill or complete a session | `session`, `reason` (`"completed"` or omit) |
391
- | `agent_respond` | Send a follow-up | `session`, `message`, `interrupt`, `approve` |
392
- | `agent_stats` | Usage metrics | none |
240
+ See `README.md` for the product overview and `docs/REFERENCE.md` for the canonical operator reference.
@@ -1,15 +0,0 @@
1
- name: plan-approval
2
- args:
3
- session_id:
4
- required: true
5
- session_name:
6
- required: true
7
- plan_summary:
8
- required: true
9
- steps:
10
- - id: approve
11
- approval: required
12
-
13
- - id: proceed
14
- command: openclaw.invoke --tool agent_respond --args-json '{"session":"$session_id","message":"Approved. Go ahead.","approve":true}'
15
- condition: $approve.approved