mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-20 18:57:17 +03:00
fix(session): measure tps from the first streamed token (#63321)
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user