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