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

Function startAgentRun

sdk/src/impl/database.ts:302–346  ·  view source on GitHub ↗
(
  params: ParamsOf<StartAgentRunFn>,
)

Source from the content-addressed store, hash-verified

300}
301
302export async function startAgentRun(
303 params: ParamsOf<StartAgentRunFn>,
304): ReturnType<StartAgentRunFn> {
305 const { apiKey, agentId, ancestorRunIds, logger } = params
306
307 const url = new URL(`/api/v1/agent-runs`, WEBSITE_URL)
308
309 try {
310 const response = await fetchWithRetry(
311 url,
312 {
313 method: 'POST',
314 headers: {
315 Authorization: `Bearer ${apiKey}`,
316 },
317 body: JSON.stringify({
318 action: 'START',
319 agentId,
320 ancestorRunIds,
321 }),
322 },
323 logger,
324 )
325
326 if (!response.ok) {
327 logger.error({ response }, 'startAgentRun request failed')
328 return null
329 }
330
331 const responseBody = await response.json()
332 if (!responseBody?.runId) {
333 logger.error(
334 { responseBody },
335 'no runId found from startAgentRun request',
336 )
337 }
338 return responseBody?.runId ?? null
339 } catch (error) {
340 logger.error(
341 { error: getErrorObject(error), agentId },
342 'startAgentRun error',
343 )
344 return null
345 }
346}
347
348export async function finishAgentRun(
349 params: ParamsOf<FinishAgentRunFn>,

Callers 1

loopAgentStepsFunction · 0.85

Calls 2

getErrorObjectFunction · 0.90
fetchWithRetryFunction · 0.85

Tested by

no test coverage detected