SIGN IN SIGN UP

fix: guard pi before_agent_start against bad event and missing systemPrompt (#482)

The before_agent_start handler read event.systemPrompt with no guard. A
null/undefined event crashed the agent with a TypeError (#439), and a truthy
event without a systemPrompt key stringified to the literal 'undefined',
prepending garbage to every system prompt (#440). Both are fixed with one
optional-chain guard that mirrors the event?. pattern the input handler already
uses: prepend the base prompt only when present, otherwise inject the ruleset
alone. Adds a regression test covering null/undefined event, missing
systemPrompt, and the normal base-prompt path.

Closes #439
Closes #440

Co-authored-by: Aroool <90670606+Aroool@users.noreply.github.com>
D
DietrichGebert committed
39bad58d40a293b2b40f4d2b1bce2f3fdea1ca26
Parent: 40e50d9
Committed by GitHub <noreply@github.com> on 7/6/2026, 11:23:31 PM