opencode-swarm 6.19.7 → 6.20.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 CHANGED
@@ -385,6 +385,119 @@ Per-agent overrides:
385
385
 
386
386
  </details>
387
387
 
388
+ <details>
389
+ <summary><strong>Context Budget Guard</strong></summary>
390
+
391
+ The Context Budget Guard monitors how much context Swarm is injecting into the conversation. It helps prevent context overflow before it becomes a problem.
392
+
393
+ ### Default Behavior
394
+
395
+ - **Enabled automatically** — No setup required. Swarm starts tracking context usage right away.
396
+ - **What it measures** — Only the context that Swarm injects (plan, context, evidence, retrospectives). It does **not** count your chat history or the model's responses.
397
+ - **Warning threshold (0.7 ratio)** — When swarm-injected context reaches ~2800 tokens (70% of 4000), the architect receives a one-time advisory warning. This is informational — execution continues normally.
398
+ - **Critical threshold (0.9 ratio)** — When context reaches ~3600 tokens (90% of 4000), the architect receives a critical alert with a recommendation to run `/swarm handoff`. This is also one-time only.
399
+ - **Non-nagging** — Alerts fire once per session, not repeatedly. You won't be pestered every turn.
400
+ - **Who sees warnings** — Only the architect receives these warnings. Other agents are unaware of the budget.
401
+
402
+ To disable entirely, set `context_budget.enabled: false` in your swarm config.
403
+
404
+ ### Configuration Reference
405
+
406
+ | Key | Type | Default | Description |
407
+ |-----|------|---------|-------------|
408
+ | `context_budget.enabled` | boolean | `true` | Enable or disable the context budget guard entirely |
409
+ | `context_budget.max_injection_tokens` | number | `4000` | Token budget for swarm-injected context per turn. This is NOT the model's context window — it's the swarm plugin's own contribution |
410
+ | `context_budget.warn_threshold` | number | `0.7` | Ratio (0.0-1.0) of `max_injection_tokens` that triggers a warning advisory |
411
+ | `context_budget.critical_threshold` | number | `0.9` | Ratio (0.0-1.0) of `max_injection_tokens` that triggers a critical alert with handoff recommendation |
412
+ | `context_budget.enforce` | boolean | `true` | When true, enforces budget limits and may trigger handoffs |
413
+ | `context_budget.prune_target` | number | `0.7` | Ratio (0.0-1.0) of context to preserve when pruning occurs |
414
+ | `context_budget.preserve_last_n_turns` | number | `4` | Number of recent turns to preserve when pruning |
415
+ | `context_budget.recent_window` | number | `10` | Number of turns to consider as "recent" for scoring |
416
+ | `context_budget.tracked_agents` | string[] | `['architect']` | Agents to track for context budget warnings |
417
+ | `context_budget.enforce_on_agent_switch` | boolean | `true` | Enforce budget limits when switching agents |
418
+ | `context_budget.model_limits` | record | `{ default: 128000 }` | Per-model token limits (model name -> max tokens) |
419
+ | `context_budget.tool_output_mask_threshold` | number | `2000` | Threshold for masking tool outputs (chars) |
420
+ | `context_budget.scoring.enabled` | boolean | `false` | Enable context scoring/ranking |
421
+ | `context_budget.scoring.max_candidates` | number | `100` | Maximum items to score (10-500) |
422
+ | `context_budget.scoring.weights` | object | `{ recency: 0.3, ... }` | Scoring weights for priority |
423
+ | `context_budget.scoring.decision_decay` | object | `{ mode: 'exponential', half_life_hours: 24 }` | Decision relevance decay |
424
+ | `context_budget.scoring.token_ratios` | object | `{ prose: 0.25, code: 0.4, ... }` | Token cost multipliers |
425
+
426
+ ### Example Configurations
427
+
428
+ **Minimal (disable):**
429
+ ```json
430
+ {
431
+ "context_budget": {
432
+ "enabled": false
433
+ }
434
+ }
435
+ ```
436
+
437
+ **Default (reference):**
438
+ ```json
439
+ {
440
+ "context_budget": {
441
+ "enabled": true,
442
+ "max_injection_tokens": 4000,
443
+ "warn_threshold": 0.7,
444
+ "critical_threshold": 0.9,
445
+ "enforce": true,
446
+ "prune_target": 0.7,
447
+ "preserve_last_n_turns": 4,
448
+ "recent_window": 10,
449
+ "tracked_agents": ["architect"],
450
+ "enforce_on_agent_switch": true,
451
+ "model_limits": { "default": 128000 },
452
+ "tool_output_mask_threshold": 2000,
453
+ "scoring": {
454
+ "enabled": false,
455
+ "max_candidates": 100,
456
+ "weights": { "recency": 0.3, "relevance": 0.4, "importance": 0.3 },
457
+ "decision_decay": { "mode": "exponential", "half_life_hours": 24 },
458
+ "token_ratios": { "prose": 0.25, "code": 0.4, "json": 0.6, "logs": 0.1 }
459
+ }
460
+ }
461
+ }
462
+ ```
463
+
464
+ **Aggressive (for long-running sessions):**
465
+ ```json
466
+ {
467
+ "context_budget": {
468
+ "enabled": true,
469
+ "max_injection_tokens": 2000,
470
+ "warn_threshold": 0.5,
471
+ "critical_threshold": 0.75,
472
+ "enforce": true,
473
+ "prune_target": 0.6,
474
+ "preserve_last_n_turns": 2,
475
+ "recent_window": 5,
476
+ "tracked_agents": ["architect"],
477
+ "enforce_on_agent_switch": true,
478
+ "model_limits": { "default": 128000 },
479
+ "tool_output_mask_threshold": 1500,
480
+ "scoring": {
481
+ "enabled": true,
482
+ "max_candidates": 50,
483
+ "weights": { "recency": 0.5, "relevance": 0.3, "importance": 0.2 },
484
+ "decision_decay": { "mode": "linear", "half_life_hours": 12 },
485
+ "token_ratios": { "prose": 0.2, "code": 0.35, "json": 0.5, "logs": 0.05 }
486
+ }
487
+ }
488
+ }
489
+ ```
490
+
491
+ ### What This Does NOT Do
492
+
493
+ - **Does NOT prune chat history** — Your conversation with the model is untouched
494
+ - **Does NOT modify tool outputs** — What tools return is unchanged
495
+ - **Does NOT block execution** — The guard is advisory only; it warns but never stops the pipeline
496
+ - **Does NOT interact with compaction.auto** — Separate feature with separate configuration
497
+ - **Only measures swarm's injected context** — Not the full context window, just what Swarm adds
498
+
499
+ </details>
500
+
388
501
  <details>
389
502
  <summary><strong>Quality Gates (Technical Detail)</strong></summary>
390
503