Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/protocol/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ export type ToCoreFromIdeOrWebviewProtocol = {
"auth/getAuthUrl": [{ useOnboarding: boolean }, { url: string }];
"tools/call": [
{ toolCall: ToolCall },
{ contextItems: ContextItem[]; errorMessage?: string },
{ contextItems: ContextItem[]; errorMessage?: string; errorReason?: string },
];
"tools/evaluatePolicy": [
{ toolName: string; basePolicy: ToolPolicy; args: Record<string, unknown> },
Expand Down
11 changes: 10 additions & 1 deletion core/tools/callTool.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { CallToolResultSchema } from "@modelcontextprotocol/sdk/types.js";
import { ContextItem, Tool, ToolCall, ToolExtras } from "..";
import { MCPManagerSingleton } from "../context/mcp/MCPManagerSingleton";
import { ContinueError } from "../util/errors";
import { canParseUrl } from "../util/url";
import { BuiltInToolNames } from "./builtIn";

Expand Down Expand Up @@ -197,6 +198,7 @@ export async function callTool(
): Promise<{
contextItems: ContextItem[];
errorMessage: string | undefined;
errorReason?: string;
}> {
try {
const args = safeParseToolCallArgs(toolCall);
Expand All @@ -214,12 +216,19 @@ export async function callTool(
};
} catch (e) {
let errorMessage = `${e}`;
if (e instanceof Error) {
let errorReason: string | undefined;

if (e instanceof ContinueError) {
errorMessage = e.message;
errorReason = e.reason;
} else if (e instanceof Error) {
errorMessage = e.message;
}

return {
contextItems: [],
errorMessage,
errorReason,
};
}
}
1 change: 1 addition & 0 deletions core/tools/implementations/readFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ToolImpl } from ".";
import { throwIfFileIsSecurityConcern } from "../../indexing/ignore";
import { getStringArg } from "../parseArgs";
import { throwIfFileExceedsHalfOfContext } from "./readFileLimit";
import { ContinueError, ContinueErrorReason } from "../../util/errors";

export const readFileImpl: ToolImpl = async (args, extras) => {
const filepath = getStringArg(args, "filepath");
Expand Down
2 changes: 1 addition & 1 deletion gui/src/redux/thunks/callToolById.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const callToolById = createAsyncThunk<
output = result.content.contextItems;
error = result.content.errorMessage
? new ContinueError(
ContinueErrorReason.Unspecified,
(result.content.errorReason as ContinueErrorReason) || ContinueErrorReason.Unspecified,
result.content.errorMessage,
)
: undefined;
Expand Down
Loading