(
sessionId: string,
input: ChildAgentTurnInput,
execution: PendingExecutionClaim,
)
| 1142 | } |
| 1143 | |
| 1144 | private async *startChildTurnClaimed( |
| 1145 | sessionId: string, |
| 1146 | input: ChildAgentTurnInput, |
| 1147 | execution: PendingExecutionClaim, |
| 1148 | ): AsyncIterable<SessionEvent> { |
| 1149 | await this.enterExecutionClaim(execution); |
| 1150 | const parentHeader = await this.deps.store.readHeader(sessionId); |
| 1151 | const definition = requireBuiltinAgentDefinition(input.spec.id); |
| 1152 | const availableChildTools = this.deps.childTools ?? []; |
| 1153 | assertAgentDefinitionRunnable({ |
| 1154 | definition, |
| 1155 | tools: availableChildTools, |
| 1156 | }); |
| 1157 | const childTools = buildToolsForAgentDefinition(availableChildTools, definition); |
| 1158 | const childHeader: SessionHeader = { |
| 1159 | ...parentHeader, |
| 1160 | permissionMode: definition.permissionMode, |
| 1161 | connectionLocked: true, |
| 1162 | }; |
| 1163 | const userInput: UserMessageInput = { |
| 1164 | turnId: input.turnId, |
| 1165 | text: input.prompt, |
| 1166 | parentRunId: input.parentRunId, |
| 1167 | ...(input.resumedFromRunId ? { resumedFromRunId: input.resumedFromRunId } : {}), |
| 1168 | agentId: definition.id, |
| 1169 | agentName: definition.name, |
| 1170 | }; |
| 1171 | const activeKey = childActiveKey(sessionId, input.turnId); |
| 1172 | const run = new AgentRun({ |
| 1173 | sessionId, |
| 1174 | header: childHeader, |
| 1175 | userInput, |
| 1176 | store: this.deps.store, |
| 1177 | runStore: this.deps.runStore, |
| 1178 | runtimeEventStore: this.deps.runtimeEventStore, |
| 1179 | ...(runtimeToolBoundaryProtocol(this.deps, childHeader) |
| 1180 | ? { toolBoundaryProtocol: runtimeToolBoundaryProtocol(this.deps, childHeader) } |
| 1181 | : {}), |
| 1182 | repairRunRuntimeLedger: this.deps.repairRunRuntimeLedger, |
| 1183 | newId: this.deps.newId, |
| 1184 | now: this.deps.now, |
| 1185 | effectiveOrchestration: resolveEffectiveOrchestration('default', undefined), |
| 1186 | recordSessionMessages: false, |
| 1187 | hooks: { |
| 1188 | reserveRun: async (targetSessionId, nextHeader, activeRun) => { |
| 1189 | const active = await this.reserveChildRun( |
| 1190 | activeKey, |
| 1191 | targetSessionId, |
| 1192 | nextHeader, |
| 1193 | definition.systemPrompt, |
| 1194 | childTools, |
| 1195 | activeRun, |
| 1196 | execution, |
| 1197 | ); |
| 1198 | this.reserveExecutionClaim(execution, active, activeRun); |
| 1199 | return active; |
| 1200 | }, |
| 1201 | unregisterRun: (active, activeRun) => this.unregisterChildRun(active, activeRun), |
no test coverage detected