openclaw-code-agent 3.0.0 → 3.2.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.
- package/README.md +129 -505
- package/dist/index.js +200 -110
- package/openclaw.plugin.json +12 -35
- package/package.json +37 -12
- package/skills/code-agent-orchestration/SKILL.md +132 -451
|
@@ -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,
|
|
3
|
+
description: Skill for orchestrating coding agent sessions from OpenClaw. Covers launching, monitoring, plan approval, lifecycle management, and worktree decisions.
|
|
4
4
|
metadata:
|
|
5
5
|
openclaw:
|
|
6
6
|
homepage: https://github.com/goldmar/openclaw-code-agent
|
|
@@ -15,515 +15,196 @@ metadata:
|
|
|
15
15
|
|
|
16
16
|
# Code Agent Orchestration
|
|
17
17
|
|
|
18
|
-
|
|
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`.
|
|
72
|
-
|
|
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
|
|
77
|
-
|
|
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.
|
|
79
|
-
|
|
80
|
-
### Examples
|
|
81
|
-
|
|
82
|
-
```
|
|
83
|
-
# Simple task
|
|
84
|
-
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
|
|
97
|
-
)
|
|
98
|
-
```
|
|
20
|
+
## Launch
|
|
99
21
|
|
|
100
|
-
|
|
22
|
+
- Do not pass `channel` manually. Routing comes from `agentChannels`, the current chat context, and `fallbackChannel`.
|
|
23
|
+
- Sessions are multi-turn. Continue existing work with `agent_respond` or `agent_launch(..., resume_session_id=...)`; do not start a fresh session for the same task.
|
|
24
|
+
- Always set a short kebab-case `name` when you care about later follow-up.
|
|
25
|
+
- Set `workdir` to the target repo.
|
|
26
|
+
- Use `permission_mode: "plan"` when the user wants a real review gate before implementation.
|
|
27
|
+
- Use `permission_mode: "bypassPermissions"` only for autonomous execution.
|
|
28
|
+
- `defaultWorktreeStrategy` now defaults to `off`. Opt into a worktree strategy explicitly when you want branch isolation.
|
|
29
|
+
- In `plan` mode, the plan belongs in normal session output. Do not ask the coding agent to write plan docs or transcript artifacts unless the user explicitly asked for a file.
|
|
101
30
|
|
|
102
|
-
|
|
103
|
-
# Resume a completed session
|
|
104
|
-
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
|
|
108
|
-
)
|
|
31
|
+
Example:
|
|
109
32
|
|
|
110
|
-
|
|
33
|
+
```text
|
|
111
34
|
agent_launch(
|
|
112
|
-
prompt: "
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
name: "refactor-db-middleware-approach",
|
|
116
|
-
multi_turn: true
|
|
35
|
+
prompt: "Fix the auth middleware bug and add tests",
|
|
36
|
+
name: "fix-auth",
|
|
37
|
+
workdir: "/home/user/projects/my-app"
|
|
117
38
|
)
|
|
118
39
|
```
|
|
119
40
|
|
|
120
|
-
|
|
121
|
-
|
|
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` |
|
|
126
|
-
|
|
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
|
|
130
|
-
|
|
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.
|
|
132
|
-
|
|
133
|
-
---
|
|
134
|
-
|
|
135
|
-
## 2. Anti-cascade rules (CRITICAL)
|
|
41
|
+
## Resume, Don't Respawn
|
|
136
42
|
|
|
137
|
-
|
|
43
|
+
When a session already exists for the task, keep using it.
|
|
138
44
|
|
|
139
|
-
|
|
45
|
+
- Waiting for plan approval: `agent_respond(session, message, approve=true)` or `agent_request_plan_approval(...)` if delegated approval must escalate to the user
|
|
46
|
+
- Waiting for a question answer: `agent_respond(session, message)`
|
|
47
|
+
- Killed/stopped by restart: `agent_respond(session, message)`
|
|
48
|
+
- Completed but needs follow-up: `agent_launch(resume_session_id=session_id, prompt="...")`
|
|
49
|
+
- Fresh `agent_launch` is only for genuinely independent work
|
|
140
50
|
|
|
141
|
-
|
|
51
|
+
Do not launch a new coding session from a wake event for the same task.
|
|
142
52
|
|
|
143
|
-
##
|
|
53
|
+
## State and Monitoring
|
|
144
54
|
|
|
145
|
-
|
|
55
|
+
Use:
|
|
146
56
|
|
|
147
|
-
```
|
|
148
|
-
# All sessions
|
|
57
|
+
```text
|
|
149
58
|
agent_sessions()
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
agent_sessions(status: "running")
|
|
153
|
-
|
|
154
|
-
# Completed sessions (for resume)
|
|
155
|
-
agent_sessions(status: "completed")
|
|
59
|
+
agent_output(session: "fix-auth", lines: 100)
|
|
60
|
+
agent_output(session: "fix-auth", full: true)
|
|
156
61
|
```
|
|
157
62
|
|
|
158
|
-
|
|
63
|
+
For worktree follow-through, inspect:
|
|
159
64
|
|
|
65
|
+
```text
|
|
66
|
+
agent_worktree_status()
|
|
67
|
+
agent_worktree_status(session: "fix-auth")
|
|
160
68
|
```
|
|
161
|
-
# Summary (last 50 lines)
|
|
162
|
-
agent_output(session: "fix-null-auth")
|
|
163
69
|
|
|
164
|
-
|
|
165
|
-
agent_output(session: "fix-null-auth", full: true)
|
|
70
|
+
Treat that tool's lifecycle, derived state, cleanup disposition, and retained reasons as authoritative. Do not infer cleanup safety from a transcript summary or from branch names alone.
|
|
166
71
|
|
|
167
|
-
|
|
168
|
-
agent_output(session: "fix-null-auth", lines: 100)
|
|
169
|
-
```
|
|
72
|
+
Treat these wake fields as authoritative state when present:
|
|
170
73
|
|
|
171
|
-
|
|
74
|
+
- `requestedPermissionMode`
|
|
75
|
+
- `effectivePermissionMode` / `currentPermissionMode`
|
|
76
|
+
- `approvalExecutionState`
|
|
172
77
|
|
|
173
|
-
|
|
174
|
-
```
|
|
175
|
-
Session: fix-auth [abc123] | Status: RUNNING | Phase: planning | Cost: $0.0312 | Duration: 2m15s
|
|
176
|
-
```
|
|
78
|
+
Use those deterministic fields instead of inferring behavior from transcript fragments.
|
|
177
79
|
|
|
178
|
-
|
|
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
|
|
80
|
+
Approval/execution meanings:
|
|
182
81
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
```
|
|
188
|
-
|
|
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."
|
|
190
|
-
|
|
191
|
-
---
|
|
192
|
-
|
|
193
|
-
## 4. Multi-turn interaction
|
|
194
|
-
|
|
195
|
-
### Send a follow-up
|
|
196
|
-
|
|
197
|
-
```
|
|
198
|
-
# Reply to an agent question
|
|
199
|
-
agent_respond(session: "add-dark-mode", message: "Yes, use CSS variables for the theme colors.")
|
|
82
|
+
- `approved_then_implemented`: normal approved execution
|
|
83
|
+
- `implemented_without_required_approval`: actual approval bypass
|
|
84
|
+
- `awaiting_approval`: still stopped at the approval gate
|
|
85
|
+
- `not_plan_gated`: no plan gate applied
|
|
200
86
|
|
|
201
|
-
|
|
202
|
-
agent_respond(session: "add-dark-mode", message: "Stop. Use Tailwind dark: classes instead of CSS variables.", interrupt: true)
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
### Auto-respond rules (STRICT)
|
|
87
|
+
Completion ownership:
|
|
206
88
|
|
|
207
|
-
|
|
208
|
-
-
|
|
209
|
-
-
|
|
89
|
+
- The plugin sends the canonical completion notification.
|
|
90
|
+
- The plugin owns the canonical completion status line; the orchestrator owns any additional plain-text follow-up.
|
|
91
|
+
- After a coding-agent session completes, the orchestrator should usually add at least a short human-useful summary of what changed, what was done, or the concrete outcome.
|
|
92
|
+
- That expectation applies to ordinary terminal/manual completions, manual no-change completions, and delegated worktree completions alike.
|
|
93
|
+
- Treat the plugin's canonical `✅` as the status signal and your follow-up as the factual outcome summary that should usually come right after it.
|
|
94
|
+
- That summary can be brief; one sentence is often enough.
|
|
95
|
+
- Extra synthesis, risk framing, and next-step guidance are optional. Add them when useful; do not force them every time.
|
|
96
|
+
- Do not generate your own heuristic completion summary from transcript tail lines. Base any summary on reliable result data such as `agent_output(..., full=true)`, diff context, or deterministic tool state.
|
|
97
|
+
- Skip the summary only in narrow cases:
|
|
98
|
+
- no user-facing follow-up will be sent at all because the orchestrator is silently continuing an internal multi-phase pipeline
|
|
99
|
+
- the completion produced no meaningful outcome to report, or the reliable result data is still too incomplete to support even a short factual summary
|
|
210
100
|
|
|
211
|
-
|
|
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
|
|
101
|
+
## Respond Rules
|
|
220
102
|
|
|
221
|
-
|
|
103
|
+
Auto-respond immediately only for:
|
|
222
104
|
|
|
223
|
-
|
|
105
|
+
- permission requests for file reads, writes, or shell commands
|
|
106
|
+
- explicit continuation prompts such as "Should I continue?"
|
|
224
107
|
|
|
225
|
-
|
|
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
|
-
---
|
|
108
|
+
Forward everything else to the user:
|
|
233
109
|
|
|
234
|
-
|
|
110
|
+
- architecture or design choices
|
|
111
|
+
- destructive operations
|
|
112
|
+
- scope changes
|
|
113
|
+
- credentials or production questions
|
|
114
|
+
- ambiguous requirements
|
|
235
115
|
|
|
236
|
-
|
|
116
|
+
When forwarding, quote the session's exact question. Do not add commentary.
|
|
237
117
|
|
|
238
|
-
|
|
239
|
-
# Kill a stuck/looping session
|
|
240
|
-
agent_kill(session: "fix-null-auth")
|
|
118
|
+
## Plan Approval
|
|
241
119
|
|
|
242
|
-
|
|
243
|
-
agent_kill(session: "fix-null-auth", reason: "completed")
|
|
244
|
-
```
|
|
120
|
+
Use `permission_mode: "plan"` whenever the user wants a real planning checkpoint.
|
|
245
121
|
|
|
246
|
-
|
|
247
|
-
- The session is stuck or looping
|
|
248
|
-
- The user requests a stop
|
|
122
|
+
### `planApproval: "ask"`
|
|
249
123
|
|
|
250
|
-
|
|
251
|
-
- The
|
|
252
|
-
-
|
|
124
|
+
- Approval belongs to the user.
|
|
125
|
+
- The plugin sends the canonical Approve / Revise / Reject prompt directly to the user.
|
|
126
|
+
- If the user requests changes, wait for the revised plan from that same session; the revised submission becomes the latest actionable review version automatically.
|
|
127
|
+
- Wait for the user's answer, then forward it with `agent_respond(...)`.
|
|
128
|
+
- Do not send a duplicate approval recap or second approval prompt.
|
|
253
129
|
|
|
254
|
-
###
|
|
130
|
+
### `planApproval: "delegate"`
|
|
255
131
|
|
|
256
|
-
-
|
|
257
|
-
-
|
|
258
|
-
-
|
|
259
|
-
-
|
|
132
|
+
- Approval belongs to the orchestrator first.
|
|
133
|
+
- This is wake-first: the plugin wakes the orchestrator without user buttons.
|
|
134
|
+
- Before deciding, read the full plan with `agent_output(session, full=true)`; do not rely on the truncated preview.
|
|
135
|
+
- Approve directly with `agent_respond(..., approve=true)` only when the latest actionable plan version is clearly in-bounds and low risk.
|
|
136
|
+
- When approving directly, pass a structured rationale with `approval_rationale`, for example: `agent_respond(session='...', message='Approved. Go ahead.', approve=true, approval_rationale='Scope matches the request and the changes are low risk.')`
|
|
137
|
+
- After approving directly, send the user a short plain-text follow-up explaining what was approved and why. The plugin's `👍 Plan approved` line is only a fallback signal, not the full explanation.
|
|
138
|
+
- If a prior version had `changes_requested`, that stale state should not block approval of the latest revised plan version.
|
|
139
|
+
- If escalation is needed, call `agent_request_plan_approval(session='...', summary='...')` exactly once so the plugin sends the single canonical user approval prompt.
|
|
140
|
+
- That escalation summary must concisely explain why you are escalating, plus risk/scope notes the user needs to decide.
|
|
141
|
+
- After that canonical prompt exists, wait for the user's decision; do not send a second plain-text approval summary.
|
|
260
142
|
|
|
261
|
-
###
|
|
143
|
+
### `planApproval: "approve"`
|
|
262
144
|
|
|
263
|
-
-
|
|
264
|
-
- Completed sessions are garbage-collected after 1h but remain resumable via persisted IDs
|
|
145
|
+
- Auto-approve only after verification per the session policy.
|
|
265
146
|
|
|
266
|
-
|
|
147
|
+
## Worktree Decisions
|
|
267
148
|
|
|
268
|
-
|
|
149
|
+
Treat worktrees as temporary task sandboxes, not as generic branch inventory.
|
|
269
150
|
|
|
270
|
-
|
|
271
|
-
2. Summarize briefly: files changed, cost, duration, any issues
|
|
272
|
-
3. If failed, analyze the error and decide: relaunch, fork, or escalate
|
|
151
|
+
Lifecycle meanings:
|
|
273
152
|
|
|
274
|
-
|
|
153
|
+
- `pending_decision`: still waiting for merge / PR / dismiss follow-through
|
|
154
|
+
- `pr_open`: PR exists; preserve the sandbox
|
|
155
|
+
- `merged`: normal ancestry merge landed
|
|
156
|
+
- `released`: content already landed on the base branch even though SHAs differ after rebase, squash, or cherry-pick
|
|
157
|
+
- `dismissed`: sandbox intentionally discarded
|
|
158
|
+
- `no_change`: no committed delta
|
|
275
159
|
|
|
276
|
-
|
|
160
|
+
If `agent_worktree_status` reports `released`, treat that sandbox as already landed. Do not narrate it as “still unmerged” just because the branch appears ahead.
|
|
277
161
|
|
|
278
|
-
###
|
|
162
|
+
### `off`
|
|
279
163
|
|
|
280
|
-
|
|
164
|
+
- No worktree. The session runs in the main checkout.
|
|
281
165
|
|
|
282
|
-
###
|
|
166
|
+
### `ask`
|
|
283
167
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
| Session completed | `✅ Completed` — brief one-liner to originating thread |
|
|
288
|
-
| Session completed (deliverable mode) | `📄 Deliverable ready` — when launched with `output_mode: "deliverable"` |
|
|
289
|
-
| Session failed | `❌ Failed` — error notification with `harnessSessionId` and resume guidance |
|
|
290
|
-
| Waiting for input | `❓ Waiting for input` — wake event (only when the agent actually asks a question) |
|
|
291
|
-
| Turn completes without a question | `⏸️ Paused after turn \| Auto-resumable` |
|
|
292
|
-
| `agent_respond` send | `↪️` — notification sent for every `agent_respond` call |
|
|
293
|
-
| `agent_respond` plan approval | `👍` — notification sent when `approve: true` |
|
|
294
|
-
| Session auto-resumes | `▶️ Auto-resumed` |
|
|
295
|
-
| Session idle-times out | `💤 Idle timeout` |
|
|
296
|
-
| Session is forcibly stopped | `⛔ Stopped ...` with the specific stop reason |
|
|
297
|
-
| Worktree decision pending (`ask`) | Inline Telegram buttons sent to user (Merge locally / Create PR) — Alice must NOT preempt |
|
|
298
|
-
| Worktree decision pending (`delegate`) | Wake sent to Alice with diff context — Alice must decide and call `agent_merge` or `agent_pr` |
|
|
168
|
+
- The plugin owns the user-facing completion/decision message and button UI.
|
|
169
|
+
- Do not call `agent_merge` or `agent_pr` unless the user explicitly asks after that.
|
|
170
|
+
- A completed ask-session worktree may later resolve as `released` if its content already landed on base through another path. Confirm that with `agent_worktree_status(...)` before deciding what follow-up is still needed.
|
|
299
171
|
|
|
300
|
-
###
|
|
172
|
+
### `delegate`
|
|
301
173
|
|
|
302
|
-
|
|
174
|
+
- The plugin wakes the orchestrator with diff context and no automatic user buttons.
|
|
175
|
+
- Read the diff context and decide whether a local merge is clearly safe.
|
|
176
|
+
- `agent_merge` is acceptable for low-risk, clearly scoped changes that match the task.
|
|
177
|
+
- Never call `agent_pr()` autonomously in delegate flows. Escalate PR decisions to the user.
|
|
178
|
+
- If the wake already says the plugin sent the canonical completion notification, do not repeat that status line, but you should still usually add a short summary of the completed outcome.
|
|
303
179
|
|
|
304
|
-
|
|
305
|
-
# Correct — standalone message, guaranteed notification ping
|
|
306
|
-
openclaw message send --channel telegram --target <chatId> --thread-id <topicId> \
|
|
307
|
-
--message "✅ [session-name] Done — <one-line summary>"
|
|
308
|
-
```
|
|
180
|
+
### `manual`
|
|
309
181
|
|
|
310
|
-
|
|
182
|
+
- Wait for an explicit user request before calling `agent_merge` or `agent_pr`.
|
|
311
183
|
|
|
312
|
-
|
|
184
|
+
### Cleanup
|
|
313
185
|
|
|
314
|
-
|
|
186
|
+
- Use `agent_worktree_cleanup(mode: "preview_safe")` to review what **Clean all safe** would remove.
|
|
187
|
+
- Use `agent_worktree_cleanup(mode: "clean_safe")` only when the user asked to clean up safe sandboxes.
|
|
188
|
+
- Use `agent_worktree_cleanup(mode: "preview_all")` when you need both safe candidates and retained reasons.
|
|
189
|
+
- Respect retained reasons from `agent_worktree_status` / `agent_worktree_cleanup`; they are the lifecycle model, not advisory prose.
|
|
315
190
|
|
|
316
|
-
###
|
|
317
|
-
|
|
318
|
-
When a session completes with `worktree_strategy: "ask"`, the plugin sends the user a single consolidated Telegram message that contains:
|
|
319
|
-
- The full commit list and diff stats
|
|
320
|
-
- The ⬇️ Merge locally / 🔀 Create PR inline buttons
|
|
321
|
-
|
|
322
|
-
**Do NOT send a separate completion summary.** The button message IS the completion signal. Sending an additional "✅ Done!" or "Here's what was done:" message creates duplicates and confuses the user.
|
|
323
|
-
|
|
324
|
-
This applies when the wake message says "Worktree strategy buttons delivered to user." — treat that as confirmation that the user is already fully informed. Take no further action until the user clicks a button.
|
|
325
|
-
|
|
326
|
-
**Buttons are handled automatically by the plugin.** When the user taps a button, the plugin's callback router dispatches the action (`agent_merge` or `agent_pr`) directly — no agent `agent_merge`/`agent_pr` call is needed in response to a button tap. If the action succeeds, the plugin sends a result notification. If the action fails, a failure notification is sent. Alice does not need to poll or intervene.
|
|
327
|
-
|
|
328
|
-
---
|
|
329
|
-
|
|
330
|
-
### Plan → Execute mode switch
|
|
331
|
-
|
|
332
|
-
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.
|
|
333
|
-
|
|
334
|
-
### Permission escalation with `approve: true`
|
|
335
|
-
|
|
336
|
-
The `approve` parameter on `agent_respond` escalates session permissions to `bypassPermissions`. It works in two scenarios:
|
|
337
|
-
|
|
338
|
-
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`. Sends a 👍 notification.
|
|
339
|
-
2. **`default` mode escalation**: When a session in `default` mode keeps prompting for shell/exec command permissions, `approve: true` escalates to `bypassPermissions` to skip all remaining prompts.
|
|
340
|
-
|
|
341
|
-
If the session is already in `bypassPermissions` mode, `approve: true` is a no-op. In `plan` mode without a pending plan, it is ignored.
|
|
342
|
-
|
|
343
|
-
```
|
|
344
|
-
# Escalate a session that keeps prompting for bash permissions
|
|
345
|
-
agent_respond(session: "fix-auth", message: "proceed", approve: true)
|
|
346
|
-
```
|
|
191
|
+
### Never
|
|
347
192
|
|
|
348
|
-
|
|
193
|
+
- Never use raw `git merge` or raw PR commands in place of plugin tools.
|
|
194
|
+
- Never invent your own workaround for a pending worktree decision; use `agent_worktree_cleanup(session: "...", dismiss_session: true)` to dismiss permanently.
|
|
195
|
+
- Never use `agent_worktree_cleanup` to force-delete unresolved worktrees. The supported bulk action is "clean all safe": omit `session` and let the plugin remove only lifecycle-safe worktrees while preserving anything active, pending, dirty, or PR-open.
|
|
196
|
+
- Never merge or PR an `ask` worktree behind the user's back.
|
|
349
197
|
|
|
350
|
-
|
|
198
|
+
## File Artifact Policy
|
|
351
199
|
|
|
352
|
-
-
|
|
353
|
-
-
|
|
354
|
-
-
|
|
200
|
+
- Do not ask the coding agent to write planning documents, investigation notes, or analysis artifacts as files unless the user explicitly requested a file.
|
|
201
|
+
- Do not commit planning documents, investigation notes, or transcript-summary artifacts to the branch.
|
|
202
|
+
- Commit only actual code, configuration, tests, and explicitly requested documentation.
|
|
355
203
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
When operating in `delegate` mode, **approve** the plan directly if ALL of the following are true:
|
|
359
|
-
- The plan scope matches the original task request
|
|
360
|
-
- The changes are low-risk (no destructive operations, no credential handling, no production deployments)
|
|
361
|
-
- The plan is clear and well-scoped (no ambiguous requirements or open design questions)
|
|
362
|
-
- No architectural decisions that the user should weigh in on
|
|
363
|
-
- The working directory and codebase are correct
|
|
364
|
-
|
|
365
|
-
**Escalate** to the user (forward with 👋 and wait) if ANY of the following are true:
|
|
366
|
-
- Destructive operations (deleting files, dropping tables, force-pushing)
|
|
367
|
-
- Credentials, secrets, or production environments
|
|
368
|
-
- Architectural decisions not covered by the original task
|
|
369
|
-
- Scope expanded beyond the original request
|
|
370
|
-
- Ambiguous requirements or assumptions the user should confirm
|
|
371
|
-
- When in doubt — always escalate
|
|
372
|
-
|
|
373
|
-
---
|
|
374
|
-
|
|
375
|
-
## 7. Worktree workflow
|
|
376
|
-
|
|
377
|
-
When a session uses `worktree_strategy`, the agent runs in an isolated git branch. After completion, the branch needs to be merged or published as a PR.
|
|
378
|
-
|
|
379
|
-
### Strategies at a glance
|
|
380
|
-
|
|
381
|
-
| Strategy | What it does | When to use |
|
|
382
|
-
|---|---|---|
|
|
383
|
-
| `off` | No worktree. Session runs in main checkout | Simple/trusted tasks where isolation isn't needed |
|
|
384
|
-
| `ask` (default) | Push branch and send inline buttons (Merge locally / Create PR); wake orchestrator with full decision context | User should decide — the interactive default |
|
|
385
|
-
| `delegate` | Push branch and wake orchestrator to decide autonomously (merge, create PR, or leave for later) | Set via `defaultWorktreeStrategy` config — orchestrator decides autonomously |
|
|
386
|
-
| `auto-merge` | Automatically merge back to base branch on completion; spawns conflict-resolver if needed | Trusted tasks on a safe branch |
|
|
387
|
-
| `auto-pr` | Automatically open a GitHub PR on completion (requires `gh`) | Feature branches needing review |
|
|
388
|
-
| `manual` | Push the branch; no further action — user handles merge/PR manually | You want to review diffs before merging |
|
|
389
|
-
|
|
390
|
-
### Launch with worktree isolation
|
|
391
|
-
|
|
392
|
-
```
|
|
393
|
-
agent_launch(
|
|
394
|
-
prompt: "Implement the new user settings page",
|
|
395
|
-
name: "user-settings",
|
|
396
|
-
workdir: "/app",
|
|
397
|
-
worktree_strategy: "auto-pr"
|
|
398
|
-
)
|
|
399
|
-
```
|
|
400
|
-
|
|
401
|
-
### Post-completion behavior by strategy
|
|
402
|
-
|
|
403
|
-
When a session with a worktree completes, your action depends on the strategy:
|
|
404
|
-
|
|
405
|
-
| Strategy | What to do after completion |
|
|
406
|
-
|---|---|
|
|
407
|
-
| `ask` | **Do nothing.** The plugin sends inline Telegram buttons (Merge locally / Create PR) to the user. **Never** call `agent_merge`, `agent_pr`, or any `git` command — wait for the user to decide. |
|
|
408
|
-
| `delegate` | You receive a `worktree-delegate` wake with diff context. Evaluate and act (see *Delegate mode* below). |
|
|
409
|
-
| `auto-merge` | No action needed — merge happens automatically. Watch for `worktree-merge-success` or `worktree-merge-conflict` notification. |
|
|
410
|
-
| `auto-pr` | No action needed — PR is created/updated automatically. |
|
|
411
|
-
| `manual` | Call `agent_merge` or `agent_pr` **only** when the user explicitly asks. |
|
|
412
|
-
| `off` | No worktree — nothing to merge. |
|
|
413
|
-
|
|
414
|
-
Note: the ⏸️ turn-complete wake is suppressed for both `ask` and `delegate` strategies — the worktree decision notification replaces it as the completion signal.
|
|
415
|
-
|
|
416
|
-
### Delegate mode: deciding merge vs PR
|
|
417
|
-
|
|
418
|
-
When you receive a `worktree-delegate` wake:
|
|
419
|
-
|
|
420
|
-
1. **Evaluate the diff** — read the commit count, files changed, and diff summary included in the wake message
|
|
421
|
-
2. **Compare to original task scope** — does the diff match what was asked?
|
|
422
|
-
3. **Decide:**
|
|
423
|
-
- **Call `agent_merge`** when: changes are low-risk, well-scoped, match the original task, and no code review is needed
|
|
424
|
-
- **Call `agent_pr`** when: changes are non-trivial, touch many files, introduce significant complexity, or when uncertain
|
|
425
|
-
- **Escalate to the user** when: changes are ambiguous, out of scope, or involve sensitive areas
|
|
426
|
-
4. **Notify the user briefly** — send a short message with your decision and one-sentence reasoning (e.g. "Merged `agent/feature-x` — straightforward 2-file change matching the original task.")
|
|
427
|
-
5. **Never use raw `git` commands** — always use `agent_merge` or `agent_pr`
|
|
428
|
-
|
|
429
|
-
### Check worktree status
|
|
430
|
-
|
|
431
|
-
```
|
|
432
|
-
agent_worktree_status() # all sessions with worktrees
|
|
433
|
-
agent_worktree_status(session: "user-settings") # specific session
|
|
434
|
-
```
|
|
435
|
-
|
|
436
|
-
### Manual merge or PR after `manual`/`ask`
|
|
437
|
-
|
|
438
|
-
```
|
|
439
|
-
# Merge back to base branch
|
|
440
|
-
agent_merge(session: "user-settings", strategy: "merge")
|
|
441
|
-
|
|
442
|
-
# Or create/update a GitHub PR
|
|
443
|
-
agent_pr(session: "user-settings", title: "Add user settings page")
|
|
444
|
-
```
|
|
445
|
-
|
|
446
|
-
### Resume with worktree context
|
|
447
|
-
|
|
448
|
-
When resuming a session that had a worktree, the worktree context (branch, strategy, PR URL) is inherited automatically — no need to pass `worktree_strategy` again:
|
|
449
|
-
|
|
450
|
-
```
|
|
451
|
-
agent_launch(
|
|
452
|
-
prompt: "Continue — also add unit tests",
|
|
453
|
-
resume_session_id: "user-settings"
|
|
454
|
-
)
|
|
455
|
-
```
|
|
456
|
-
|
|
457
|
-
### Deliverable mode
|
|
458
|
-
|
|
459
|
-
For document/report generation tasks, use `output_mode: "deliverable"` to send 📄 instead of ✅:
|
|
460
|
-
|
|
461
|
-
```
|
|
462
|
-
agent_launch(
|
|
463
|
-
prompt: "Write a technical spec for the new auth system",
|
|
464
|
-
name: "auth-spec",
|
|
465
|
-
output_mode: "deliverable"
|
|
466
|
-
)
|
|
467
|
-
```
|
|
468
|
-
|
|
469
|
-
---
|
|
470
|
-
|
|
471
|
-
## 8. Best practices
|
|
472
|
-
|
|
473
|
-
### Launch checklist
|
|
474
|
-
|
|
475
|
-
1. `agentChannels` is configured for this workdir -> notifications arrive
|
|
476
|
-
2. `multi_turn: true` -> interaction is possible after launch
|
|
477
|
-
3. `name` is descriptive -> easy to identify in `agent_sessions`
|
|
478
|
-
4. `workdir` points to the correct project -> the agent works in the right directory
|
|
479
|
-
|
|
480
|
-
### Parallel tasks
|
|
481
|
-
|
|
482
|
-
```
|
|
483
|
-
# Launch multiple sessions on independent tasks
|
|
484
|
-
agent_launch(prompt: "Build the frontend auth page", name: "frontend-auth", workdir: "/app/frontend", multi_turn: true)
|
|
485
|
-
agent_launch(prompt: "Build the backend auth API", name: "backend-auth", workdir: "/app/backend", multi_turn: true)
|
|
486
|
-
```
|
|
487
|
-
|
|
488
|
-
- Respect the `maxSessions` limit (default: 5)
|
|
489
|
-
- Each session must have a unique `name`
|
|
490
|
-
- Monitor each session individually via wake events
|
|
491
|
-
|
|
492
|
-
### Reporting results
|
|
493
|
-
|
|
494
|
-
When a session completes, keep summaries brief:
|
|
495
|
-
- Files changed
|
|
496
|
-
- Cost and duration
|
|
497
|
-
- Any issues or remaining TODOs
|
|
498
|
-
|
|
499
|
-
---
|
|
500
|
-
|
|
501
|
-
## 9. Anti-patterns
|
|
502
|
-
|
|
503
|
-
| Anti-pattern | Consequence | Fix |
|
|
504
|
-
|---|---|---|
|
|
505
|
-
| Launching new sessions from wake events | Cascading sessions | Only use `agent_respond`/`agent_output` when woken |
|
|
506
|
-
| Adding commentary when forwarding questions | User gets noise, not the question | Quote the agent's exact question, nothing else |
|
|
507
|
-
| Auto-responding to design/architecture questions | Decisions made without user input | Only auto-respond to permissions and explicit confirmations |
|
|
508
|
-
| Passing `channel` explicitly | Bypasses automatic routing | Let `agentChannels` handle routing automatically |
|
|
509
|
-
| Not checking the result of a completed session | User doesn't know what happened | Always read `agent_output` and summarize briefly |
|
|
510
|
-
| Launching too many sessions in parallel | `maxSessions` limit reached | Respect the limit, prioritize, sequence if necessary |
|
|
511
|
-
| Calling `agent_merge` or `agent_pr` when strategy is `ask` | Bypasses the user's inline-button decision | Wait for the Telegram buttons — do nothing until the user decides |
|
|
512
|
-
| Using raw `git merge` instead of `agent_merge` | Skips conflict resolution, cleanup, and session state tracking | Always use `agent_merge` when the user asks to merge a worktree branch |
|
|
513
|
-
|
|
514
|
-
---
|
|
204
|
+
## Anti-Patterns
|
|
515
205
|
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
| `agent_sessions` | List sessions | `status` (all/running/completed/failed/killed) |
|
|
522
|
-
| `agent_output` | Read the output | `session`, `full`, `lines` |
|
|
523
|
-
| `agent_kill` | Kill or complete a session | `session`, `reason` (`"completed"` or omit) |
|
|
524
|
-
| `agent_respond` | Send a follow-up | `session`, `message`, `interrupt`, `approve` |
|
|
525
|
-
| `agent_stats` | Usage metrics | none |
|
|
526
|
-
| `agent_worktree_status` | Show worktree status for sessions | `session` (optional — omit for all) |
|
|
527
|
-
| `agent_merge` | Merge worktree branch to base | `session`, `base_branch`, `strategy`, `push`, `delete_branch` |
|
|
528
|
-
| `agent_pr` | Create/update GitHub PR for worktree branch | `session`, `title`, `body`, `base_branch`, `force_new` |
|
|
529
|
-
| `agent_worktree_cleanup` | Clean up merged agent/* branches | `workdir`, `base_branch`, `skip_session_check`, `dry_run`, `session` |
|
|
206
|
+
- Do not pass `multi_turn` or `multi_turn_disabled`; all sessions are multi-turn.
|
|
207
|
+
- Do not pass `channel` manually unless you are debugging routing.
|
|
208
|
+
- Do not auto-answer design or scope questions.
|
|
209
|
+
- Do not infer approval/completion ownership from old transcript snippets when deterministic fields are present.
|
|
210
|
+
- Do not post duplicate completion or approval recaps when the plugin already sent the canonical message.
|