MCPcopy Create free account
hub / github.com/Noumena-Network/code / logSpeculation

Function logSpeculation

src/services/PromptSuggestion/speculation.ts:125–154  ·  view source on GitHub ↗
(
  id: string,
  outcome: 'accepted' | 'aborted' | 'error',
  startTime: number,
  suggestionLength: number,
  messages: Message[],
  boundary: CompletionBoundary | null,
  extras?: Record<string, string | number | boolean | undefined>,
)

Source from the content-addressed store, hash-verified

123>
124
125function logSpeculation(
126 id: string,
127 outcome: 'accepted' | 'aborted' | 'error',
128 startTime: number,
129 suggestionLength: number,
130 messages: Message[],
131 boundary: CompletionBoundary | null,
132 extras?: Record<string, string | number | boolean | undefined>,
133): void {
134 logEvent('ncode_speculation', {
135 speculation_id:
136 id as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
137 outcome:
138 outcome as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
139 duration_ms: Date.now() - startTime,
140 suggestion_length: suggestionLength,
141 tools_executed: countToolsInMessages(messages),
142 completed: boundary !== null,
143 boundary_type: boundary?.type as
144 | AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS
145 | undefined,
146 boundary_tool: getBoundaryTool(boundary) as
147 | AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS
148 | undefined,
149 boundary_detail: getBoundaryDetail(boundary) as
150 | AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS
151 | undefined,
152 ...extras,
153 })
154}
155
156function countToolsInMessages(messages: Message[]): number {
157 const blocks = messages

Callers 4

startSpeculationFunction · 0.85
acceptSpeculationFunction · 0.85
abortSpeculationFunction · 0.85
handleSpeculationAcceptFunction · 0.85

Calls 4

countToolsInMessagesFunction · 0.85
getBoundaryToolFunction · 0.85
getBoundaryDetailFunction · 0.85
logEventFunction · 0.50

Tested by

no test coverage detected