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

Function finishAgentRun

sdk/src/impl/database.ts:348–393  ·  view source on GitHub ↗
(
  params: ParamsOf<FinishAgentRunFn>,
)

Source from the content-addressed store, hash-verified

346}
347
348export async function finishAgentRun(
349 params: ParamsOf<FinishAgentRunFn>,
350): ReturnType<FinishAgentRunFn> {
351 const {
352 apiKey,
353 runId,
354 status,
355 totalSteps,
356 directCredits,
357 totalCredits,
358 logger,
359 } = params
360
361 const url = new URL(`/api/v1/agent-runs`, WEBSITE_URL)
362
363 try {
364 const response = await fetchWithRetry(
365 url,
366 {
367 method: 'POST',
368 headers: {
369 Authorization: `Bearer ${apiKey}`,
370 },
371 body: JSON.stringify({
372 action: 'FINISH',
373 runId,
374 status,
375 totalSteps,
376 directCredits,
377 totalCredits,
378 }),
379 },
380 logger,
381 )
382
383 if (!response.ok) {
384 logger.error({ response }, 'finishAgentRun request failed')
385 return
386 }
387 } catch (error) {
388 logger.error(
389 { error: getErrorObject(error), runId, status },
390 'finishAgentRun error',
391 )
392 }
393}
394
395export async function addAgentStep(
396 params: ParamsOf<AddAgentStepFn>,

Callers 1

loopAgentStepsFunction · 0.85

Calls 2

getErrorObjectFunction · 0.90
fetchWithRetryFunction · 0.85

Tested by

no test coverage detected