pi-canary 1.1.1 → 1.1.2

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.
@@ -116,10 +116,19 @@ export default function (pi: ExtensionAPI) {
116
116
  verifyContextSent = true;
117
117
  const messages = [...event.messages];
118
118
 
119
- // Suppress the original user question so the agent focuses only on the canary check.
120
- // The question remains in session history and reappears in Phase 2.
119
+ // Replace the original user question with a neutral prompt so the agent focuses
120
+ // only on the canary check. We keep the user role (replacing content, not the
121
+ // message) because some providers (e.g. llama-server) use Jinja2 chat templates
122
+ // that require a user message at the end of the conversation — removing it causes
123
+ // template parsing to fail with "No user query found in messages." The original
124
+ // question remains in session history and reappears in Phase 2.
121
125
  if (messages.length > 0 && (messages[messages.length - 1] as any).role === "user") {
122
- messages.pop();
126
+ const lastMsg = messages[messages.length - 1] as any;
127
+ if (typeof lastMsg.content === "string") {
128
+ lastMsg.content = "Please return the canary tokens.";
129
+ } else if (Array.isArray(lastMsg.content) && lastMsg.content.length > 0) {
130
+ lastMsg.content = [{ type: "text", text: "Please return the canary tokens." }];
131
+ }
123
132
  }
124
133
 
125
134
  const histLen = messages.length;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-canary",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
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",