fix: bypass Anthropic OAuth token blocking for tool names
Anthropic blocks specific lowercase tool names (bash, read, write, edit) when using OAuth tokens. This fix: 1. Renames blocked tools to capitalized versions (Bash, Read, Write, Edit) in pi-tools.ts via renameBlockedToolsForOAuth() 2. Passes all tools as customTools in splitSdkTools() to bypass pi-coding-agent's built-in tool filtering, which expects lowercase names The capitalized names work with both OAuth tokens and regular API keys. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Peter Steinberger
parent
a69a863090
commit
333832c2e1
@@ -612,7 +612,11 @@ export function createSystemPromptOverride(
|
||||
return () => trimmed;
|
||||
}
|
||||
|
||||
const BUILT_IN_TOOL_NAMES = new Set(["read", "bash", "edit", "write"]);
|
||||
// Tool names are now capitalized (Bash, Read, Write, Edit) to bypass Anthropic's
|
||||
// OAuth token blocking of lowercase names. However, pi-coding-agent's SDK has
|
||||
// hardcoded lowercase names in its built-in tool registry, so we must pass ALL
|
||||
// tools as customTools to bypass the SDK's filtering.
|
||||
// See: https://github.com/anthropics/claude-code/issues/XXX
|
||||
|
||||
type AnyAgentTool = AgentTool;
|
||||
|
||||
@@ -623,19 +627,13 @@ export function splitSdkTools(options: {
|
||||
builtInTools: AnyAgentTool[];
|
||||
customTools: ReturnType<typeof toToolDefinitions>;
|
||||
} {
|
||||
// SDK rebuilds built-ins from cwd; route sandboxed versions as custom tools.
|
||||
const { tools, sandboxEnabled } = options;
|
||||
if (sandboxEnabled) {
|
||||
return {
|
||||
builtInTools: [],
|
||||
customTools: toToolDefinitions(tools),
|
||||
};
|
||||
}
|
||||
// Always pass all tools as customTools to bypass pi-coding-agent's built-in
|
||||
// tool filtering, which expects lowercase names (bash, read, write, edit).
|
||||
// Our tools are now capitalized (Bash, Read, Write, Edit) for OAuth compatibility.
|
||||
const { tools } = options;
|
||||
return {
|
||||
builtInTools: tools.filter((tool) => BUILT_IN_TOOL_NAMES.has(tool.name)),
|
||||
customTools: toToolDefinitions(
|
||||
tools.filter((tool) => !BUILT_IN_TOOL_NAMES.has(tool.name)),
|
||||
),
|
||||
builtInTools: [],
|
||||
customTools: toToolDefinitions(tools),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user