nextclaw 0.6.26 → 0.6.27

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/dist/cli/index.js CHANGED
@@ -2336,7 +2336,8 @@ function resolveAgentProfiles(config2) {
2336
2336
  workspace: entry.workspace,
2337
2337
  model: entry.model,
2338
2338
  maxToolIterations: entry.maxToolIterations,
2339
- maxTokens: entry.maxTokens
2339
+ maxTokens: entry.maxTokens,
2340
+ contextTokens: entry.contextTokens
2340
2341
  })).filter((entry) => Boolean(entry.id)) : [];
2341
2342
  const defaultAgentId = listed.find((entry) => entry.default)?.id ?? listed[0]?.id ?? "main";
2342
2343
  const seed = listed.length > 0 ? listed : [{ id: defaultAgentId }];
@@ -2354,7 +2355,8 @@ function resolveAgentProfiles(config2) {
2354
2355
  workspace: getWorkspacePath4(entry.workspace ?? defaults.workspace),
2355
2356
  model: entry.model ?? defaults.model,
2356
2357
  maxIterations: entry.maxToolIterations ?? defaults.maxToolIterations,
2357
- maxTokens: entry.maxTokens ?? defaults.maxTokens
2358
+ maxTokens: entry.maxTokens ?? defaults.maxTokens,
2359
+ contextTokens: entry.contextTokens ?? defaults.contextTokens
2358
2360
  }));
2359
2361
  }
