MCPcopy Index your code
hub / github.com/codeaashu/claude-code / runInProcessTeammate

Function runInProcessTeammate

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

Source from the content-addressed store, hash-verified

881 * @returns Result with messages and success status
882 */
883export async function runInProcessTeammate(
884 config: InProcessRunnerConfig,
885): Promise<InProcessRunnerResult> {
886 const {
887 identity,
888 taskId,
889 prompt,
890 description,
891 agentDefinition,
892 teammateContext,
893 toolUseContext,
894 abortController,
895 model,
896 systemPrompt,
897 systemPromptMode,
898 allowedTools,
899 allowPermissionPrompts,
900 invokingRequestId,
901 } = config
902 const { setAppState } = toolUseContext
903
904 logForDebugging(
905 `[inProcessRunner] Starting agent loop for ${identity.agentId}`,
906 )
907
908 // Create AgentContext for analytics attribution
909 const agentContext: AgentContext = {
910 agentId: identity.agentId,
911 parentSessionId: identity.parentSessionId,
912 agentName: identity.agentName,
913 teamName: identity.teamName,
914 agentColor: identity.color,
915 planModeRequired: identity.planModeRequired,
916 isTeamLead: false,
917 agentType: 'teammate',
918 invokingRequestId,
919 invocationKind: 'spawn',
920 invocationEmitted: false,
921 }
922
923 // Build system prompt based on systemPromptMode
924 let teammateSystemPrompt: string
925 if (systemPromptMode === 'replace' && systemPrompt) {
926 teammateSystemPrompt = systemPrompt
927 } else {
928 const fullSystemPromptParts = await getSystemPrompt(
929 toolUseContext.options.tools,
930 toolUseContext.options.mainLoopModel,
931 undefined,
932 toolUseContext.options.mcpClients,
933 )
934
935 const systemPromptParts = [
936 ...fullSystemPromptParts,
937 TEAMMATE_SYSTEM_PROMPT_ADDENDUM,
938 ]
939
940 // If custom agent definition provided, append its prompt

Callers 1

startInProcessTeammateFunction · 0.85

Calls 15

logForDebuggingFunction · 0.85
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

Tested by

no test coverage detected