( config: InProcessRunnerConfig, )
| 900 | * @returns Result with messages and success status |
| 901 | */ |
| 902 | export 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 |
no test coverage detected