Fix Claude adapter: web search misclassification, auth parsing duplication, and env exposure#1143

closed1
codething/648ca884-claude
cursor/claude-adapter-issues-650f
openedMar 16, 2026byCcursor[bot]
View on GitHubTwo-way sync enabledPR last imported 29d ago

What Changed

Three targeted fixes in the Claude Code adapter and provider health layers:

  1. isReadOnlyToolName web search misclassification (ClaudeCodeAdapter.ts): Added && !normalized.includes("web") to the "search" substring check so that tools like "WebSearch" are no longer incorrectly classified as read-only. They now correctly flow through classifyToolItemType and get the dynamic_tool_call request type instead of file_read_approval.

  2. Deduplicated auth parsing and CLI runner (ProviderHealth.ts): Extracted parseAuthStatusWithLabels (parameterized by provider-specific message labels) and runCliCommand (parameterized by binary name) to replace the near-identical parseAuthStatusFromOutput/parseClaudeAuthStatusFromOutput and runCodexCommand/runClaudeCommand pairs. The public API surface (parseAuthStatusFromOutput, parseClaudeAuthStatusFromOutput) is preserved as thin wrappers.

  3. Filtered process.env for Claude subprocess (ClaudeCodeAdapter.ts): Replaced env: process.env with env: createClaudeSpawnEnv(process.env), which strips T3CODE_* and VITE_* prefixed variables before forwarding to the Claude SDK. This follows the same pattern used by createTerminalSpawnEnv in the terminal manager.

Why

  • Bug 1 caused web search tool invocations to be classified as file read operations, giving them the wrong approval flow.
  • Bug 2 created maintenance risk: any fix to one auth parser would need to be manually applied to the other.
  • Bug 3 exposed the server's internal environment variables (including T3CODE_* secrets and build-time VITE_* vars) to the Claude Code subprocess.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes — N/A (no UI changes)
  • I included a video for animation/interaction changes — N/A

Note

Fix Claude adapter web search misclassification, auth parsing duplication, and env variable exposure

  • Fixes isReadOnlyToolName in ClaudeCodeAdapter.ts so tool names containing both "web" and "search" are no longer classified as read-only.
  • Adds createClaudeSpawnEnv to filter process.env before passing it to the Claude child process, blocking variables prefixed with T3CODE_ or VITE_.
  • Extracts a shared parseAuthStatusWithLabels util in ProviderHealth.ts so Codex and Claude auth parsing share one implementation with provider-specific label sets.
  • Adds runCliCommand to deduplicate the spawn/collect logic previously duplicated between runCodexCommand and runClaudeCommand.
  • Behavioral Change: Claude child processes no longer inherit T3CODE_* or VITE_* env vars from the server process.
📊 Macroscope summarized b8b3926. 2 files reviewed, 1 issue evaluated, 0 issues filtered, 1 comment posted

🗂️ Filtered Issues

Added 1 commit

  • Fix isReadOnlyToolName web search misclassification, deduplicate auth parsing, and filter process.env for Claudeb8b3926
……@@ -84,7 +84,39 @@ function extractAuthBoolean(value: unknown): boolean | undefined {
111+ "Could not verify Claude Code authentication status from JSON output (missing auth marker).",
112+ verifyFailurePrefix: "Could not verify Claude Code authentication status",
113+ loginHints: ["run `claude login`", "run claude login"],
114+};
MmacroscopeappBoton lines 105–114Mar 16, 2026

🟠 High Layers/ProviderHealth.ts:105

The loginHints array in CLAUDE_AUTH_LABELS contains run \claude login`andrun claude login, but the unauthenticatedMessagecorrectly instructs users to runclaude auth login. When the Claude CLI outputs "run claude auth login", parseAuthStatusWithLabelsfails to match because the hints are missing theauth` subcommand, causing unauthenticated status detection to silently fail and potentially return an incorrect "unknown" auth status instead of "unauthenticated".

suggestion
1const CLAUDE_AUTH_LABELS: ProviderAuthLabels = {
2 unknownCommandMessage:
3 "Claude Code authentication status command is unavailable in this version of Claude Code.",
4 unauthenticatedMessage:
5 "Claude Code is not authenticated. Run `claude auth login` and try again.",
6 jsonParseWarning:
7 "Could not verify Claude Code authentication status from JSON output (missing auth marker).",
8 verifyFailurePrefix: "Could not verify Claude Code authentication status",
9 loginHints: ["run `claude auth login`", "run claude auth login"],
10};
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
text
1In file apps/server/src/provider/Layers/ProviderHealth.ts around lines 105-114:
2
3The `loginHints` array in `CLAUDE_AUTH_LABELS` contains `run \`claude login\`` and `run claude login`, but the `unauthenticatedMessage` correctly instructs users to run `claude auth login`. When the Claude CLI outputs "run `claude auth login`", `parseAuthStatusWithLabels` fails to match because the hints are missing the `auth` subcommand, causing unauthenticated status detection to silently fail and potentially return an incorrect "unknown" auth status instead of "unauthenticated".
4
5Evidence trail:
6apps/server/src/provider/Layers/ProviderHealth.ts lines 106-115 (CLAUDE_AUTH_LABELS definition showing loginHints: ["run `claude login`", "run claude login"] and unauthenticatedMessage: "Run `claude auth login`"); lines 138-148 (parseAuthStatusWithLabels unauthenticated detection logic using loginHints.some((hint) => lowerOutput.includes(hint))); lines 182-188 (fallback to 'unknown' status when no patterns match)