You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
packages/core/src/webAgent.ts has several this.emit(...) call sites that do not supply the timestamp and iterationId fields the typed interfaces (and the generated JSON schema) declare as required on the base WebAgentEventData. Surfaced by Copilot on #489 at `webAgent.ts:1907` — TASK_COMPLETED — but applies more broadly.
Current state
The WebAgentEventEmitter (packages/core/src/events.ts:502-551) is a pass-through; it does NOT inject timestamp or iterationId middleware-style.
The private wrapper WebAgent.emit(type, data: any) at webAgent.ts:1993-1995 is also a pass-through and uses data: any, which masks the type mismatch from TypeScript.
Some emit sites supply iterationId (e.g., AGENT_STEP at webAgent.ts:538-541, TASK_VALIDATED at webAgent.ts:1397-1403); none I sampled supply timestamp. The TASK_COMPLETED emit at webAgent.ts:1901-1907 supplies neither.
Loggers (chalkConsole.ts, json.ts) consume TaskCompleteEventData and similar typed payloads — when consumers read data.timestamp or data.iterationId, they get undefined despite the type asserting otherwise.
The generated schema (packages/core/schemas/webagent-event.json) marks both fields as required on TaskCompleteEventData etc., so SSE/stream consumers (tabs-api, eval-judge, generated SDKs) may also be miscalibrated.
Wire-API surface mismatch: subscribers reading the typed shape will silently observe `undefined` where the schema promises a value. Downstream tooling that generates types from the schema (tabs-api, Stainless SDKs) will model the field as required-but-missing.
The misalignment is invisible at compile time because of `emit(type, data: any)`.
Suggested fixes (not part of this issue's contract)
A few options worth considering, none picked here:
Middleware in the emitter to auto-inject timestamp and iterationId from WebAgent instance state at emit time. Centralizes the fix; one change covers all emit sites.
Tighten emit() typing so data must satisfy the declared event-type's payload shape (drop `any`). Forces every existing emit site to supply the fields explicitly; surfaces every site that's currently noncompliant at build time.
Audit and fix per emit site without changing the wrapper. Mechanical, scoped, doesn't change the typing contract.
Scope
Out of scope for #489 (which deliberately only adds the optional validationOutcome field to TaskCompleteEventData). Filing as a separate follow-up so the trail is preserved.
Summary
packages/core/src/webAgent.tshas severalthis.emit(...)call sites that do not supply thetimestampanditerationIdfields the typed interfaces (and the generated JSON schema) declare as required on the baseWebAgentEventData. Surfaced by Copilot on #489 at `webAgent.ts:1907` — TASK_COMPLETED — but applies more broadly.Current state
WebAgentEventEmitter(packages/core/src/events.ts:502-551) is a pass-through; it does NOT injecttimestamporiterationIdmiddleware-style.WebAgent.emit(type, data: any)atwebAgent.ts:1993-1995is also a pass-through and usesdata: any, which masks the type mismatch from TypeScript.iterationId(e.g.,AGENT_STEPatwebAgent.ts:538-541,TASK_VALIDATEDatwebAgent.ts:1397-1403); none I sampled supplytimestamp. TheTASK_COMPLETEDemit atwebAgent.ts:1901-1907supplies neither.chalkConsole.ts,json.ts) consumeTaskCompleteEventDataand similar typed payloads — when consumers readdata.timestampordata.iterationId, they getundefineddespite the type asserting otherwise.packages/core/schemas/webagent-event.json) marks both fields asrequiredonTaskCompleteEventDataetc., so SSE/stream consumers (tabs-api, eval-judge, generated SDKs) may also be miscalibrated.git blameshows the TASK_COMPLETED emit lacks those fields since commit23011910(Nick Chapman, 2025-08-11). It was not introduced by feat(core): wire validator history and surface validationOutcome (#429) #463 (PR1) or feat(core): surface validationOutcome on TASK_COMPLETED event (#429) #489 (PR2).Why this matters
Suggested fixes (not part of this issue's contract)
A few options worth considering, none picked here:
timestampanditerationIdfromWebAgentinstance state at emit time. Centralizes the fix; one change covers all emit sites.emit()typing sodatamust satisfy the declared event-type's payload shape (drop `any`). Forces every existing emit site to supply the fields explicitly; surfaces every site that's currently noncompliant at build time.Scope
Out of scope for #489 (which deliberately only adds the optional
validationOutcomefield toTaskCompleteEventData). Filing as a separate follow-up so the trail is preserved.