MCPcopy Create free account
hub / github.com/apache/maka / admitToolForStep

Method admitToolForStep

packages/runtime/src/tool-runtime.ts:1814–1831  ·  view source on GitHub ↗
(tool: MakaTool, stepId: string | undefined)

Source from the content-addressed store, hash-verified

1812 }
1813
1814 private admitToolForStep(tool: MakaTool, stepId: string | undefined): string | undefined {
1815 if (!stepId) return undefined;
1816 const existing = this.stepAdmissions.get(stepId) ?? { callCount: 0 };
1817 const exclusive = tool.executionSemantics === 'exclusive_step';
1818 if (existing.exclusiveToolName) {
1819 // Say first that nothing happened. A model reading only "cannot share a
1820 // step" cannot tell a refusal apart from a failure and may re-send a call
1821 // that did run.
1822 return `Tool ${tool.name} did not run: ${existing.exclusiveToolName} cannot share an assistant step with other tool calls. Send ${tool.name} again in a later step.`;
1823 }
1824 if (exclusive && existing.callCount > 0) {
1825 return `Tool ${tool.name} did not run: it cannot share an assistant step with other tool calls. Send ${tool.name} again in a step where it is the only call.`;
1826 }
1827 existing.callCount += 1;
1828 if (exclusive) existing.exclusiveToolName = tool.name;
1829 this.stepAdmissions.set(stepId, existing);
1830 return undefined;
1831 }
1832
1833 private assertDurableDispatchNotAborted(toolName: string, abortSignal: AbortSignal): void {
1834 if (!abortSignal.aborted) return;

Callers 1

executeToolMethod · 0.95

Calls 2

getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected