Skip to content

pi-extension: before_agent_start crashes if event is null/undefined #439

Description

@nanaubusiness

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions