MCPcopy
hub / github.com/CodebuffAI/codebuff / loopAgentSteps

Function loopAgentSteps

packages/agent-runtime/src/run-agent-step.ts:559–1170  ·  view source on GitHub ↗
(
  params: {
    addAgentStep: AddAgentStepFn
    agentState: AgentState
    agentType: string
    clearUserPromptMessagesAfterResponse?: boolean
    clientSessionId: string
    content?: Array<TextPart | ImagePart>
    costMode?: string
    fileContext: ProjectFileContext
    finishAgentRun: FinishAgentRunFn
    localAgentTemplates: Record<string, AgentTemplate>
    logger: Logger
    parentSystemPrompt?: string
    parentTools?: ToolSet
    prompt: string | undefined
    signal: AbortSignal
    spawnParams: Record<string, any> | undefined
    startAgentRun: StartAgentRunFn
    userId: string | undefined
    userInputId: string
    agentTemplate?: AgentTemplate
  } & ParamsExcluding<typeof additionalToolDefinitions, 'agentTemplate'> &
    ParamsExcluding<
      typeof runProgrammaticStep,
      | 'agentState'
      | 'onCostCalculated'
      | 'prompt'
      | 'runId'
      | 'stepNumber'
      | 'stepsComplete'
      | 'system'
      | 'template'
      | 'toolCallParams'
      | 'tools'
    > &
    ParamsExcluding<typeof getAgentTemplate, 'agentId'> &
    ParamsExcluding<
      typeof getAgentPrompt,
      | 'agentTemplate'
      | 'promptType'
      | 'agentTemplates'
      | 'additionalToolDefinitions'
    > &
    ParamsExcluding<
      typeof getMCPToolData,
      'toolNames' | 'mcpServers' | 'writeTo'
    > &
    ParamsExcluding<StartAgentRunFn, 'agentId' | 'ancestorRunIds'> &
    ParamsExcluding<
      FinishAgentRunFn,
      'runId' | 'status' | 'totalSteps' | 'directCredits' | 'totalCredits'
    > &
    ParamsExcluding<
      typeof runAgentStep,
      | 'additionalToolDefinitions'
      | 'agentState'
      | 'agentTemplate'
      | 'prompt'
      | 'runId'
      | 'spawnParams'
      | 'system'
      | 'tools'
    > &
    ParamsExcluding<
      AddAgentStepFn,
      | 'agentRunId'
      | 'stepNumber'
      | 'credits'
      | 'childRunIds'
      | 'messageId'
      | 'status'
      | 'startTime'
    >,
)

Source from the content-addressed store, hash-verified

557 * skipped.
558 */
559export async function loopAgentSteps(
560 params: {
561 addAgentStep: AddAgentStepFn
562 agentState: AgentState
563 agentType: string
564 clearUserPromptMessagesAfterResponse?: boolean
565 clientSessionId: string
566 content?: Array<TextPart | ImagePart>
567 costMode?: string
568 fileContext: ProjectFileContext
569 finishAgentRun: FinishAgentRunFn
570 localAgentTemplates: Record<string, AgentTemplate>
571 logger: Logger
572 parentSystemPrompt?: string
573 parentTools?: ToolSet
574 prompt: string | undefined
575 signal: AbortSignal
576 spawnParams: Record<string, any> | undefined
577 startAgentRun: StartAgentRunFn
578 userId: string | undefined
579 userInputId: string
580 agentTemplate?: AgentTemplate
581 } & ParamsExcluding<typeof additionalToolDefinitions, 'agentTemplate'> &
582 ParamsExcluding<
583 typeof runProgrammaticStep,
584 | 'agentState'
585 | 'onCostCalculated'
586 | 'prompt'
587 | 'runId'
588 | 'stepNumber'
589 | 'stepsComplete'
590 | 'system'
591 | 'template'
592 | 'toolCallParams'
593 | 'tools'
594 > &
595 ParamsExcluding<typeof getAgentTemplate, 'agentId'> &
596 ParamsExcluding<
597 typeof getAgentPrompt,
598 | 'agentTemplate'
599 | 'promptType'
600 | 'agentTemplates'
601 | 'additionalToolDefinitions'
602 > &
603 ParamsExcluding<
604 typeof getMCPToolData,
605 'toolNames' | 'mcpServers' | 'writeTo'
606 > &
607 ParamsExcluding<StartAgentRunFn, 'agentId' | 'ancestorRunIds'> &
608 ParamsExcluding<
609 FinishAgentRunFn,
610 'runId' | 'status' | 'totalSteps' | 'directCredits' | 'totalCredits'
611 > &
612 ParamsExcluding<
613 typeof runAgentStep,
614 | 'additionalToolDefinitions'
615 | 'agentState'
616 | 'agentTemplate'

Callers 4

mainPromptFunction · 0.90
executeSubagentFunction · 0.90

Calls 15

getAgentTemplateFunction · 0.90
getAgentPromptFunction · 0.90
buildAgentToolSetFunction · 0.90
getToolSetFunction · 0.90
buildArrayFunction · 0.90
buildUserMessageContentFunction · 0.90
userMessageFunction · 0.90
callTokenCountAPIFunction · 0.90
countTokensJsonFunction · 0.90
runProgrammaticStepFunction · 0.90

Tested by

no test coverage detected