Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/common/types/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export interface MuxMetadata {
// Readers should use helper: isCompacted = compacted !== undefined && compacted !== false
compacted?: "user" | "idle" | boolean;
toolPolicy?: ToolPolicy; // Tool policy active when this message was sent (user messages only)
mode?: string; // The mode (plan/exec/etc) active when this message was sent (assistant messages only)
mode?: string; // The mode active when this message was sent (assistant messages only) - plan/exec today, custom modes in future
cmuxMetadata?: MuxFrontendMetadata; // Frontend-defined metadata, backend treats as black-box
muxMetadata?: MuxFrontendMetadata; // Frontend-defined metadata, backend treats as black-box
}
Expand Down
6 changes: 5 additions & 1 deletion src/node/services/sessionTimingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -482,11 +482,15 @@ export class SessionTimingService {

const model = normalizeGatewayModel(data.model);

// Validate mode: stats schema only accepts "plan" | "exec" for now.
// Custom modes will need schema updates when supported.
const mode = data.mode === "plan" || data.mode === "exec" ? data.mode : undefined;

const state: ActiveStreamState = {
workspaceId: data.workspaceId,
messageId: data.messageId,
model,
mode: data.mode,
mode,
startTimeMs: data.startTime,
firstTokenTimeMs: null,
completedToolExecutionMs: 0,
Expand Down
9 changes: 7 additions & 2 deletions src/node/services/streamManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,9 @@ export class StreamManager extends EventEmitter {
streamInfo.state = StreamState.STREAMING;

// Emit stream start event (include mode from initialMetadata if available)
const streamStartMode = streamInfo.initialMetadata?.mode as "plan" | "exec" | undefined;
// Validate mode - stats schema only accepts "plan" | "exec" for now
const rawMode = streamInfo.initialMetadata?.mode;
const streamStartMode = rawMode === "plan" || rawMode === "exec" ? rawMode : undefined;
this.emit("stream-start", {
type: "stream-start",
workspaceId: workspaceId as string,
Expand Down Expand Up @@ -1776,7 +1778,10 @@ export class StreamManager extends EventEmitter {
await this.tokenTracker.setModel(streamInfo.model);

// Emit stream-start event (include mode from initialMetadata if available)
const replayMode = streamInfo.initialMetadata?.mode as "plan" | "exec" | undefined;
// Validate mode - stats schema only accepts "plan" | "exec" for now
const rawReplayMode = streamInfo.initialMetadata?.mode;
const replayMode =
rawReplayMode === "plan" || rawReplayMode === "exec" ? rawReplayMode : undefined;
this.emit("stream-start", {
type: "stream-start",
workspaceId,
Expand Down
Loading