From 1adc05aa6a4a7e17984a4f9c71fc2987de31cbdf Mon Sep 17 00:00:00 2001 From: MoerAI Date: Mon, 16 Mar 2026 14:59:01 +0900 Subject: [PATCH] fix(agents): mark sensitive-stop payload as error with isError flag Add isError: true to the sensitive stop_reason payload so downstream consumers (e.g. cron delivery) correctly treat it as an error. Add 'sensitive' to the error kind union type. --- src/agents/pi-embedded-runner/run.ts | 1 + src/agents/pi-embedded-runner/types.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/agents/pi-embedded-runner/run.ts b/src/agents/pi-embedded-runner/run.ts index df2a7388c6e..2d18955d184 100644 --- a/src/agents/pi-embedded-runner/run.ts +++ b/src/agents/pi-embedded-runner/run.ts @@ -1320,6 +1320,7 @@ export async function runEmbeddedPiAgent( text: "I can't respond to that - the content was flagged by the model's safety filter. " + "Please rephrase or try a different topic.", + isError: true, }, ], meta: { diff --git a/src/agents/pi-embedded-runner/types.ts b/src/agents/pi-embedded-runner/types.ts index 722abbf2a9a..ac98141f0dc 100644 --- a/src/agents/pi-embedded-runner/types.ts +++ b/src/agents/pi-embedded-runner/types.ts @@ -41,7 +41,8 @@ export type EmbeddedPiRunMeta = { | "compaction_failure" | "role_ordering" | "image_size" - | "retry_limit"; + | "retry_limit" + | "sensitive"; message: string; }; /** Stop reason for the agent run (e.g., "completed", "tool_calls"). */