Skip to content

Commit 484aab7

Browse files
committed
fix(core): Handle no tool selection in AgenticExecutor
Previously, if the language model opted not to call a tool, the executor would incorrectly proceed to the "tool not found" logic. This resulted in misleading warnings and incorrect trace data.
1 parent fffaed1 commit 484aab7

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

packages/core/deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mcpc/core",
3-
"version": "0.3.6",
3+
"version": "0.3.7",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com/mcpc-tech/mcpc.git"

packages/core/src/executors/agentic/agentic-executor.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,23 @@ export class AgenticExecutor {
9292
const definitionsOf = (args.definitionsOf as string[]) || [];
9393
const hasDefinitions = (args.hasDefinitions as string[]) || [];
9494

95+
// If no tool selected, just return schema definitions if requested
96+
if (!useTool) {
97+
if (executeSpan) {
98+
executeSpan.setAttributes({
99+
toolType: "none",
100+
completion: true,
101+
});
102+
endSpan(executeSpan);
103+
}
104+
105+
const result: CallToolResult = { content: [] };
106+
this.appendToolSchemas(result, definitionsOf, hasDefinitions);
107+
return result;
108+
}
109+
95110
// Update span name to include selected tool
96-
if (executeSpan && useTool) {
111+
if (executeSpan) {
97112
try {
98113
const safeTool = String(useTool).replace(/\s+/g, "_");
99114
if (typeof (executeSpan as any).updateName === "function") {
@@ -210,15 +225,15 @@ export class AgenticExecutor {
210225
if (executeSpan) {
211226
executeSpan.setAttributes({
212227
toolType: "not_found",
213-
useTool: useTool || "unknown",
214-
completion: true,
228+
useTool: useTool,
215229
});
216230
endSpan(executeSpan);
217231
}
218232

219-
this.logger.debug({
220-
message: "Tool not found, returning completion message",
233+
this.logger.warning({
234+
message: "Tool not found",
221235
useTool,
236+
availableTools: this.allToolNames,
222237
});
223238

224239
const result: CallToolResult = {

0 commit comments

Comments
 (0)