MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / buildTrace

Function buildTrace

scripts/export-deepseek-session-traces.ts:404–439  ·  view source on GitHub ↗
(
  candidate: CandidateRow,
  representativeRows: Map<string, SessionRow>,
)

Source from the content-addressed store, hash-verified

402}
403
404function buildTrace(
405 candidate: CandidateRow,
406 representativeRows: Map<string, SessionRow>,
407) {
408 const representativeRow = representativeRows.get(
409 candidate.representative_message_id,
410 )
411
412 if (!representativeRow) {
413 throw new Error(
414 `No representative row found for ${candidate.client_id}: ${candidate.representative_message_id}`,
415 )
416 }
417
418 const request = getRequest(representativeRow)
419 const messages = buildFinalMessages(representativeRow)
420
421 return {
422 client_id: candidate.client_id,
423 model: candidate.model,
424 summary: {
425 provider_call_count: Number(candidate.provider_call_count),
426 first_finished_at: toIso(candidate.first_finished_at),
427 last_finished_at: toIso(candidate.last_finished_at),
428 representative_message_id: representativeRow.id,
429 representative_run_id: representativeRow.run_id,
430 representative_finished_at: toIso(representativeRow.finished_at),
431 representative_message_count: representativeRow.message_count,
432 final_message_count: messages.length,
433 tool_count: getTools(request).length,
434 appended_final_response: !!representativeRow.response?.trim(),
435 },
436 tools: getTools(request),
437 messages,
438 }
439}
440
441type SessionTrace = ReturnType<typeof buildTrace>
442

Callers 1

mainFunction · 0.85

Calls 5

getRequestFunction · 0.85
buildFinalMessagesFunction · 0.85
getToolsFunction · 0.85
toIsoFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected