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

Function extractAgentLessons

evals/buffbench/lessons-extractor.ts:92–187  ·  view source on GitHub ↗
(
  input: ExtractAgentLessonsInput,
)

Source from the content-addressed store, hash-verified

90}
91
92export async function extractAgentLessons(
93 input: ExtractAgentLessonsInput,
94): Promise<{
95 lessons: Lesson[]
96}> {
97 try {
98 const {
99 client,
100 localAgentDefinitions,
101 prompt,
102 groundTruthFileDiffs,
103 contextFiles,
104 agentDiff,
105 agentTrace,
106 judgeResult,
107 error,
108 } = input
109
110 const groundTruthDiffs = groundTruthFileDiffs
111 .map(({ path, diff }) => `### ${path}\n\`\`\`diff\n${diff}\n\`\`\``)
112 .join('\n\n')
113
114 const contextFilesContent = Object.entries(contextFiles)
115 .map(
116 ([filePath, content]) => `### ${filePath}\n\`\`\`\n${content}\n\`\`\``,
117 )
118 .join('\n\n')
119
120 const truncated = truncateTrace(agentTrace)
121 const truncatedTraceJson = JSON.stringify(truncated, null, 2)
122
123 const judgeSummary = judgeResult
124 ? `Overall: ${judgeResult.overallScore}/10, Completion: ${judgeResult.completionScore}/10, Code Quality: ${judgeResult.codeQualityScore}/10
125Weaknesses: ${judgeResult.weaknesses?.join(' | ') || '(none)'}`
126 : '(no judge summary)'
127
128 const lessonsPrompt = `## User Prompt
129${prompt}
130
131## Context Files (from parent commit)
132${contextFilesContent || '(No context files)'}
133
134## Ground Truth Changes (One valid implementation)
135${groundTruthDiffs || '(No ground truth diffs)'}
136
137## Agent's Changes
138\`\`\`diff
139${agentDiff || '(No changes made)'}
140\`\`\`
141
142## Agent Trace (truncated)
143\`\`\`json
144${truncatedTraceJson}
145\`\`\`
146
147## Judge Summary
148${judgeSummary}
149${error ? `\n## Agent Error\n${error}\n` : ''}

Callers 1

runTaskFunction · 0.90

Calls 4

truncateTraceFunction · 0.90
withTimeoutFunction · 0.90
getErrorObjectFunction · 0.90
runMethod · 0.45

Tested by

no test coverage detected