MCPcopy
hub / github.com/codeaashu/claude-code / runToolsSerially

Function runToolsSerially

src/services/tools/toolOrchestration.ts:118–150  ·  view source on GitHub ↗
(
  toolUseMessages: ToolUseBlock[],
  assistantMessages: AssistantMessage[],
  canUseTool: CanUseToolFn,
  toolUseContext: ToolUseContext,
)

Source from the content-addressed store, hash-verified

116}
117
118async function* runToolsSerially(
119 toolUseMessages: ToolUseBlock[],
120 assistantMessages: AssistantMessage[],
121 canUseTool: CanUseToolFn,
122 toolUseContext: ToolUseContext,
123): AsyncGenerator<MessageUpdate, void> {
124 let currentContext = toolUseContext
125
126 for (const toolUse of toolUseMessages) {
127 toolUseContext.setInProgressToolUseIDs(prev =>
128 new Set(prev).add(toolUse.id),
129 )
130 for await (const update of runToolUse(
131 toolUse,
132 assistantMessages.find(_ =>
133 _.message.content.some(
134 _ => _.type === 'tool_use' && _.id === toolUse.id,
135 ),
136 )!,
137 canUseTool,
138 currentContext,
139 )) {
140 if (update.contextModifier) {
141 currentContext = update.contextModifier.modifyContext(currentContext)
142 }
143 yield {
144 message: update.message,
145 newContext: currentContext,
146 }
147 }
148 markToolUseAsComplete(toolUseContext, toolUse.id)
149 }
150}
151
152async function* runToolsConcurrently(
153 toolUseMessages: ToolUseBlock[],

Callers 1

runToolsFunction · 0.85

Calls 3

runToolUseFunction · 0.85
markToolUseAsCompleteFunction · 0.70
addMethod · 0.45

Tested by

no test coverage detected