Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(sdk): add AgentErrorEvent to StreamPayload type

Naiyuan Qing1819f4196d22
diff --git a/packages/sdk/src/actions/index.ts b/packages/sdk/src/actions/index.ts
index c378a6d663..b3ef94e331 100644
--- a/packages/sdk/src/actions/index.ts
+++ b/packages/sdk/src/actions/index.ts
@@ -38,6 +38,7 @@ export {
type CompactionEvent,
type CompactionStartEvent,
type CompactionEndEvent,
+ type AgentErrorEvent,
type ContentBlock,
type TextContent,
type ThinkingContent,
diff --git a/packages/sdk/src/actions/stream.ts b/packages/sdk/src/actions/stream.ts
index c0249353df..19aa9482eb 100644
--- a/packages/sdk/src/actions/stream.ts
+++ b/packages/sdk/src/actions/stream.ts
@@ -45,16 +45,22 @@ export type CompactionEndEvent = {
/** Union of all compaction events */
export type CompactionEvent = CompactionStartEvent | CompactionEndEvent;
+/** Emitted when the agent encounters an error (LLM failure, quota exceeded, etc.) */
+export type AgentErrorEvent = {
+ type: "agent_error";
+ error: string;
+};
+
// --- Stream event types ---
/**
- * Hub forwards AgentEvent from pi-agent-core and CompactionEvent as-is.
- * StreamPayload wraps them with routing metadata.
+ * Hub forwards AgentEvent from pi-agent-core, CompactionEvent,
+ * and AgentErrorEvent as-is. StreamPayload wraps them with routing metadata.
*/
export interface StreamPayload {
streamId: string;
agentId: string;
- event: AgentEvent | CompactionEvent;
+ event: AgentEvent | CompactionEvent | AgentErrorEvent;
}
/** Extract thinking/reasoning content from an AgentEvent that carries a message */