MCPcopy
hub / github.com/claude-code-best/claude-code / runInProcessTeammate

Function runInProcessTeammate

src/utils/swarm/inProcessRunner.ts:902–1632  ·  view source on GitHub ↗
(
  config: InProcessRunnerConfig,
)

Source from the content-addressed store, hash-verified

900 * @returns Result with messages and success status
901 */
902export async function runInProcessTeammate(
903 config: InProcessRunnerConfig,
904): Promise<InProcessRunnerResult> {
905 const {
906 identity,
907 taskId,
908 prompt,
909 description,
910 agentDefinition,
911 teammateContext,
912 toolUseContext,
913 abortController,
914 model,
915 systemPrompt,
916 systemPromptMode,
917 allowedTools,
918 allowPermissionPrompts,
919 invokingRequestId,
920 } = config
921 const { setAppState } = toolUseContext
922 const startTime = Date.now()
923
924 logForDebugging(
925 `[inProcessRunner] Starting agent loop for ${identity.agentId}`,
926 )
927
928 // Create AgentContext for analytics attribution
929 const agentContext: AgentContext = {
930 agentId: identity.agentId,
931 parentSessionId: identity.parentSessionId,
932 agentName: identity.agentName,
933 teamName: identity.teamName,
934 agentColor: identity.color,
935 planModeRequired: identity.planModeRequired,
936 isTeamLead: false,
937 agentType: 'teammate',
938 invokingRequestId,
939 invocationKind: 'spawn',
940 invocationEmitted: false,
941 }
942
943 // Build system prompt based on systemPromptMode
944 let teammateSystemPrompt: string
945 if (systemPromptMode === 'replace' && systemPrompt) {
946 teammateSystemPrompt = systemPrompt
947 } else {
948 const fullSystemPromptParts = await getSystemPrompt(
949 toolUseContext.options.tools,
950 toolUseContext.options.mainLoopModel,
951 undefined,
952 toolUseContext.options.mcpClients,
953 )
954
955 const systemPromptParts = [
956 ...fullSystemPromptParts,
957 TEAMMATE_SYSTEM_PROMPT_ADDENDUM,
958 ]
959

Callers 1

startInProcessTeammateFunction · 0.85

Calls 15

logEventFunction · 0.85
formatAsTeammateMessageFunction · 0.85
tryClaimNextTaskFunction · 0.85
appendCappedMessageFunction · 0.85
createUserMessageFunction · 0.85
createAbortControllerFunction · 0.85
tokenCountWithEstimationFunction · 0.85
getAutoCompactThresholdFunction · 0.85
cloneFileStateCacheFunction · 0.85
compactConversationFunction · 0.85
asSystemPromptFunction · 0.85

Tested by

no test coverage detected