Skip to content

feat(chat): require events$ on Agent contract with structured AgentEvent union#138

Merged
blove merged 4 commits into
mainfrom
feat/agent-events-contract
Apr 25, 2026
Merged

feat(chat): require events$ on Agent contract with structured AgentEvent union#138
blove merged 4 commits into
mainfrom
feat/agent-events-contract

Conversation

@blove
Copy link
Copy Markdown
Contributor

@blove blove commented Apr 25, 2026

Summary

  • Replaces optional customEvents$: Observable<AgentCustomEvent> (free-form) with required events$: Observable<AgentEvent> (structured discriminated union).
  • AgentEvent = AgentStateUpdateEvent | AgentCustomEvent. state_update is a structured variant with data: Record<string, unknown>; custom is the escape hatch carrying { name, data: unknown }.
  • LangGraph adapter translates CustomStreamEventAgentEvent, discriminating state_update when data is a Record.
  • Codifies invariant in JSDoc: state on signals, events on events$, no duplication.

Motivation

The previous customEvents$ was optional and free-form, forcing every consumer to null-check and trust untyped payloads. Making it required + structured eliminates both frictions and gives a clear addition path for future well-known event types.

Test Plan

  • nx run-many -t lint,test,build -p chat,langgraph passes
  • nx affected -t build passes
  • No residual customEvents\$ on Agent contract; cockpit unaffected (no consumers outside chat.component.ts)

Design + plan

  • Spec: docs/superpowers/specs/2026-04-25-events-on-agent-contract-design.md
  • Plan: docs/superpowers/plans/2026-04-25-events-on-agent-contract.md

🤖 Generated with Claude Code

blove and others added 4 commits April 24, 2026 22:36
Replace optional customEvents$ with required events$ carrying a
discriminated union (AgentStateUpdateEvent | AgentCustomEvent).
Codify invariant: state on signals, events on events$, no duplication.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
3 tasks: rewrite agent-event types + chat-side rewiring (single
commit due to intermediate breakage), langgraph adapter translation,
final verify + PR.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ent union

Replaces optional customEvents$: Observable<AgentCustomEvent> with
required events$: Observable<AgentEvent>. AgentEvent discriminates
state_update from generic custom events. Codifies invariant: state on
signals, events on events$, no duplication.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
toAgent(ref) now emits events$: Observable<AgentEvent>. Translates
state_update events into AgentStateUpdateEvent (with data: Record),
all others into the structured AgentCustomEvent escape hatch.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cacheplane Ready Ready Preview, Comment Apr 25, 2026 3:43pm
cacheplane-minting-service Ready Ready Preview, Comment Apr 25, 2026 3:43pm

Request Review

@blove blove merged commit c18cefc into main Apr 25, 2026
15 checks passed
@blove blove deleted the feat/agent-events-contract branch May 7, 2026 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant