fix(session): measure tps from the first streamed token (#63321)

This commit is contained in:
Dax
2026-11-11 10:32:49 -05:00
committed by GitHub
Unverified
parent 2ef38b2172
commit 99f2bea6df
17 changed files with 150 additions and 18 deletions
+12
View File
@@ -346,6 +346,17 @@ export namespace Step {
})
export type Started = typeof Started.Type
/** Records when the provider streamed the first output token, before the rest of the response. */
export const FirstToken = Event.durable({
type: "session.step.first-token",
...options,
schema: {
...Base,
assistantMessageID: SessionMessage.ID,
},
})
export type FirstToken = typeof FirstToken.Type
/** Records the provider response-body boundary independently of tool settlement. */
export const Streamed = Event.durable({
type: "session.step.streamed",
@@ -679,6 +690,7 @@ export const Definitions = Event.inventory(
Shell.Started,
Shell.Ended,
Step.Started,
Step.FirstToken,
Step.Streamed,
Step.Ended,
Step.Failed,
+2
View File
@@ -239,6 +239,8 @@ export const Assistant = Schema.Struct({
retry: AssistantRetry.pipe(optional),
time: Schema.Struct({
created: DateTimeUtcFromMillis,
/** When the provider streamed the first output token, before the rest of the response. */
firstToken: DateTimeUtcFromMillis.pipe(optional),
/** When the provider response body ended, before tool settlement. */
streamed: DateTimeUtcFromMillis.pipe(optional),
completed: DateTimeUtcFromMillis.pipe(optional),
@@ -134,6 +134,7 @@ describe("public event manifest", () => {
"session.shell.started.1",
"session.shell.ended.1",
"session.step.started.1",
"session.step.first-token.1",
"session.step.streamed.1",
"session.step.ended.1",
"session.step.failed.1",