2360
2362
  var GatewayAgentRuntimePool = class {
@@ -2465,6 +2467,7 @@ var GatewayAgentRuntimePool = class {
2465
2467
  model: profile.model,
2466
2468
  maxIterations: profile.maxIterations,
2467
2469
  maxTokens: profile.maxTokens,
2470
+ contextTokens: profile.contextTokens,
2468
2471
  braveApiKey: this.options.braveApiKey,
2469
2472
  execConfig: this.options.execConfig,
2470
2473
  cronService: this.options.cronService,
@@ -3555,6 +3558,7 @@ ${this.logo} ${APP_NAME4} is ready! (${source})`);
3555
3558
  model: config2.agents.defaults.model,
3556
3559
  maxIterations: config2.agents.defaults.maxToolIterations,
3557
3560
  maxTokens: config2.agents.defaults.maxTokens,
3561
+ contextTokens: config2.agents.defaults.contextTokens,
3558
3562
  braveApiKey: config2.tools.web.search.apiKey || void 0,
3559
3563
  execConfig: config2.tools.exec,
3560
3564
  restrictToWorkspace: config2.tools.restrictToWorkspace,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nextclaw",
3
- "version": "0.6.26",
3
+ "version": "0.6.27",
4
4
  "description": "Lightweight personal AI assistant with CLI, multi-provider routing, and channel integrations.",
5
5
  "private": false,
6
6
  "type": "module",
@@ -38,9 +38,9 @@
38
38
  "dependencies": {
39
39
  "chokidar": "^3.6.0",
40
40
  "commander": "^12.1.0",
41
- "@nextclaw/core": "^0.6.23",
42
- "@nextclaw/server": "^0.4.9",
43
- "@nextclaw/openclaw-compat": "^0.1.16"
41
+ "@nextclaw/core": "^0.6.24",
42
+ "@nextclaw/server": "^0.4.10",
43
+ "@nextclaw/openclaw-compat": "^0.1.17"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/node": "^20.17.6",
@@ -23,6 +23,7 @@ When NextClaw AI needs to operate the product itself (status/doctor/channels/con
23
23
  - [AI Self-Management Contract](#ai-self-management-contract)
24
24
  - [Quick Start](#quick-start)
25
25
  - [Configuration](#configuration)
26
+ - [Input context budget](#input-context-budget)
26
27
  - [Multi-agent routing & session isolation](#multi-agent-routing--session-isolation-openclaw-aligned)
27
28
  - [Workspace](#workspace)
28
29
  - [Commands](#commands)
@@ -131,6 +132,7 @@ When the gateway is already running, config changes from the UI or `nextclaw con
131
132
  - `agents.defaults.model`
132
133
  - `agents.defaults.maxToolIterations`
133
134
  - `agents.defaults.maxTokens`
135
+ - `agents.defaults.contextTokens`
134
136
  - `agents.context.*`
135
137
  - `tools.*`
136
138
 
@@ -150,6 +152,8 @@ You can now configure OpenClaw-style multi-agent runtime behavior directly in th
150
152
  - `session.dmScope`: DM isolation strategy (`main` / `per-peer` / `per-channel-peer` / `per-account-channel-peer`)
151
153
  - `session.agentToAgent.maxPingPongTurns`: cap cross-agent ping-pong loops (`0` means block auto ping-pong)
152
154
 
155
+ See full architecture details in [Multi-Agent Architecture](guides/multi-agent-architecture.md).
156
+
153
157
  Example:
154
158
 
155
159
  ```json
@@ -163,6 +167,7 @@ Example:
163
167
  "workspace": "~/workspace-engineer",
164
168
  "model": "openai/gpt-5.2-codex",
165
169
  "maxTokens": 12000,
170
+ "contextTokens": 200000,
166
171
  "maxToolIterations": 24
167
172
  }
168
173
  ]
@@ -193,6 +198,123 @@ nextclaw config set session.dmScope '"per-account-channel-peer"' --json
193
198
  nextclaw config set session.agentToAgent.maxPingPongTurns 0 --json
194
199
  ```
195
200
 
201
+ ### Multi-agent collaboration playbook (recommended)
202
+
203
+ Use this baseline for predictable team-style collaboration:
204
+
205
+ 1. Keep `main` as the default fallback role.
206
+ 2. Add specialist agents in `agents.list` (for example `engineer`, `ops`, `support`).
207
+ 3. Route stable traffic classes with `bindings` (channel/account/peer based).
208
+ 4. Use `session.dmScope="per-account-channel-peer"` for multi-account + multi-channel isolation.
209
+ 5. Set `session.agentToAgent.maxPingPongTurns=0` first, then increase only when you explicitly want cross-agent relay.
210
+
211
+ Suggested role split:
212
+
213
+ - `main`: default reception, broad Q&A, fallback when no binding matches.
214
+ - `engineer`: technical channels / dev rooms.
215
+ - `ops`: deployment/monitoring channels.
216
+ - `support`: customer-facing groups.
217
+
218
+ ### Binding match semantics (deterministic)
219
+
220
+ `bindings` are processed in array order, and the **first matching rule wins**.
221
+
222
+ - `match.channel` is required for a valid match.
223
+ - `match.accountId`:
224
+ - omitted/empty => matches only account `default`
225
+ - `"*"` => matches all accounts
226
+ - specific value => matches that normalized account id
227
+ - `match.peer` omitted => matches all peers under the selected channel/account scope.
228
+ - if no binding matches, routing falls back to the default agent (`agents.list[].default`, otherwise first agent, otherwise `main`).
229
+
230
+ Example with explicit precedence (more specific rule first):
231
+
232
+ ```json
233
+ {
234
+ "bindings": [
235
+ {
236
+ "agentId": "engineer",
237
+ "match": {
238
+ "channel": "discord",
239
+ "accountId": "zongzhihui",
240
+ "peer": { "kind": "channel", "id": "dev-room" }
241
+ }
242
+ },
243
+ {
244
+ "agentId": "support",
245
+ "match": {
246
+ "channel": "discord",
247
+ "accountId": "*"
248
+ }
249
+ }
250
+ ]
251
+ }
252
+ ```
253
+
254
+ ### Collaboration recipes
255
+
256
+ Recipe A — default + specialist routing:
257
+
258
+ ```bash
259
+ nextclaw config set agents.list '[{"id":"main","default":true},{"id":"engineer"}]' --json
260
+ nextclaw config set bindings '[{"agentId":"engineer","match":{"channel":"discord","accountId":"zongzhihui","peer":{"kind":"channel","id":"dev-room"}}}]' --json
261
+ ```
262
+
263
+ Recipe B — multi-account safe isolation:
264
+
265
+ ```bash
266
+ nextclaw config set session.dmScope '"per-account-channel-peer"' --json
267
+ ```
268
+
269
+ Recipe C — reduce noisy group triggering:
270
+
271
+ ```bash
272
+ nextclaw config set channels.discord.requireMention true --json
273
+ nextclaw config set channels.discord.groupPolicy '"allowlist"' --json
274
+ nextclaw config set channels.discord.groupAllowFrom '["dev-room"]' --json
275
+ ```
276
+
277
+ ### Multi-agent acceptance checklist
278
+
279
+ 1. Prepare at least two agents (`main` + one specialist).
280
+ 2. Add at least one binding and verify inbound messages hit the expected role.
281
+ 3. Verify DM isolation across user/channel/account boundaries under the selected `dmScope`.
282
+ 4. If Discord/Telegram group collaboration is enabled, verify mention gating (`requireMention` / `mentionPatterns`) behavior.
283
+ 5. Verify auto ping-pong policy with `session.agentToAgent.maxPingPongTurns` (set `0` to block).
284
+
285
+ Pass criteria: stable routing, no cross-session context leakage, predictable group triggering, explainable fallback behavior.
286
+
287
+ ### Multi-agent troubleshooting quick map
288
+
289
+ - Routed to wrong agent:
290
+ - check binding order (specific rules must be before broad rules)
291
+ - confirm `match.accountId` and `match.peer` actually match inbound metadata
292
+ - Always falls back to `main`:
293
+ - verify `bindings` is not empty and `match.channel` is correct
294
+ - verify target `agentId` exists in `agents.list`
295
+ - Group messages not triggering:
296
+ - check `groupPolicy`, `groupAllowFrom`, and `requireMention`
297
+ - confirm message text matches configured `mentionPatterns` if enabled
298
+ - DM context looks mixed:
299
+ - switch to `session.dmScope="per-account-channel-peer"`
300
+ - re-test across two users/channels/accounts and compare outcomes
301
+
302
+ ### Input context budget
303
+
304
+ NextClaw now applies a token-budget input pruner before each model call.
305
+
306
+ - `agents.defaults.contextTokens`: model input context budget (default `200000`)
307
+ - reserve floor: `20000` tokens
308
+ - soft threshold: `4000` tokens
309
+ - when over budget: trim tool results first, then drop oldest history, then trim oversized prompt/user tail as final fallback
310
+
311
+ CLI examples:
312
+
313
+ ```bash
314
+ nextclaw config set agents.defaults.contextTokens 200000 --json
315
+ nextclaw config set agents.list '[{"id":"engineer","contextTokens":160000}]' --json
316
+ ```
317
+
196
318
  For internal AI operations (same as other built-in capabilities):
197
319
 
198
320
  - Yes, the runtime registers the `gateway` tool (`config.get` / `config.schema` / `config.apply` / `config.patch`).