In pi-extension/index.js lines 185-188:
pi.on("before_agent_start", async (event) => {
if (!currentMode || currentMode === "off") return;
return { systemPrompt: `${event.systemPrompt}\n\n${getPonytailInstructions(currentMode)}` };
});
event.systemPrompt is accessed without a null/undefined guard. If the pi runtime calls this handler with a falsy event (null/undefined), it throws TypeError: Cannot read property 'systemPrompt' of null/undefined and crashes the agent.
Note: the input handler at line 159 uses event?.source (optional chaining) but before_agent_start uses bare event.systemPrompt — inconsistent.
In
pi-extension/index.jslines 185-188:event.systemPromptis accessed without a null/undefined guard. If the pi runtime calls this handler with a falsy event (null/undefined), it throwsTypeError: Cannot read property 'systemPrompt' of null/undefinedand crashes the agent.Note: the
inputhandler at line 159 usesevent?.source(optional chaining) butbefore_agent_startuses bareevent.systemPrompt— inconsistent.