pi-canary 1.0.3 → 1.1.1

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
@@ -51,7 +51,7 @@ Persistent configuration lives in `extensions/canary.json`. You can ask the agen
51
51
 
52
52
  | Key | Default | Description |
53
53
  |-----|---------|-------------|
54
- | `COUNT` | `3` | Number of canary tokens injected per turn |
54
+ | `COUNT` | `3` | Number of canary tokens injected per turn (`0` disables the canary check entirely) |
55
55
  | `POSITION` | `end` | Where tokens are injected: `start`, `equidistant`, or `end` |
56
56
  | `VARIANT` | `fixed` | `fixed` = same tokens every turn (preserves KV cache); `variant` = new tokens each turn |
57
57
  | `FAIL_COMPACT` | `0` | Compact context after N consecutive failures (`0` = disabled) |
@@ -92,6 +92,12 @@ export default function (pi: ExtensionAPI) {
92
92
  let verifyResponseTimestamp: number | null = null;
93
93
 
94
94
  pi.on("before_agent_start", (_event, _ctx) => {
95
+ // COUNT=0 disables the canary check entirely
96
+ if (cfg.COUNT === 0) {
97
+ phase = "idle";
98
+ currentTokens = null;
99
+ return;
100
+ }
95
101
  if (cfg.VARIANT === "fixed") {
96
102
  if (!fixedTokens || fixedTokens.length !== cfg.COUNT) {
97
103
  fixedTokens = Array.from({ length: cfg.COUNT }, generateToken);
@@ -273,7 +279,7 @@ export default function (pi: ExtensionAPI) {
273
279
  if (eq > 0 && val !== "") {
274
280
  if (key === "COUNT") {
275
281
  const n = parseInt(val, 10);
276
- if (n > 0) { cfg.COUNT = n; fixedTokens = null; results.push(`COUNT=${cfg.COUNT}`); }
282
+ if (n >= 0) { cfg.COUNT = n; fixedTokens = null; results.push(`COUNT=${cfg.COUNT}`); }
277
283
  else results.push(`invalid COUNT: ${val}`);
278
284
  } else if (key === "POSITION") {
279
285
  if (val === "start" || val === "equidistant" || val === "end") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-canary",
3
- "version": "1.0.3",
3
+ "version": "1.1.1",
4
4
  "description": "Pi extension: silently verifies agent context awareness every turn using hidden canary tokens. KV-cache friendly.",
5
5
  "keywords": ["pi-package", "pi", "pi-coding-agent", "extension", "context-awareness", "canary", "safety", "verification", "local-llm"],
6
6
  "license": "MIT",
@@ -21,7 +21,7 @@ injected into the conversation history. Passed = proceed; failed = warning.
21
21
 
22
22
  | Key | Default | Valid values | What it controls |
23
23
  |-----|---------|-------------|-----------------|
24
- | `COUNT` | `3` | integer > 0 | Number of canary tokens per turn |
24
+ | `COUNT` | `3` | integer 0 | Number of canary tokens per turn (`0` disables the canary check entirely) |
25
25
  | `POSITION` | `end` | `start` \| `equidistant` \| `end` | Where tokens are injected in context |
26
26
  | `VARIANT` | `fixed` | `fixed` \| `variant` | Fixed reuses same tokens (KV-cache friendly); variant regenerates each turn |
27
27
  | `FAIL_COMPACT` | `0` | integer ≥ 0 | Trigger compaction after N consecutive failures (0 = disabled) |