MCPcopy Create free account
hub / github.com/Noumena-Network/code / runInProcessTeammate

Function runInProcessTeammate

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

Source from the content-addressed store, hash-verified

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

Callers 1

startInProcessTeammateFunction · 0.85

Calls 15

isInternalBuildFunction · 0.85
formatAsTeammateMessageFunction · 0.85
tryClaimNextTaskFunction · 0.85
appendCappedMessageFunction · 0.85
createAbortControllerFunction · 0.85
tokenCountWithEstimationFunction · 0.85
getAutoCompactThresholdFunction · 0.85
cloneFileStateCacheFunction · 0.85
compactConversationFunction · 0.85
asSystemPromptFunction · 0.85
buildPostCompactMessagesFunction · 0.85

Tested by

no test coverage detected