Skip to content

Replace MessageStart/MessageEnd with ToolCallResult and HookEvent#62

Merged
msullivan merged 1 commit into
mainfrom
no-message-start
May 1, 2026
Merged

Replace MessageStart/MessageEnd with ToolCallResult and HookEvent#62
msullivan merged 1 commit into
mainfrom
no-message-start

Conversation

@msullivan

Copy link
Copy Markdown
Contributor

MessageStart and MessageEnd were always emitted back-to-back after the
models rework, and MessageStart didn't carry any useful information
anymore. A bunch of downstream examples were broken. (Some are still a
bit broken after this; I have some more pending tool streaming
changes.)

Instead, we'll add two special-purpose event types:

  • ToolCallResult: emitted after tool execution with the result message
  • HookEvent: emitted when a hook suspends/resolves/cancels

(Previously those were signaled with synthetic MessageStart/MessageEnd
pairs.)

We also add a
TerminalEvent = types.StreamEnd | ToolCallResult | HookEvent
that represents all of the AgentEvents that are "terminal".

I also wanted to make message nonoptional in all the events (since
from a user perspective, it should be!), so I've made the default be
a _DUMMY_MESSAGE. This is an annoying hack but improves the user
facing interface a fair amount, if they are using typing.

@msullivan msullivan requested a review from anbuzin April 30, 2026 20:46
@vercel

vercel Bot commented Apr 30, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
py-ai Ready Ready Preview, Comment Apr 30, 2026 10:59pm

Request Review

proxy: {
'/api': {
target: 'http://localhost:8000',
rewrite: (path) => path.replace(/^\/api/, ''),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't actually do that, the move is to use vercel dev and let it handle the routing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do this, though, it will work either way?

MessageStart and MessageEnd were always emitted back-to-back after the
models rework, and MessageStart didn't carry any useful information
anymore. A bunch of downstream examples were broken. (Some are still a
bit broken after this; I have some more pending tool streaming
changes.)

Instead, we'll add two special-purpose event types:
- ToolCallResult: emitted after tool execution with the result message
- HookEvent: emitted when a hook suspends/resolves/cancels

(Previously those were signaled with synthetic MessageStart/MessageEnd
pairs.)

We also add a
`TerminalEvent = types.StreamEnd | ToolCallResult | HookEvent`
that represents all of the AgentEvents that are "terminal".

I also wanted to make `message` nonoptional in all the events (since
from a *user* perspective, it should be!), so I've made the default be
a `_DUMMY_MESSAGE`. This is an annoying hack but improves the user
facing interface a fair amount, if they are using typing.
@msullivan msullivan merged commit a2fa880 into main May 1, 2026
6 checks passed
@msullivan msullivan deleted the no-message-start branch May 1, 2026 01:09
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.

2 participants