6 6
7> 查詢 Claude Code 執行時錯誤訊息,了解每個錯誤的含義及修復方法。7> 查詢 Claude Code 執行時錯誤訊息,了解每個錯誤的含義及修復方法。
8 8
9本頁列出 Claude Code 顯示的執行時錯誤及如何從每個錯誤中恢復,以及當回應似乎有問題但沒有錯誤時要檢查的內容。如需安裝錯誤(例如 `command not found` 或設定期間的 TLS 失敗),請參閱 [Troubleshoot installation and login](/docs/zh-TW/troubleshoot-install)。9本頁列出 Claude Code 顯示的執行時錯誤及如何從每個錯誤中復原,以及當回應似乎有問題但沒有錯誤時要檢查的內容。如需安裝錯誤(例如 `command not found` 或設定期間的 TLS 失敗),請參閱[疑難排解安裝和登入](/docs/zh-TW/troubleshoot-install)。
10 10
11這些錯誤和恢復命令適用於 CLI、[Desktop app](/docs/zh-TW/desktop) 和 [Claude Code on the web](/docs/zh-TW/claude-code-on-the-web),因為這三者都包裝相同的 Claude Code CLI。如需特定表面的問題,請參閱該表面頁面上的疑難排解部分。11除了[包裝程式和 IDE 錯誤](#wrapper-and-ide-errors)(由啟動程式列印而非 Claude Code 本身列印)外,這些錯誤和復原命令適用於 CLI、[桌面應用程式](/docs/zh-TW/desktop)和 [Claude Code 網頁版](/docs/zh-TW/claude-code-on-the-web),因為這三者都包裝相同的 Claude Code CLI。如需其他表面特定的問題,請參閱該表面頁面上的疑難排解部分。
12 12
13<Note>13<Note>
14 Claude Code 呼叫 Claude API 以取得模型回應,因此大多數執行時錯誤對應到基礎 API 錯誤代碼。本頁涵蓋每個錯誤在 Claude Code 中的含義及如何恢復。如需原始 HTTP 狀態代碼定義,請參閱 [Claude Platform error reference](https://platform.claude.com/docs/en/api/errors)。14 Claude Code 呼叫 Claude API 以取得模型回應,因此大多數執行時錯誤對應到基礎 API 錯誤代碼。本頁涵蓋每個錯誤在 Claude Code 中的含義及如何復原。如需原始 HTTP 狀態代碼定義,請參閱 [Claude Platform 錯誤參考](https://platform.claude.com/docs/en/api/errors)。
15</Note>15</Note>
16 16
17<h2 id="find-your-error">17<h2 id="find-your-error">
18 尋找您的錯誤18 找到您的錯誤
19</h2>19</h2>
20 20
21將您在終端中看到的訊息與下方的部分相符。21將您看到的訊息與下面的部分進行比對。
22 22
23| 訊息 | 部分 |23| 訊息 | 部分 |
24| :------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------ |24| :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------ |
25| `API Error: 500 Internal server error` | [Server errors](#api-error-500-internal-server-error) |25| `API Error: 500 Internal server error` | [伺服器錯誤](#api-error-500-internal-server-error) |
26| `API Error: Repeated 529 Overloaded errors` | [Server errors](#api-error-repeated-529-overloaded-errors) |26| `API Error: Repeated 529 Overloaded errors` | [伺服器錯誤](#api-error-repeated-529-overloaded-errors) |
27| `Request timed out` | [Server errors](#request-timed-out),或如果訊息提及您的網際網路連線,則為 [Network](#unable-to-connect-to-api) |27| `Request timed out` | [伺服器錯誤](#request-timed-out),或如果訊息提及您的網際網路連線,則為[網路](#unable-to-connect-to-api) |
28| `Server error mid-response. The response above may be incomplete.` | [Server errors](#the-response-above-may-be-incomplete) |28| `API Error: No response from API` | [伺服器錯誤](#no-response-from-api) |
29| `Connection closed mid-response` / `Response stalled mid-stream` | [Server errors](#the-response-above-may-be-incomplete) |29| `Server error mid-response. The response above may be incomplete.` | [伺服器錯誤](#the-response-above-may-be-incomplete) |
30| `<model> is temporarily unavailable, so auto mode cannot determine the safety of...` | [Server errors](#auto-mode-cannot-determine-the-safety-of-an-action) |30| `Connection lost mid-response` / `Your computer went to sleep mid-response` / `The response stopped arriving` | [伺服器錯誤](#the-response-above-may-be-incomplete) |
31| `Auto mode could not evaluate this action and is blocking it for safety` | [Server errors](#auto-mode-cannot-determine-the-safety-of-an-action) |31| `Connection closed mid-response` / `Response stalled mid-stream` | [伺服器錯誤](#the-response-above-may-be-incomplete) |
32| `Auto mode classifier transcript exceeded context window` | [Server errors](#auto-mode-cannot-determine-the-safety-of-an-action) |32| `Connection lost before a response was produced` / `Your computer went to sleep before a response was produced` / `The response stalled before a response was produced` | [自動重試](#automatic-retries) |
33| `Agent terminated early due to an API error` | [Server errors](#agent-terminated-early-due-to-an-api-error) |33| `Connection closed while thinking` / `Response stalled while thinking` | [自動重試](#automatic-retries) |
34| `You've hit your session limit` / `You've hit your weekly limit` | [Usage limits](#youve-hit-your-session-limit) |34| `Connection lost while your computer was asleep` | [自動重試](#automatic-retries) |
35| `Usage credits required for 1M context` | [Usage limits](#usage-credits-required-for-1m-context) |35| `<model> is temporarily unavailable, so auto mode cannot determine the safety of...` | [伺服器錯誤](#auto-mode-cannot-determine-the-safety-of-an-action) |
36| `Server is temporarily limiting requests` | [Usage limits](#server-is-temporarily-limiting-requests) |36| `Auto mode could not evaluate this action and is blocking it for safety` | [伺服器錯誤](#auto-mode-cannot-determine-the-safety-of-an-action) |
37| `Request rejected (429)` | [Usage limits](#request-rejected-429) |37| `Auto mode classifier transcript exceeded context window` | [伺服器錯誤](#auto-mode-cannot-determine-the-safety-of-an-action) |
38| `Credit balance is too low` | [Usage limits](#credit-balance-is-too-low) |38| `Agent aborted: auto mode classifier request refused by the safety safeguard` | [伺服器錯誤](#auto-mode-cannot-determine-the-safety-of-an-action) |
39| `Not logged in · Please run /login` | [Authentication](#not-logged-in) |39| `Agent terminated early due to an API error` | [伺服器錯誤](#agent-terminated-early-due-to-an-api-error) |
40| `Could not resolve authentication method` | [Authentication](#could-not-resolve-authentication-method) |40| `You've hit your session limit` / `You've hit your weekly limit` / `You've hit your Opus limit` / `You've hit your Sonnet limit` | [使用限制](#youve-hit-your-session-limit) |
41| `Invalid API key` | [Authentication](#invalid-api-key) |41| `Usage credits required for 1M context` | [使用限制](#usage-credits-required-for-1m-context) |
42| `Your apiKeyHelper script is failing` | [Authentication](#your-apikeyhelper-script-is-failing) |42| `the prompt to confirm went unanswered — nothing was sent` | [使用限制](#the-prompt-to-confirm-went-unanswered) |
43| `This organization has been disabled` | [Authentication](#this-organization-has-been-disabled) |43| `Server is temporarily limiting requests` | [使用限制](#server-is-temporarily-limiting-requests) |
44| `Your organization has disabled API key authentication` | [Authentication](#your-organization-has-disabled-api-key-authentication) |44| `Request rejected (429)` | [使用限制](#request-rejected-429) |
45| `Your organization has disabled Claude subscription access` | [Authentication](#your-organization-has-disabled-claude-subscription-access) |45| `Credit balance is too low` | [使用限制](#credit-balance-is-too-low) |
46| `Routines are disabled by your organization's policy` | [Authentication](#routines-are-disabled-by-your-organizations-policy) |46| `Could not update your spend limit` | [使用限制](#could-not-update-your-spend-limit) |
47| `Remote Control is only available when using Claude via api.anthropic.com` | [Authentication](#remote-control-requires-the-anthropic-api) |47| `spend limit reached` / `spend limit unavailable` | [使用限制](#spend-limit-reached) |
48| `OAuth token revoked` / `OAuth token has expired` | [Authentication](#oauth-token-revoked-or-expired) |48| `Not logged in · Please run /login` | [驗證](#not-logged-in) |
49| `Login expired · Please run /login` | [Authentication](#login-expired) |49| `Could not resolve authentication method` | [驗證](#could-not-resolve-authentication-method) |
50| `Failed to authenticate: OAuth session expired and could not be refreshed` | [Authentication](#login-expired) |50| `Invalid API key` | [驗證](#invalid-api-key) |
51| `does not meet scope requirement user:profile` | [Authentication](#oauth-scope-requirement) |51| `Your apiKeyHelper script is failing` | [驗證](#your-apikeyhelper-script-is-failing) |
52| `AWS credentials expired or invalid` | [Authentication](#aws-credentials-expired-or-invalid) |52| `Invalid auth token · Fix external auth token` | [驗證](#invalid-request-header-value) |
53| `AWS authentication failed` | [Authentication](#aws-authentication-failed) |53| `Invalid ANTHROPIC_CUSTOM_HEADERS · Fix the environment variable` | [驗證](#invalid-request-header-value) |
54| `AWS default-chain credential resolve timed out` | [Authentication](#aws-default-chain-credential-resolve-timed-out) |54| `Invalid request header from the environment · Fix the environment variable` | [驗證](#invalid-request-header-value) |
55| `Unable to connect to API` | [Network](#unable-to-connect-to-api) |55| `This organization has been disabled` | [驗證](#this-organization-has-been-disabled) |
56| `Waiting for API response · will retry in` | [Automatic retries](#automatic-retries),或如果持續發生,則為 [Network](#unable-to-connect-to-api) |56| `Your organization has disabled API key authentication` | [驗證](#your-organization-has-disabled-api-key-authentication) |
57| `Bedrock streaming response has content-type "..."; expected "application/vnd.amazon.eventstream"` | [Network](#bedrock-streaming-response-has-an-unexpected-content-type) |57| `Your organization has disabled Claude subscription access` | [驗證](#your-organization-has-disabled-claude-subscription-access) |
58| `SSL certificate verification failed` | [Network](#ssl-certificate-errors) |58| `Routines are disabled by your organization's policy` | [驗證](#routines-are-disabled-by-your-organizations-policy) |
59| `SSL certificate error (...)` during login or startup | [Network](#ssl-certificate-errors) |59| `Remote Control is only available when using Claude via api.anthropic.com` | [驗證](#remote-control-requires-the-anthropic-api) |
60| `403` with `x-deny-reason: host_not_allowed` in a cloud or routine session | [Network](#host-not-allowed-in-a-cloud-session) |60| `OAuth token refresh failed — run /login to re-authenticate` | [驗證](#remote-control-couldnt-refresh-your-login) |
61| `Couldn't reconnect to your Remote Control session` | [Network](#couldnt-reconnect-to-your-remote-control-session) |61| `JWT refresh failed: no OAuth token — run /login` | [驗證](#remote-control-couldnt-refresh-your-login) |
62| `Prompt is too long` | [Request errors](#prompt-is-too-long) |62| `Claude.ai login expired` | [驗證](#remote-control-couldnt-refresh-your-login) |
63| `Error during compaction: Conversation too long` | [Request errors](#error-during-compaction-conversation-too-long) |63| `Claude.ai login was rejected — run /login, then /remote-control` | [驗證](#remote-control-couldnt-refresh-your-login) |
64| `Request too large` | [Request errors](#request-too-large) |64| `OAuth token unavailable — run /login to restore Remote Control` | [驗證](#remote-control-couldnt-refresh-your-login) |
65| `Image was too large` | [Request errors](#image-was-too-large) |65| `Signed out of Claude — run /login, then /remote-control` | [驗證](#remote-control-couldnt-refresh-your-login) |
66| `Unable to resize image` | [Request errors](#unable-to-resize-image) |66| `signed-in claude.ai account or organization changed on this machine` | [驗證](#remote-control-stopped-because-the-signed-in-account-changed) |
67| `PDF too large` / `PDF is password protected` | [Request errors](#pdf-errors) |67| `Remote Control stopped — the app running this session is now signed in to a different Claude account` | [驗證](#remote-control-stopped-because-the-app-running-the-session-signed-out-or-switched-accounts) |
68| `Extra inputs are not permitted` | [Request errors](#extra-inputs-are-not-permitted) |68| `Remote Control stopped — the app running this session is signed out of Claude` | [驗證](#remote-control-stopped-because-the-app-running-the-session-signed-out-or-switched-accounts) |
69| `There's an issue with the selected model` | [Request errors](#theres-an-issue-with-the-selected-model) |69| `OAuth token revoked` / `OAuth token has expired` | [驗證](#oauth-token-revoked-or-expired) |
70| `Model ... is not a recognized model id` | [Request errors](#model-is-not-a-recognized-model-id) |70| `API Error: 401 Invalid authentication credentials` | [驗證](#api-error-401-invalid-authentication-credentials) |
71| `Claude Opus is not available with the Claude Pro plan` | [Request errors](#claude-opus-is-not-available-with-the-claude-pro-plan) |71| `Login expired · Please run /login` | [驗證](#login-expired) |
72| `Model ... is restricted by your organization's settings` | [Request errors](#model-is-restricted-by-your-organizations-settings) |72| `Not signed in to the Cloud gateway — run /login.` | [驗證](#administrator-policy-requires-a-cloud-gateway-sign-in) |
73| `thinking.type.enabled is not supported for this model` | [Request errors](#thinking-type-enabled-is-not-supported-for-this-model) |73| `Administrator policy requires a Cloud gateway sign-in on this machine` | [驗證](#administrator-policy-requires-a-cloud-gateway-sign-in) |
74| `max_tokens must be greater than thinking.budget_tokens` | [Request errors](#thinking-budget-exceeds-output-limit) |74| `Failed to authenticate: OAuth session expired and could not be refreshed` | [驗證](#login-expired) |
75| `API Error: 400 due to tool use concurrency issues` | [Request errors](#tool-use-or-thinking-block-mismatch) |75| `Your account is on hold and can't use Claude Code. View details or appeal: https://claude.ai/restricted` | [驗證](#your-account-is-on-hold) |
76| `Claude Code is unable to respond to this request, which appears to violate our Usage Policy` | [Request errors](#usage-policy-refusal) |76| `Your account is on hold and can't sign in to Claude Code. View details or appeal: https://claude.ai/restricted` | [驗證](#your-account-is-on-hold) |
77| `<model> has safety measures that flagged this message for a cybersecurity topic` | [Request errors](#safety-measures-flagged-a-cybersecurity-topic) |77| `Anthropic profile login expired · Re-authenticate your Anthropic profile` | [驗證](#anthropic-profile-login-expired) |
78| `Installation was killed before it could finish (exit code 137)` | [Installation errors](#installation-was-killed-before-it-could-finish) |78| `Anthropic profile login expired · Run /login to use your claude.ai account instead, or re-authenticate the profile` | [驗證](#anthropic-profile-login-expired) |
79| `The connection dropped while downloading the update` | [Installation errors](#the-connection-dropped-while-downloading-the-update) |79| `does not meet scope requirement user:profile` | [驗證](#oauth-scope-requirement) |
80| `Download timed out: exceeded the total deadline` | [Installation errors](#the-connection-dropped-while-downloading-the-update) |80| `claude.ai rejected the session token` / `session token rejected` | [驗證](#claude-ai-rejected-the-session-token) |
81| `--bg and --print conflict` | [Command-line errors](#command-line-errors) |81| `Issuer mismatch in authorization response (RFC 9207)` | [驗證](#issuer-mismatch-in-authorization-response) |
82| `Error: --json-schema is not a valid JSON Schema` | [Command-line errors](#command-line-errors) |82| `Cloud gateway session expired — run /login to reconnect.` | [驗證](#cloud-gateway-session-expired) |
83| `Could not import <server>: <reason>` | [Command-line errors](#could-not-import-a-server-from-claude-desktop) |83| `Cloud gateway <url> no longer accepts this session` | [驗證](#cloud-gateway-session-expired) |
84| `Error: MCP tool <name> (passed via --permission-prompt-tool) not found` | [Command-line errors](#mcp-permission-prompt-tool-not-found) |84| `AWS credentials expired or invalid` | [驗證](#aws-credentials-expired-or-invalid) |
85| `Marketplace "<name>" is registered from an untrusted source` | [Plugin errors](#marketplace-is-registered-from-an-untrusted-source) |85| `AWS authentication failed` | [驗證](#aws-authentication-failed) |
86| `references ${user_config.*} in a shell-form command` | [Plugin errors](#plugin-command-references-user-config) |86| `Could not load AWS credentials` / `Could not load Google Cloud credentials` | [驗證](#could-not-load-aws-or-google-cloud-credentials) |
87| `Monitor "<name>" from plugin <plugin> references ${user_config.*} in its command` | [Plugin errors](#plugin-command-references-user-config) |87| `AWS default-chain credential resolve timed out` | [驗證](#aws-default-chain-credential-resolve-timed-out) |
88| `headersHelper for MCP server '<name>' references ${user_config.*}` | [Plugin errors](#plugin-command-references-user-config) |88| `Timed out after 60s waiting for AWS` | [驗證](#bedrock-setup-verification-timed-out-waiting-for-aws) |
89| `would be spawned with zero tools — refusing` | [Tool errors](#agent-would-be-spawned-with-zero-tools) |89| `A request to AWS timed out. Check your network and proxy settings, then try again.` | [驗證](#bedrock-setup-verification-timed-out-waiting-for-aws) |
90| `File is covered by a Read deny rule in your permission settings` | [Tool errors](#file-is-covered-by-a-read-deny-rule) |90| `Could not load the default credentials` on Google Cloud's Agent Platform | [驗證](#could-not-load-aws-or-google-cloud-credentials) |
91| `Can't open MCP settings in a background session` | [Background session errors](#commands-refused-in-a-background-session) |91| `Unable to connect to API` | [網路](#unable-to-connect-to-api) |
92| `CLAUDE_CODE_PROCESS_WRAPPER: launcher ...` | [Background session errors](#claude_code_process_wrapper-launcher-errors) |92| `Connection refused —` / `Can't reach the API server —` / `No internet route —` / `Couldn't connect through your proxy` / `Connection dropped`,各以括號中的錯誤代碼結尾 | [網路](#unable-to-connect-to-api) |
93| `Ignoring N permissions.allow entries from ... this workspace has not been trusted` | [Configuration warnings](#workspace-has-not-been-trusted) |93| `Unable to connect to Anthropic services` during setup | [網路](#unable-to-connect-to-anthropic-services) |
94| 回應品質似乎低於平常 | [Response quality](#responses-seem-lower-quality-than-usual) |94| `Socket is closed` | [網路](#socket-is-closed) |
95| `Waiting for API response · will retry in` | [自動重試](#automatic-retries),或如果持續發生,則為[網路](#unable-to-connect-to-api) |
96| `API returned an empty or malformed response` | [網路](#api-returned-an-empty-or-malformed-response) |
97| `Streaming response ended before any complete data was received` | [網路](#streaming-response-ended-before-any-complete-data-was-received) |
98| `Bedrock streaming response has content-type "..."; expected "application/vnd.amazon.eventstream"` | [網路](#bedrock-streaming-response-has-an-unexpected-content-type) |
99| `SSL certificate verification failed` | [網路](#ssl-certificate-errors) |
100| `SSL certificate error (...)` during login or startup | [網路](#ssl-certificate-errors) |
101| `unable to get local issuer certificate` | [網路](#ssl-certificate-errors) |
102| `403` with `x-deny-reason: host_not_allowed` in a cloud or routine session | [網路](#host-not-allowed-in-a-cloud-session) |
103| `proxy refused the connection` | [網路](#the-proxy-refused-the-connection) |
104| `403` with `This GraphQL query is not enabled for this session` in a cloud session | [GitHub proxy](/docs/zh-TW/cloud-environments#github-proxy) |
105| `The cloud environments service returned an empty response` / `The cloud environments service returned a response in an unexpected format` | [網路](#the-cloud-environments-service-returned-an-empty-or-unexpected-response) |
106| `Couldn't reconnect to your Remote Control session` | [網路](#couldnt-reconnect-to-your-remote-control-session) |
107| `N sessions ended while this machine was offline — the environment was cleaned up on the server and can't be resumed.` | [網路](#sessions-ended-while-this-machine-was-offline) |
108| `Couldn't share the transcript.` | [網路](#couldnt-share-the-transcript) |
109| `Prompt is too long` / `Input is too long for requested model` | [請求錯誤](#prompt-is-too-long) |
110| `Prompt is too long · automatic compaction failed:` | [請求錯誤](#prompt-is-too-long) |
111| `Prompt is too long · this conversation is a single exchange` / `A single-exchange conversation cannot be compacted` | [請求錯誤](#prompt-is-too-long) |
112| `Context limit reached · /compact or /clear to continue` | [請求錯誤](#prompt-is-too-long) |
113| `Context limit reached · /clear to continue` | [請求錯誤](#prompt-is-too-long) |
114| `capability_rejected: prompt_too_long` on a Claude apps gateway session | [請求錯誤](#prompt-is-too-long) |
115| `upstream rejected the request` / `request too large for this upstream` on a Claude apps gateway session | [上游錯誤訊息](/docs/zh-TW/claude-apps-gateway-config#upstream-error-messages) |
116| `upstream rate limit exceeded` on a Claude apps gateway session | [上游錯誤訊息](/docs/zh-TW/claude-apps-gateway-config#upstream-error-messages) |
117| `all upstreams failed (N attempted)` on a Claude apps gateway session | [上游錯誤訊息](/docs/zh-TW/claude-apps-gateway-config#upstream-error-messages) |
118| `Claude Code may not be enabled for your organization` after a Claude apps gateway sign-in | [Claude apps gateway 疑難排解](/docs/zh-TW/claude-apps-gateway-deploy#troubleshooting) |
119| `Context exceeds the ...-token limit by ... tokens` in `/context` output | [請求錯誤](#context-exceeds-the-token-limit) |
120| `Error during compaction: Conversation too long` | [請求錯誤](#error-during-compaction-conversation-too-long) |
121| `Request too large` | [請求錯誤](#request-too-large) |
122| `Request too large for the API's 32MB request limit` | [請求錯誤](#request-too-large) |
123| `Image was too large` | [請求錯誤](#image-was-too-large) |
124| `Unable to resize image` | [請求錯誤](#unable-to-resize-image) |
125| `PDF too large` / `PDF is password protected` | [請求錯誤](#pdf-errors) |
126| `Extra inputs are not permitted` | [請求錯誤](#extra-inputs-are-not-permitted) |
127| `API Error: 400 ... tools.N.custom.input_schema: JSON schema is invalid` / `Property keys should match pattern` | [請求錯誤](#tool-input-schema-is-invalid) |
128| `There's an issue with the selected model` | [請求錯誤](#theres-an-issue-with-the-selected-model) |
129| `Model ... is not a recognized model id` | [請求錯誤](#model-is-not-a-recognized-model-id) |
130| `Model ... not found` | [請求錯誤](#model-not-found) |
131| `Claude Opus is not available with the Claude Pro plan` | [請求錯誤](#claude-opus-is-not-available-with-the-claude-pro-plan) |
132| `Claude Code ... does not support this model; version ... or newer is required` | [請求錯誤](#claude-code-does-not-support-this-model) |
133| `Claude Code ... is older than the minimum version required by your organization's policy` | [請求錯誤](#claude-code-does-not-support-this-model) |
134| `Model ... is restricted by your organization's settings` | [請求錯誤](#model-is-restricted-by-your-organizations-settings) |
135| `Model switch ... blocked by a PreModelSwitch hook` | [請求錯誤](#model-switch-was-blocked-by-a-premodelswitch-hook) |
136| `couldn't save it as your default` / `couldn't confirm it was saved as your default` | [請求錯誤](#couldnt-save-it-as-your-default) |
137| `thinking.type.enabled is not supported for this model` | [請求錯誤](#thinking-type-enabled-is-not-supported-for-this-model) |
138| `Effort '<level>' isn't available with thinking turned off on this model` | [請求錯誤](#effort-isnt-available-with-thinking-turned-off) |
139| `effort '<level>' is not supported when thinking is disabled` | [請求錯誤](#effort-isnt-available-with-thinking-turned-off) |
140| `max_tokens must be greater than thinking.budget_tokens` | [請求錯誤](#thinking-budget-exceeds-output-limit) |
141| `API Error: 400 due to tool use concurrency issues` | [請求錯誤](#tool-use-or-thinking-block-mismatch) |
142| `[Unsupported tool content removed]` | [請求錯誤](#unsupported-tool-content-removed) |
143| `server_tool_use.name: Input should be` on every turn of a resumed session | [請求錯誤](#unsupported-tool-content-removed) |
144| `<model> can't help with this. Start a new session to continue` | [請求錯誤](#usage-policy-refusal) |
145| `Claude Code is unable to respond to this request, which appears to violate our Usage Policy` | [請求錯誤](#usage-policy-refusal) |
146| `<model>'s safeguards flagged this message` | [請求錯誤](#safety-measures-flagged-a-cybersecurity-topic) |
147| `<model> has safety measures that flagged this message for a cybersecurity topic` | [請求錯誤](#safety-measures-flagged-a-cybersecurity-topic) |
148| `Installation was killed before it could finish (exit code 137)` | [安裝錯誤](#installation-was-killed-before-it-could-finish) |
149| `The connection dropped while downloading the update` | [安裝錯誤](#the-connection-dropped-while-downloading-the-update) |
150| `Download timed out: exceeded the total deadline` | [安裝錯誤](#the-connection-dropped-while-downloading-the-update) |
151| `--bg and --print conflict` | [命令列錯誤](#command-line-errors) |
152| `Cloud sessions cannot be created from a --restricted session` | [命令列錯誤](#cloud-sessions-cannot-be-created-from-a-restricted-session) |
153| `Error: --json-schema is not a valid JSON Schema` | [命令列錯誤](#command-line-errors) |
154| `Error: Invalid --agents configuration:` | [命令列錯誤](#invalid-agents-configuration) |
155| `Error: Settings file exceeds the 2MiB limit` | [命令列錯誤](#settings-file-exceeds-the-2mib-limit) |
156| `The current directory no longer exists (it was deleted or moved)` / `Can't read the current directory` | [命令列錯誤](#the-current-directory-no-longer-exists) |
157| `couldn't be resolved to a real location, so its skills, commands, and agents weren't loaded` | [命令列錯誤](#directory-couldnt-be-resolved-to-a-real-location) |
158| `Error: Workspace not trusted` when starting Remote Control | [命令列錯誤](#workspace-not-trusted-when-starting-remote-control) |
159| `` `<flag>` before `remote-control` is not carried over to the sessions Remote Control starts `` | [命令列錯誤](#not-carried-over-to-the-sessions-remote-control-starts) |
160| `` `claude import` is not yet available in this build `` | [命令列錯誤](#claude-import-is-not-yet-available-in-this-build) |
161| `Could not read Claude Code config` | [命令列錯誤](#could-not-read-claude-code-config) |
162| `Could not import <server>: <reason>` | [命令列錯誤](#could-not-import-a-server-from-claude-desktop) |
163| `Cannot add MCP server to scope: managed` | [命令列錯誤](#cannot-add-mcp-server-to-the-managed-scope) |
164| `is Anthropic-hosted and doesn't support local OAuth` | [命令列錯誤](#anthropic-hosted-and-doesnt-support-local-oauth) |
165| `Can't read .mcp.json: it isn't a regular file or is larger than 2097152 bytes` | [命令列錯誤](#cant-read-mcp-json) |
166| `Server rejected the Authorization header minted by the configured headersHelper` | [命令列錯誤](#server-rejected-the-authorization-header-minted-by-the-configured-headershelper) |
167| `Error: MCP tool <name> (passed via --permission-prompt-tool) not found` | [命令列錯誤](#mcp-permission-prompt-tool-not-found) |
168| `OAuth callback port <port> is already in use — another process may be holding it` | [命令列錯誤](#oauth-callback-port-is-already-in-use) |
169| `Shell command failed for pattern "..."`, from `/security-review` or any skill that injects dynamic context | [命令列錯誤](#security-review-fails-without-origin-head) |
170| `Shell command permission check failed for pattern "..."`, from a skill that injects dynamic context | [命令列錯誤](#security-review-fails-without-origin-head) |
171| ``Skill <name> requires bash (`shell: bash` in frontmatter) but Git Bash was not found`` | [命令列錯誤](#security-review-fails-without-origin-head) |
172| `Input must be provided either through stdin or as a prompt argument when using --print` | [命令列錯誤](#input-must-be-provided-when-using-print) |
173| `Error: Input contained only whitespace` | [命令列錯誤](#input-contained-only-whitespace) |
174| `Blank prompt — the message was only whitespace, so nothing was sent to the model.` | [命令列錯誤](#input-contained-only-whitespace) |
175| `Error: stream-json input carried over 256M characters with no newline` | [命令列錯誤](#stream-json-input-carried-over-256m-characters-with-no-newline) |
176| `Unknown command: /<name>`, with or without a `Did you mean` suggestion | [命令列錯誤](#unknown-command) |
177| `Diff is too large for ultrareview` / `PR #<N> is too large for ultrareview` | [命令列錯誤](#diff-is-too-large-for-ultrareview) |
178| `Could not find merge-base with <branch>` | [命令列錯誤](#could-not-find-merge-base-with-the-base-branch) |
179| `Your checkout has no branches (detached HEAD only)` | [命令列錯誤](#your-checkout-has-no-branches) |
180| `Ultrareview clones <owner>/<repo> in the cloud with the GitHub account connected to your Claude account, and none is connected` | [命令列錯誤](#no-github-account-is-connected-to-your-claude-account) |
181| `Your connected GitHub account can't see <owner>/<repo>` | [命令列錯誤](#your-connected-github-account-cant-see-the-repository) |
182| `The GitHub App preflight failed transiently (network or service hiccup) — retry in a moment to start from GitHub instead` | [命令列錯誤](#the-github-app-preflight-failed-transiently) |
183| `Failed to resume the conversation` | [命令列錯誤](#failed-to-resume-the-conversation) |
184| `No conversation found with session ID: <session-id>` | [命令列錯誤](#no-conversation-found-with-the-session-id) |
185| `Cannot switch renderers in this session` | [命令列錯誤](#cannot-switch-renderers-in-this-session) |
186| `Cannot switch renderers while work is running in the background` | [命令列錯誤](#cannot-switch-renderers-in-this-session) |
187| `Couldn't read your Zed keymap` / `Couldn't back up your Zed keymap` / `Couldn't update your Zed keymap` | [命令列錯誤](#terminal-setup-left-your-zed-keymap-unchanged) |
188| `Your Zed keymap isn't a readable list of keybindings` | [命令列錯誤](#terminal-setup-left-your-zed-keymap-unchanged) |
189| `Skill usage reports are not available on this connection.` | [命令列錯誤](#skill-usage-reports-are-not-available-on-this-connection) |
190| `` `plugin eval` is currently in early access `` / `` `plugin eval` is currently unavailable `` | [Plugin 錯誤](#plugin-eval-is-currently-in-early-access) |
191| `Marketplace "<name>" is registered from an untrusted source` | [Plugin 錯誤](#marketplace-is-registered-from-an-untrusted-source) |
192| `references ${user_config.*} in a shell-form command` | [Plugin 錯誤](#plugin-command-references-user-config) |
193| `Monitor "<name>" from plugin <plugin> references ${user_config.*} in its command` | [Plugin 錯誤](#plugin-command-references-user-config) |
194| `headersHelper for MCP server '<name>' references ${user_config.*}` | [Plugin 錯誤](#plugin-command-references-user-config) |
195| `Plugin archive integrity check failed` | [Plugin 錯誤](#plugin-archive-integrity-check-failed) |
196| `path escapes plugin directory` | [Plugin 錯誤](#path-escapes-plugin-directory) |
197| `path could not be checked` | [Plugin 錯誤](#path-could-not-be-checked) |
198| `its marketplace entry path does not stay inside the marketplace directory` | [Plugin 錯誤](#marketplace-entry-path-does-not-stay-inside-the-marketplace-directory) |
199| `Plugin source path refused` | [Plugin 錯誤](#marketplace-entry-path-does-not-stay-inside-the-marketplace-directory) |
200| `Failed to load marketplace configuration` | [Plugin 錯誤](#failed-to-load-marketplace-configuration) |
201| `Marketplace configuration file is corrupted` | [Plugin 錯誤](#failed-to-load-marketplace-configuration) |
202| `would be spawned with zero tools — refusing` | [工具錯誤](#agent-would-be-spawned-with-zero-tools) |
203| `File is covered by a Read deny rule in your permission settings` | [工具錯誤](#file-is-covered-by-a-read-deny-rule) |
204| `subagent_type is required: the general-purpose agent is not available in this session` | [工具錯誤](#subagent-type-is-required) |
205| `Error: this write left the memory index at MEMORY.md at ..., over its ... read limit` | [工具錯誤](#memory-index-is-over-its-read-limit) |
206| `pkill: refusing to run` | [工具錯誤](#pkill-pattern-matches-the-claude-code-process) |
207| `Failed to write to <name>'s inbox — nothing was sent` | [工具錯誤](#failed-to-write-to-a-teammate-inbox) |
208| `Failed to write the plan approval request to the lead's inbox — plan not submitted` | [工具錯誤](#failed-to-write-to-a-teammate-inbox) |
209| `Message too large for cross-session delivery` | [工具錯誤](#message-too-large-for-cross-session-delivery) |
210| `Too many messages to this session just now` | [工具錯誤](#too-many-messages-to-this-session-just-now) |
211| `Refusing to send: reply target is a symlink` / `Refusing to send: cannot vet reply target` | [工具錯誤](#refusing-to-send-a-cross-session-message) |
212| `Refusing to send: connected endpoint is not the expected process` / `Refusing to send: connected endpoint identity could not be read` | [工具錯誤](#refusing-to-send-a-cross-session-message) |
213| `Refusing to send: connected endpoint is not owned by this user` / `Refusing to send: connected endpoint owner could not be read` | [工具錯誤](#refusing-to-send-a-cross-session-message) |
214| `Refusing to send: connected endpoint is a different process with the expected pid` | [工具錯誤](#refusing-to-send-a-cross-session-message) |
215| `Refusing to read <path>: its symlink resolution changed after permission was checked` / `Refusing to search <path>: its symlink resolution changed after permission was checked` | [工具錯誤](#refusing-after-a-symlink-changed) |
216| `Refusing to write <path>: its parent-directory symlink resolution changed after permission was checked` / `Refusing to write <path>: it is a symbolic link. Write to the link's target path instead` | [工具錯誤](#refusing-after-a-symlink-changed) |
217| `Refusing to search <path>: a path one of its Read deny rules is written through changed while the search was being prepared` / `Refusing to search <path>: it could not be opened` | [工具錯誤](#refusing-after-a-symlink-changed) |
218| `its permission check expired before it ran (too many concurrent file operations)` / `ripgrep was found only by name on PATH` | [工具錯誤](#refusing-after-a-symlink-changed) |
219| `task output swap refused (tasks dir moved or linked)` | [工具錯誤](#task-output-swap-refused) |
220| `Command killed: its output file was replaced or could no longer be verified` | [工具錯誤](#task-output-swap-refused) |
221| `the source file is not valid UTF-8 text` / `the source file is not valid UTF-16 text` | [工具錯誤](#the-source-file-is-not-valid-utf-8-text) |
222| `the source file has the replacement character U+FFFD` | [工具錯誤](#the-source-file-is-not-valid-utf-8-text) |
223| `Can't open MCP settings while no terminal is attached to this background session` | [背景工作階段錯誤](#commands-refused-in-a-background-session) |
224| `Can't open MCP settings in a background session` | [背景工作階段錯誤](#commands-refused-in-a-background-session) |
225| `blocked because the path is spelled in a form that cannot be safely resolved` | [背景工作階段錯誤](#write-or-command-blocked-because-the-path-cannot-be-safely-resolved) |
226| `blocked because the path is network-shaped` | [背景工作階段錯誤](#write-or-command-blocked-because-the-path-names-a-network-location) |
227| `This session has no saved transcript` | [背景工作階段錯誤](#this-session-has-no-saved-transcript) |
228| `Can't open — this session is running in another terminal` | [背景工作階段錯誤](#this-session-is-running-in-another-terminal) |
229| `This conversation is already open in another running Claude session` | [背景工作階段錯誤](#this-session-is-running-in-another-terminal) |
230| `This session's saved conversation is no longer on disk` | [背景工作階段錯誤](#this-sessions-saved-conversation-is-no-longer-on-disk) |
231| `kept <id> — <n> unpushed commits on <branch>` | [背景工作階段錯誤](#worktree-has-commits-that-are-not-pushed-anywhere) |
232| `kept <id> — worktree has commits that are not pushed anywhere` | [背景工作階段錯誤](#worktree-has-commits-that-are-not-pushed-anywhere) |
233| `terminal host process died — press Enter to restart` / `This session's terminal host process died` | [背景工作階段錯誤](#terminal-host-process-died) |
234| `Session isn't responding` / `Press enter again to restart this session — it isn't responding` | [背景工作階段錯誤](#session-isnt-responding) |
235| `Session <id> was stopped while the respawn was in flight` | [背景工作階段錯誤](#session-was-stopped-while-the-respawn-was-in-flight) |
236| `This session was running agent '<name>', which is no longer available` | [背景工作階段錯誤](#session-agent-no-longer-available) |
237| `CLAUDE_CODE_PROCESS_WRAPPER: launcher ...` | [背景工作階段錯誤](#claude_code_process_wrapper-launcher-errors) |
238| `EUNKNOWN: unknown error, uv_spawn` | [背景工作階段錯誤](#eunknown-when-starting-a-background-session) |
239| `EACCES: permission denied, posix_spawn` | [背景工作階段錯誤](#eacces-when-starting-a-background-session) |
240| `exited before it became reachable` | [背景工作階段錯誤](#background-service-exited-before-it-became-reachable) |
241| `Couldn't start a background session (working directory no longer exists or is not accessible: ...)` | [背景工作階段錯誤](#working-directory-no-longer-exists-when-starting-a-background-session) |
242| `Claude Code is being updated by npm on this machine (still not runnable after 2 min, ...)` | [背景工作階段錯誤](#eacces-when-starting-a-background-session) |
243| `Claude Code process exited with code N` | [包裝程式和 IDE 錯誤](#claude-code-process-exited-with-code-n) |
244| `Could not locate the Claude CLI on PATH` | [包裝程式和 IDE 錯誤](#could-not-locate-the-claude-cli-on-path) |
245| `Restored the code, but skipped N files` | [Rewind 警告和錯誤](#restored-the-code-but-skipped-files) |
246| `No files were restored: N files failed (backup missing, or the file could not be updated)` | [Rewind 警告和錯誤](#no-files-were-restored) |
247| `Transcript writes are failing (...)` | [工作階段儲存警告](#transcript-writes-are-failing) |
248| `Transcript saving is off — CLAUDE_CODE_SKIP_PROMPT_HISTORY is set` | [工作階段儲存警告](#transcript-saving-is-off-skip-prompt-history) |
249| `Transcript saving is off — inherited CLAUDE_CODE_CHILD_SESSION marker` | [工作階段儲存警告](#transcript-saving-is-off-child-session-marker) |
250| `Claude Code's fullscreen renderer didn't finish starting last time on this machine` / `Claude Code's fullscreen renderer has repeatedly failed to start on this machine` | [設定警告](#fullscreen-failed-start-notice) |
251| `Claude Code exited after an unrecoverable interface error (...)` | [設定警告](#exited-after-an-unrecoverable-interface-error) |
252| `Agent descriptions are over the 15.0k-token limit` | [設定警告](#agent-descriptions-are-over-the-15000-token-limit) |
253| `Ignoring N permissions.allow entries from ... this workspace has not been trusted` | [設定警告](#workspace-has-not-been-trusted) |
254| `is a network path, which cannot be added as a working directory` | [設定警告](#working-directory-is-a-network-path) |
255| `Remote managed settings failed to load (<cause>)` | [設定警告](#remote-managed-settings-failed-to-load) |
256| `Managed settings were not approved; exiting without applying them.` | [設定警告](#managed-settings-were-not-approved) |
257| `MCP server <name> is blocked by enterprise managed policy` | [設定警告](#mcp-server-is-blocked-by-enterprise-managed-policy) |
258| `Managed settings document could not be parsed as a JSON object; none of its settings are in effect. Fix or remove it.` | [設定警告](#managed-settings-document-could-not-be-parsed) |
259| `Managed settings drop-in directory could not be read` | [設定警告](#managed-settings-document-could-not-be-parsed) |
260| `"crossSessionInbound" must be one of "accept", "hold", "refuse"` | [設定警告](#crosssessioninbound-must-be-one-of-accept-hold-refuse) |
261| `headersHelper not run — this workspace has no persisted trust` | [設定警告](#headershelper-not-run) |
262| `Invalid permission rule "..." was skipped: Malformed Tool(content) rule` | [設定警告](#malformed-tool-content-rule) |
263| `... is not matched by file permission checks` | [設定警告](#is-not-matched-by-file-permission-checks) |
264| `... has a wildcard before the rest of the command` | [設定警告](#has-a-wildcard-before-the-rest-of-the-command) |
265| `CLAUDE_CODE_DISABLE_1M_CONTEXT is set, but the 200K limit isn't enforced` | [設定警告](#the-200k-limit-isnt-enforced) |
266| `[claude-code:unrecognized_model]` | [設定警告](#unrecognized-model-id-on-a-request) |
267| `Stale sandbox mask files left by a killed session` | [設定警告](#stale-sandbox-mask-files-left-by-a-killed-session) |
268| 回應品質似乎比平常低 | [回應品質](#responses-seem-lower-quality-than-usual) |
95 269
96<h2 id="automatic-retries">270<h2 id="automatic-retries">
97 自動重試271 自動重試
98</h2>272</h2>
99 273
100Claude Code 在向您顯示錯誤之前會重試暫時性失敗。伺服器錯誤、過載回應、請求逾時、臨時 429 節流和中斷的連線都會以指數退避方式重試最多 10 次。自 v2.1.198 起,這涵蓋在任何可見輸出串流之前在回應中途中斷的連線:Claude Code 使用相同的退避重新發出請求,轉向繼續而不是停止並出現連線錯誤。自 v2.1.199 起,不帶您計畫配額標頭的臨時 429 節流在您使用 claude.ai 訂閱登入時也會重試;較早的版本僅針對 API 金鑰和 Enterprise 登入重試它們。274Claude Code 會在顯示錯誤之前,以指數退避方式重試暫時性故障最多 10 次。它不會總是重試在 Claude 回應中途出現的故障。當您看到本頁面上的其中一個錯誤時,Claude Code 已經對該故障進行了適用的重試;下面的清單說明哪些故障會獲得完整的重試預算、哪些會獲得較小的預算,以及哪些不會獲得任何預算。
101 275
102有些失敗類別不會重試,因為重試無法成功:276Claude Code 會重試這些故障:
103 277
104* 自 v2.1.199 起,TLS 憑證驗證失敗(例如 TLS 檢查代理、遺失的 `NODE_EXTRA_CA_CERTS` 套件或過期的憑證)在第一次嘗試時失敗,因此修復會立即出現,而不是在完整重試預算之後。請參閱 [SSL 憑證錯誤](#ssl-certificate-errors)。暫時性 TLS 條件(例如握手逾時)仍會重試。278* 伺服器錯誤、過載回應,以及在 Claude 回應開始串流之前到達的請求逾時。
105* 自 v2.1.199 起,在 Claude 已經串流可見輸出後到達的伺服器錯誤會保留部分回應並附加 [不完整回應通知](#the-response-above-may-be-incomplete),而不是重試,因為重新執行請求可能會執行相同的工具兩次。較早的版本會捨棄部分輸出並將轉向報告為錯誤。279* 連線中斷。當連線在 Claude 完成其回應的任何部分(包括其思考)之前中途中斷時,Claude Code 會以相同的退避方式重新發出請求,並且回合會繼續,即使某些文字已經開始串流。當連線在 Claude 完成思考之後但在開始任何文字或工具呼叫之前中斷時,Claude Code 會改為快速連續重新發出請求最多兩次,如果連線在該點持續中斷,則以 `Connection lost before a response was produced` 結束回合。
106* [Amazon Bedrock 串流回應具有非預期的內容類型](#bedrock-streaming-response-has-an-unexpected-content-type)在第一次嘗試時失敗,因為重寫回應的閘道或代理會以相同方式重寫重試。需要 Claude Code v2.1.208 或更新版本。280* Claude Code 偵測到的連線在您的電腦進入睡眠狀態時在請求中途被中斷。Claude Code 將其計為上述規則下的連線中斷;一旦重試標籤命名了具體原因,它會讀作 `Connection lost while your computer was asleep`,如果回合在 Claude 完成思考但在任何文字或工具呼叫之前結束,訊息會讀作 `Your computer went to sleep before a response was produced`。
281* 停滯的回應串流,當回應標頭已到達但 Claude 回應的任何部分都未到達,或當 Claude 完成思考但尚未開始任何文字或工具呼叫時:Claude Code 會中止停滯的連線,並最多重新發出一次請求,不在上述 10 次嘗試預算內。如果在 Claude 完成思考但在任何文字或工具呼叫之前回應停滯第二次,Claude Code 會以 `The response stalled before a response was produced` 結束回合。
282* 串流請求 API 從未以回應標頭回答,在 [first-byte deadline 執行](/docs/zh-TW/network-config#streaming-idle-watchdogs) 的連線上:Claude Code 在截止時間中止它,並在重試預算內最多每個模型請求重新發送一次,然後如果該嘗試也未獲得回答,則以 [No response from API](#no-response-from-api) 結束回合。在其他連線上,請求會等待 `API_TIMEOUT_MS`。當您設定 `CLAUDE_CODE_RETRY_WATCHDOG` 時,一次重試上限不適用。
283* 暫時性 429 節流,但不是閘道的支出限制 `429`,這不是節流;請參閱 [Spend limit reached](#spend-limit-reached)。
284 * 當您使用 claude.ai 訂閱登入時,這包括不帶有您計畫配額標頭的 429 節流。在 v2.1.199 之前,Claude Code 僅針對 API 金鑰和企業登入重試這些節流。
285* 因為輸入加上 `max_tokens` 超過內容限制而被拒絕的請求。以相同方式重新發送它會以相同方式失敗,所以 Claude Code 會以縮減的 `max_tokens` 重試,並在兩種情況下停止重試並改為壓縮:
286 * 當沒有縮減可以適應時,例如當對話本身幾乎填滿內容視窗時。
287 * 當重試無法進一步縮減 `max_tokens` 時。在 v2.1.218 之前,Claude Code 可以重新發送仍然不適應的縮減請求,例如當擴展思考預算超過剩餘內容時,直到重試預算用盡。
288* 在 [Google Cloud 的 Agent Platform](/docs/zh-TW/google-vertex-ai) 上過期或遺失的 Google Cloud 認證,或在您的機器上無法載入的 AWS 認證。Claude Code 會捨棄其快取的認證並重試最多兩次,然後報告錯誤,以便您可以立即重新驗證,如 [Could not load AWS or Google Cloud credentials](#could-not-load-aws-or-google-cloud-credentials) 下所述。在 v2.1.228 之前,Claude Code 會透過完整重試預算重試失敗的 Google Cloud 認證,然後才顯示錯誤。
289* 來自 Anthropic API 的 `401` 或 `403`,直接或透過 [LLM gateway](/docs/zh-TW/llm-gateway),而 [`apiKeyHelper`](/docs/zh-TW/settings-reference#apikeyhelper) 指令碼提供認證。Claude Code 會重新執行指令碼並使用其新輸出重試,在完整重試預算內。當指令碼本身在重新執行時失敗時,Claude Code 會改為顯示 [Your apiKeyHelper script is failing](#your-apikeyhelper-script-is-failing)。
107 290
108重試時,微調器會在錯誤標籤後顯示 `Retrying in Ns · attempt x/y` 倒數計時。標籤命名第一次嘗試的特定原因,以便您可以立即採取行動的失敗:網路已關閉、TLS 握手失敗或您達到速率限制。對於其他錯誤,它最初讀取 `API error`。自 v2.1.198 起,它會切換到第三次嘗試的特定原因,或在 `CLAUDE_CODE_MAX_RETRIES` 允許少於三次時的最後一次嘗試;較早的版本僅在最後一次嘗試時切換。291在 v2.1.227 之前,`Connection lost before a response was produced` 讀作 `Connection closed while thinking, before producing a response`,`The response stalled before a response was produced` 讀作 `Response stalled while thinking, before producing a response`。
109 292
110自 v2.1.198 起,通常的微調器提示在重試期間被抑制。一旦錯誤原因被揭示,如果失敗是 529 過載,倒數計時下方的行也會命名檢查服務狀態的位置:Anthropic API 上的 `status.claude.com`,或其他配置上提供者或閘道主機命名的位置。293Claude Code 不會重試這些故障:
111 294
112如果在請求仍待處理時,回應串流上 20 秒內沒有資料到達,微調器會在任何重試開始之前顯示 `Waiting for API response · will retry in … · check your network`。請求尚未失敗:倒數計時會執行到 Claude Code 中止停滯連線並重試的位置,因此一旦資料恢復或重試成功,橫幅就會自動清除。自 v2.1.185 起,閾值為 20 秒;較早的版本會在 10 秒後顯示橫幅,措辭不同。如果它在每次嘗試時都重新出現,請將其視為[網路問題](#unable-to-connect-to-api)。295* TLS 憑證驗證失敗,例如 TLS 檢查代理、遺失的 `NODE_EXTRA_CA_CERTS` 套件,或過期的憑證。Claude Code 在第一次嘗試時報告錯誤,以便您可以立即修正憑證設定;請參閱 [SSL certificate errors](#ssl-certificate-errors)。Claude Code 仍會重試暫時性 TLS 條件,例如握手逾時。在 v2.1.199 之前,Claude Code 會透過完整重試預算重試憑證失敗,然後才顯示錯誤。
296* 伺服器錯誤、連線中斷,或停滯的串流在 Claude 完成文字區塊或工具呼叫之後到達,或在完成思考後開始一個但在完成回應之前。Claude Code 不會重新執行請求,因為這可能會執行相同的工具呼叫兩次。它會保留 Claude 完成的內容,執行 Claude 完成的任何工具呼叫,並從其結果繼續回合。關於您在互動式工作階段和非互動式工作階段中看到的內容,請閱讀 [The response above may be incomplete](#the-response-above-may-be-incomplete)。在 v2.1.199 之前,當伺服器錯誤在串流中途到達時,Claude Code 會捨棄部分輸出並將整個回合報告為錯誤。
297* 在 Claude 完成回應之後到達的故障:不需要重試任何內容,所以 Claude Code 會保留完整回應並正常結束回合。
298* [Amazon Bedrock 串流回應具有意外的 content-type](#bedrock-streaming-response-has-an-unexpected-content-type),因為重寫回應的閘道或代理會以相同方式重寫重試。需要 Claude Code v2.1.208 或更新版本。
299* 失敗的串流請求的非串流重試獲得成功狀態但 [body 中沒有 Claude API 訊息](#api-returned-an-empty-or-malformed-response)。Claude Code 以該錯誤結束回合。
300* 您的組織的原則檢查拒絕的請求,其表現為帶有拒絕訊息的 `API Error:` 行。您的組織管理員使用 [Inference hooks](https://platform.claude.com/docs/en/manage-claude/inference-hooks)(Claude 企業功能)設定檢查,訊息以他們設定的指示結尾,或預設告訴您聯絡他們。Claude Code 不會將被拒絕的請求重新發送到相同的模型或 [fallback model](/docs/zh-TW/model-config#fallback-model-chains),因為拒絕是關於請求的內容而不是模型。在 v2.1.239 之前,Claude Code 可以重新發送被拒絕的請求,不進行串流或在設定的後備模型上,然後才向您顯示拒絕。
113 301
114當您看到本頁上的其中一個錯誤時,這些重試已經用盡,除非它屬於不會重試的類別,例如憑證驗證失敗。您可以使用這些環境變數調整行為:302<h3 id="what-you-see-while-claude-code-retries-or-waits">
303 當 Claude Code 重試或等待時您看到的內容
304</h3>
305
306重試時,微調器在錯誤標籤後顯示 `Retrying in Ns · attempt x/y` 倒數計時。標籤命名第一次嘗試的具體原因,用於您可以立即採取行動的故障:網路已關閉、TLS 握手失敗,或您達到速率限制。對於其他錯誤,它最初讀作 `API error`。從 v2.1.198 開始,它會切換到第三次嘗試的具體原因,或當 `CLAUDE_CODE_MAX_RETRIES` 允許少於三次時在最後一次嘗試;較早的版本僅在最後一次嘗試時切換。
307
308從 v2.1.198 開始,在重試期間會隱藏通常的微調器提示。一旦錯誤原因被揭示,如果故障是 529 過載,倒數計時下方的行也會命名檢查服務狀態的位置:Anthropic API 上的 `status.claude.com`,或其他設定上的訊息中命名的提供者或閘道主機。
309
310如果在請求仍待處理時,回應串流上 20 秒內沒有資料到達,微調器會在任何重試開始之前顯示 `Waiting for API response · will retry in … · check your network`。請求尚未失敗:倒數計時執行到 Claude Code 中止停滯連線的點。中止後,您看到的內容取決於回應已進行的距離:
311
312* 在 Claude 完成文字區塊或工具呼叫之前,或在完成思考後開始一個,Claude Code 會重試請求或以錯誤結束回合。[Automatic retries](#automatic-retries) 說明它重試哪些停滯以及重試多少次。
313* 在 Claude 完成文字區塊或工具呼叫之後,或在完成思考後開始一個,但在 Claude 完成回應之前,Claude Code 會保留 Claude 完成的內容,從 Claude 完成的任何工具呼叫繼續回合,並顯示 [The response above may be incomplete](#the-response-above-may-be-incomplete)。在非互動式工作階段中,以及在任何工作階段中的子代理回應,Claude Code 可能會先提示 Claude 繼續回應;該項目說明何時執行以及何時您仍在那裡看到通知。
314* 在 Claude 完成回應之後,Claude Code 正常結束回合。
315
316一旦資料恢復或重試成功,橫幅會自動清除。如果它在每次嘗試時重新出現,請將其視為 [network issue](#unable-to-connect-to-api)。在 v2.1.185 之前,橫幅在 10 秒後出現,措辭不同。
317
318當 Claude 正在諮詢 [advisor](/docs/zh-TW/advisor) 時,橫幅在 90 秒無資料後出現,而不是 20 秒,因為長時間的顧問審查可以發送超過 20 秒的任何內容。在 v2.1.214 之前,20 秒的閾值也適用於顧問呼叫,所以橫幅在顧問審查期間出現,即使沒有任何問題。
319
320<h3 id="tune-retry-behavior">
321 調整重試行為
322</h3>
323
324您可以使用這些環境變數調整重試行為:
115 325
116| 變數 | 預設值 | 效果 |326| 變數 | 預設 | 效果 |
117| :---------------------------------------------- | :----- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |327| :------------------------------------------------------- | :----- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
118| [`CLAUDE_CODE_MAX_RETRIES`](/docs/zh-TW/env-vars) | 10 | 重試次數。自 v2.1.186 起上限為 15;自 v2.1.199 起 `CLAUDE_CODE_RETRY_WATCHDOG` 提高預設值並移除上限。降低它以在指令碼中更快地顯示失敗。 |328| [`CLAUDE_CODE_MAX_RETRIES`](/docs/zh-TW/env-vars) | 10 | 重試嘗試次數。從 v2.1.186 開始上限為 15;從 v2.1.199 開始 `CLAUDE_CODE_RETRY_WATCHDOG` 會提高預設值並移除上限。降低它以在指令碼中更快地顯示故障。 |
119| [`CLAUDE_CODE_RETRY_WATCHDOG`](/docs/zh-TW/env-vars) | 未設定 | 在 CI 工作等無人值守的工作階段中設定為 `1`,以無限期重試 `429` 和 `529` 容量錯誤,而不是在 `CLAUDE_CODE_MAX_RETRIES` 次嘗試後失敗。自 v2.1.199 起,它也提高了其他暫時性錯誤(例如伺服器錯誤、逾時和中斷的連線)的預設重試計數至 300,大約三小時的退避,並在您明確設定該變數時移除 `CLAUDE_CODE_MAX_RETRIES` 的上限 15。 |329| [`CLAUDE_CODE_RETRY_WATCHDOG`](/docs/zh-TW/env-vars) | 未設定 | 在無人值守的工作階段(例如 CI 工作)中設定為 `1`,以無限期重試 `429` 和 `529` 容量錯誤,而不是在 `CLAUDE_CODE_MAX_RETRIES` 嘗試後失敗。Claude Code 在報告支出限制或耗盡使用額度的 `429` 上立即失敗,即使是來自 [gateway spend cap](#spend-limit-reached) 的重新設定排程。在 v2.1.239 之前,看門狗無限期重試這些。在 v2.1.199 或更新版本上,它也會提高其他暫時性錯誤(例如伺服器錯誤、逾時和連線中斷)的預設重試計數至 300,大約三小時的退避,如果您明確設定該變數,則移除 `CLAUDE_CODE_MAX_RETRIES` 的上限 15。 |
120| [`API_TIMEOUT_MS`](/docs/zh-TW/env-vars) | 600000 | 每個請求的逾時(毫秒)。為慢速網路或代理提高它。 |330| [`API_TIMEOUT_MS`](/docs/zh-TW/env-vars) | 600000 | 每個請求的逾時(毫秒)。為慢速網路或代理提高它。它也會上限 Claude Code 等待回應標頭的時間,如 [No response from API](#no-response-from-api) 中所述。 |
331| [`CLAUDE_STREAM_FIRST_BYTE_TIMEOUT_MS`](/docs/zh-TW/env-vars) | 未設定 | 串流請求的第一個回應位元組的截止時間(毫秒)。需要 Claude Code v2.1.242 或更新版本。關於當此未設定時 Claude Code 如何選擇截止時間,請參閱 [No response from API](#no-response-from-api)。 |
121 332
122<h2 id="server-errors">333<h2 id="server-errors">
123 伺服器錯誤334 伺服器錯誤
124</h2>335</h2>
125 336
126這些錯誤來自推論提供者,而非您的帳戶或請求。在 Anthropic API 上,這表示 Anthropic 基礎設施。在 Amazon Bedrock、Google Cloud 的 Agent Platform、Microsoft Foundry 或自訂閘道上,這表示該提供者的基礎設施。337大多數這些錯誤來自推論提供者:Anthropic 在 Anthropic API 上的服務,以及該提供者在 Amazon Bedrock、Google Cloud 的 Agent Platform、Microsoft Foundry 或自訂閘道上的端點後面的服務。[Auto mode 無法判斷動作的安全性](#auto-mode-cannot-determine-the-safety-of-an-action)和[Agent 因 API 錯誤而提前終止](#agent-terminated-early-due-to-an-api-error)也涵蓋您這一方的原因,例如無法叫用分類器模型的 Amazon Bedrock 帳戶或達到使用限制的子代理。
127 338
128<h3 id="api-error-500-internal-server-error">339<h3 id="api-error-500-internal-server-error">
129 API 錯誤:500 內部伺服器錯誤340 API Error: 500 Internal server error
130</h3>341</h3>
131 342
132Claude Code 會顯示任何 5xx 回應的狀態碼和 API 的錯誤訊息。下面的範例顯示 Anthropic API 上的 500 回應:343Claude Code 會顯示任何 5xx 回應的狀態碼和 API 的錯誤訊息。下面的範例顯示 Anthropic API 上的 500 回應:
135API Error: 500 Internal server error. This is a server-side issue, usually temporary — try again in a moment. If it persists, check https://status.claude.com.346API Error: 500 Internal server error. This is a server-side issue, usually temporary — try again in a moment. If it persists, check https://status.claude.com.
136```347```
137 348
138結尾的句子會指出要檢查服務健康狀態的位置,並因提供者而異。Amazon Bedrock、Google Cloud 的 Agent Platform 和 Microsoft Foundry 配置會指出該提供者的服務狀態。自訂 `ANTHROPIC_BASE_URL` 會指出閘道主機。349尾部句子名稱檢查服務健康狀況的位置,並因提供者而異。Amazon Bedrock、Google Cloud 的 Agent Platform 和 Microsoft Foundry 設定會名稱該提供者的服務狀態。自訂 `ANTHROPIC_BASE_URL` 會名稱閘道主機。
139 350
140這表示 API 內部發生了意外故障。它不是由您的提示、設定或帳戶造成的。351這表示 API 內部發生意外故障。它不是由您的提示、設定或帳戶引起的。
141 352
142**該怎麼做:**353**該怎麼做:**
143 354
144* 檢查 [status.claude.com](https://status.claude.com) 或訊息中指名的提供者狀態頁面,查看是否有活躍的事件355* 檢查 [status.claude.com](https://status.claude.com) 或訊息中名稱的提供者狀態頁面,查看是否有活躍的事件
145* 等待一分鐘,然後再次傳送您的訊息。您的原始訊息仍在對話中,所以對於較長的提示,您可以輸入 `try again` 而不是貼上整個內容。356* 等待一分鐘,然後再次傳送您的訊息。您的原始訊息仍在對話中,因此對於較長的提示,您可以輸入 `try again` 而不是貼上整個內容。
146* 如果錯誤持續出現且沒有發佈的事件,請執行 `/feedback` 以便 Anthropic 可以使用您的請求詳細資訊進行調查。如果您的環境中無法使用 `/feedback`,請參閱[報告錯誤](#report-an-error)。357* 如果錯誤持續存在且沒有發佈的事件,請執行 `/feedback`,以便 Anthropic 可以使用您的請求詳細資訊進行調查。如果您的環境中無法使用 `/feedback`,請參閱[報告錯誤](#report-an-error)。
147 358
148<h3 id="api-error-repeated-529-overloaded-errors">359<h3 id="api-error-repeated-529-overloaded-errors">
149 API 錯誤:重複的 529 超載錯誤360 API Error: Repeated 529 Overloaded errors
150</h3>361</h3>
151 362
152API 在所有使用者中暫時達到容量上限。Claude Code 在顯示此訊息之前已經重試了多次:363API 在所有使用者中暫時達到容量。Claude Code 在顯示此訊息之前已經重試了多次:
153 364
154```text theme={null}365```text theme={null}
155API Error: Repeated 529 Overloaded errors. The API is at capacity — this is usually temporary. Try again in a moment. If it persists, check https://status.claude.com.366API Error: Repeated 529 Overloaded errors. The API is at capacity — this is usually temporary. Try again in a moment. If it persists, check https://status.claude.com.
156```367```
157 368
158結尾的句子因提供者而異,方式與上面的 500 錯誤相同。369尾部句子因提供者而異,方式與上面的 500 錯誤相同。
159 370
160529 不是您的使用限制,也不會計入您的配額。371529 不是您的使用限制,也不會計入您的配額。
161 372
162**該怎麼做:**373**該怎麼做:**
163 374
164* 檢查 [status.claude.com](https://status.claude.com) 或訊息中指名的提供者狀態頁面,查看是否有容量通知375* 檢查 [status.claude.com](https://status.claude.com) 或訊息中名稱的提供者狀態頁面,查看容量通知
165* 幾分鐘後再試一次376* 在幾分鐘後重試
166* 執行 `/model` 並切換到不同的模型以繼續工作,因為容量是按模型追蹤的。當某個模型負載特別高時,Claude Code 會提示您執行此操作,例如 `Opus is experiencing high load, please use /model to switch to Sonnet`。377* 執行 `/model` 並切換到不同的模型以繼續工作,因為容量是按模型追蹤的。Claude Code 會在一個模型負載特別高時提示您執行此操作,例如 `Opus is experiencing high load, please use /model to switch to Sonnet`。
167 378
168<h3 id="request-timed-out">379<h3 id="request-timed-out">
169 請求逾時380 Request timed out
170</h3>381</h3>
171 382
172API 在連線截止期限之前沒有回應。383API 在連線截止時間之前沒有回應。
173 384
174```text theme={null}385```text theme={null}
175Request timed out386Request timed out
181 392
182* 重試請求393* 重試請求
183* 對於長時間執行的任務,將工作分解為較小的提示394* 對於長時間執行的任務,將工作分解為較小的提示
184* 如果是緩慢的網路或代理造成的,請按照[自動重試](#automatic-retries)中的說明提高 `API_TIMEOUT_MS`395* 如果緩慢的網路或代理是原因,請按照[自動重試](#automatic-retries)中的說明提高 `API_TIMEOUT_MS`
185* 如果逾時頻繁且您的網路狀況良好,請參閱下面的[網路和連線錯誤](#network-and-connection-errors)396* 如果逾時頻繁且您的網路在其他方面狀況良好,請參閱下面的[網路和連線錯誤](#network-and-connection-errors)
397
398<h3 id="no-response-from-api">
399 No response from API
400</h3>
401
402Claude Code 傳送了串流請求,API 在第一個位元組的截止時間內沒有返回回應標頭,因此 Claude Code 中止了請求,而不是等待完整的 `API_TIMEOUT_MS` 請求逾時(預設為 10 分鐘)。Claude Code 最多再傳送一次請求,如果[重試預算](#tune-retry-behavior)允許的話。當重試也沒有得到回應時,該輪次以此訊息結束,該訊息顯示每次嘗試等待了多長時間。當您設定 [`CLAUDE_CODE_RETRY_WATCHDOG`](/docs/zh-TW/env-vars) 時,一次重試的上限不適用,Claude Code 會在[調整重試行為](#tune-retry-behavior)中描述的預算下重試。
403
404```text theme={null}
405API Error: No response from API (waited 3m, then 10m on the retry). If a proxy or gateway on your network holds responses until they complete, raise API_TIMEOUT_MS or CLAUDE_STREAM_FIRST_BYTE_TIMEOUT_MS to wait longer.
406```
407
408Claude Code 分別為第一次嘗試的等待回應標頭和重試的等待設定:
409
410* **第一次嘗試**:當您將其設定為 1 或更多時,[`CLAUDE_STREAM_FIRST_BYTE_TIMEOUT_MS`](/docs/zh-TW/env-vars),限制在 10 秒到 30 分鐘之間。否則 Claude Code 會使用[串流空閒監視程式](/docs/zh-TW/network-config#streaming-idle-watchdogs)中列出的位元組級監視程式逾時,因此改變該逾時的變數也會改變此等待。無論哪種方式,Claude Code 都會為請求正文的每 32KB 添加一秒。
411* **重試**:比 `API_TIMEOUT_MS` 少一秒,預設略低於 10 分鐘,以便重試可以超過保持回應直到生成完成的代理或閘道。在 Amazon Bedrock 上,重試使用與第一次嘗試相同的截止時間,訊息顯示一個持續時間而不是兩個。
412
413兩個等待都不超過正 `API_TIMEOUT_MS` 少一秒,正 `API_TIMEOUT_MS` 在 11 秒以下會關閉截止時間。位元組級監視程式僅在回應標頭到達後才開始,因此在此之後停止傳送位元組的回應遵循[停滯串流規則](#automatic-retries)而不是此截止時間。
414
415**該怎麼做:**
416
417* 再次傳送您的訊息。您的原始訊息仍在對話中,因此對於較長的提示,您可以輸入 `try again` 而不是貼上整個內容。
418* 如果重複出現,將其視為[網路或代理問題](#unable-to-connect-to-api)。接受連線但從不轉發請求的代理會在每次嘗試時產生此錯誤。
419* 如果您網路上的代理或閘道保持回應直到完成,請提高 `API_TIMEOUT_MS` 以便重試等待更長時間。在 Amazon Bedrock 上,也請提高 `CLAUDE_STREAM_FIRST_BYTE_TIMEOUT_MS`。
420* 如果第一次嘗試持續逾時,然後重試成功,請提高 `CLAUDE_STREAM_FIRST_BYTE_TIMEOUT_MS` 以便第一次嘗試也等待足夠長的時間。
421
422在 v2.1.242 之前,Claude Code 在未回應的串流請求失敗之前等待完整的 `API_TIMEOUT_MS` 請求逾時(預設為 10 分鐘)。在 v2.1.261 之前,重試等待與第一次嘗試相同的截止時間,訊息沒有顯示持續時間。
186 423
187<h3 id="the-response-above-may-be-incomplete">424<h3 id="the-response-above-may-be-incomplete">
188 上面的回應可能不完整425 The response above may be incomplete
189</h3>426</h3>
190 427
191串流回應在 Claude 已經產生可見輸出後失敗。重新傳送請求可能會執行相同的工具呼叫兩次,所以 Claude Code 會保留已經串流的內容,並改為附加此通知,而不是捨棄該輪次。您看到的變體會指出原因:428串流請求在回應仍在進行中時失敗,在 Claude 完成一個文字區塊或工具呼叫之後,或在完成思考後開始一個。重新傳送請求可能會執行相同的工具呼叫兩次,因此 Claude Code 會保留 Claude 完成的輸出並附加此通知,而不是丟棄該輪次。您看到的變體名稱原因:
192 429
193```text theme={null}430```text theme={null}
194API Error: Server error mid-response. The response above may be incomplete.431API Error: Server error mid-response. The response above may be incomplete.
195API Error: Connection closed mid-response. The response above may be incomplete.432API Error: Connection lost mid-response. The response above may be incomplete.
196API Error: Response stalled mid-stream. The response above may be incomplete.433API Error: Your computer went to sleep mid-response. The response above may be incomplete.
434API Error: The response stopped arriving. The response above may be incomplete.
197```435```
198 436
199* }`Server error mid-response`:中途串流超載或 5xx 伺服器錯誤。此變體需要 Claude Code v2.1.199 或更新版本;在此之前,該情況會捨棄部分輸出並將整個輪次報告為錯誤。437* `Server error mid-response`:中流過載或 5xx 伺服器錯誤。此變體需要 Claude Code v2.1.199 或更高版本;在此之前,該情況會丟棄部分輸出並將整個輪次報告為錯誤。
200* `Connection closed mid-response`:連線中斷。438* `Connection lost mid-response`:連線中斷。
201* `Response stalled mid-stream`:串流停止傳送資料。439* `Your computer went to sleep mid-response`:Claude Code 偵測到您的電腦在回應串流時進入睡眠狀態。一旦您的電腦喚醒,Claude Code 會將連線視為中斷並停止從中讀取。
440* `The response stopped arriving`:連線保持開啟但停止傳遞資料,因此串流空閒監視程式中止了它。在 v2.1.222 之前,Claude Code 也可能在通過 `ANTHROPIC_BASE_URL` 或 `ANTHROPIC_AWS_BASE_URL` 到達的[閘道](/docs/zh-TW/gateways)連線上報告此故障,同時伺服器的保活 ping 仍在到達,因為它只計算那裡解析的回應事件;升級會停止這些虛假逾時在這些路由上。通過提供者基礎 URL(例如 `ANTHROPIC_BEDROCK_BASE_URL`)到達的閘道不被位元組監視程式包裝;請參閱[串流空閒監視程式](/docs/zh-TW/network-config#streaming-idle-watchdogs)。
441
442在 v2.1.227 之前,`Connection lost mid-response` 讀作 `Connection closed mid-response`,`The response stopped arriving` 讀作 `Response stalled mid-stream`。
443
444在四種情況下,Claude Code 會在不立即顯示此通知的情況下處理故障:
445
446* 在回應的早期,Claude Code 要麼重試故障,要麼以不同的錯誤結束輪次。請參閱[自動重試](#automatic-retries)。
447* 當這些故障之一在 Claude 完成回應後到達時,Claude Code 會保留完整回應並正常結束輪次,沒有此通知。在 v2.1.222 之前,Claude Code 在連線中斷或在回應完成後停滯時顯示此通知,並將輪次報告為錯誤,儘管回應是完整的。
448* 在[非互動式工作階段](/docs/zh-TW/headless)中,例如 `-p` 執行、[Agent SDK](/docs/zh-TW/agent-sdk/overview) 執行或[雲端工作階段](/docs/zh-TW/claude-code-on-the-web),當截斷回應在主對話中且包含文字但沒有工具呼叫時,您不必自己傳送 `continue`:Claude Code 會保留部分輸出並提示 Claude 從停止的地方繼續,最多連續三次。您只有在 Claude Code 用完這些繼續後才會看到此通知。在 v2.1.246 之前,Claude Code 在第一次截斷時以此通知結束非互動式輪次。
449* 在[子代理](/docs/zh-TW/sub-agents#api-errors-in-subagents)中,無論工作階段是否互動:當其截斷回應包含文字但沒有工具呼叫時,Claude Code 會提示子代理繼續。通知僅在這些繼續用完後才成為子代理的最後一條訊息。在 v2.1.257 之前,子代理在第一次截斷時顯示此通知。
202 450
203**該怎麼做:**451**該怎麼做:**
204 452
205* 閱讀已串流的回應。沒有任何內容遺失,但最後的句子或工具呼叫可能缺失。453* 在互動式工作階段中,閱讀螢幕上保留的回應:Claude Code 保留 Claude 在錯誤之前完成的每個區塊,但在輪次結束時丟棄中斷的最後區塊,因此最後的句子或工具呼叫可能會遺失。回覆 `continue` 以讓 Claude 從其最後完成的區塊繼續。
206* 回覆 `continue` 以讓 Claude 從停止的地方繼續454* 在[非互動式模式](/docs/zh-TW/headless)(`-p`)中:
207* 如果相同的錯誤在任何可見輸出之前出現,Claude Code 會重試請求而不是完成它。請參閱[自動重試](#automatic-retries)。455 * 使用預設文字輸出,Claude Code 會列印它仍然從輪次早期保留的最後完成的文字區塊,然後是此訊息。當它沒有保留任何內容時,Claude Code 會單獨列印此訊息,例如因為 Claude Code 在輪次中間壓縮了對話並清除了該文字。在 v2.1.219 之前,Claude Code 在 `-p` 文字輸出中只列印此訊息並丟棄它已經產生的回應。
456 * 使用 `--output-format json` 或 `stream-json`,Claude Code 會在 `result` 欄位中報告此訊息。
457 * 一旦連線穩定,要繼續該輪次,請恢復工作階段並按照[繼續對話](/docs/zh-TW/headless#continue-conversations)中的說明傳送 `continue`。
208 458
209<h3 id="auto-mode-cannot-determine-the-safety-of-an-action">459<h3 id="auto-mode-cannot-determine-the-safety-of-an-action">
210 自動模式無法判斷動作的安全性460 Auto mode cannot determine the safety of an action
211</h3>461</h3>
212 462
213[自動模式](/docs/zh-TW/permission-modes#eliminate-prompts-with-auto-mode)用來分類動作的模型無法做出決定,所以自動模式沒有自動批准該動作。您看到的訊息取決於分類器失敗的原因。463[auto mode](/docs/zh-TW/permission-modes#eliminate-prompts-with-auto-mode) 使用的模型無法產生決定來分類動作,因此 auto mode 沒有自動批准該動作。您看到的訊息取決於分類器如何失敗。
214 464
215在您的工作目錄內的讀取、搜尋和編輯會跳過分類器,所以它們在所有這些情況下都能繼續工作。465讀取、搜尋和編輯您的工作目錄內的內容會跳過分類器,因此它們在所有這些情況下都能繼續工作。
216 466
217當分類器模型超載時:467當分類器模型不可用時:
218 468
219```text theme={null}469```text theme={null}
220<model> is temporarily unavailable, so auto mode cannot determine the safety of <tool> right now. Wait briefly and then try this action again.470<model> is temporarily unavailable, so auto mode cannot determine the safety of <tool> right now. Wait a moment and then try this action again.
221```471```
222 472
473當 Claude Code 可以判斷故障類別時,它會在 `temporarily unavailable` 後面的括號中名稱該類別,例如 `<model> is temporarily unavailable (rate-limited), so auto mode cannot determine the safety of <tool> right now`。類別為 `(rate-limited)`、`(overloaded)`、`(server error)`、`(timed out)` 和 `(connection failed)`。速率限制、過載和伺服器錯誤是暫時的,重試有效。如果 `(timed out)` 或 `(connection failed)` 重複,請檢查您的連線;請參閱[無法連線到 API](#unable-to-connect-to-api)。在 v2.1.229 之前,訊息從不名稱類別,讀作 `Wait briefly and then try this action again`。
474
475當沒有類別符合時,訊息出現時括號中沒有類別;多個故障會產生該形式。在 [Amazon Bedrock](/docs/zh-TW/amazon-bedrock) 上,包括 [Mantle 端點](/docs/zh-TW/amazon-bedrock#use-the-mantle-endpoint),當您的 AWS 帳戶無法叫用訊息中名稱的模型時,它也會出現,該故障在每次重試時重複,直到您的帳戶被授予存取該模型的權限。
476
223**該怎麼做:**477**該怎麼做:**
224 478
225* 幾秒鐘後重試;Claude 會看到相同的訊息,通常會自動重試479* 在幾秒後重試;Claude 會看到相同的訊息,通常會自動重試。暫時故障與 [auto mode 資格](/docs/zh-TW/permission-modes#eliminate-prompts-with-auto-mode)無關;您不需要變更設定
226* 如果重試持續失敗,請繼續執行唯讀任務,稍後再回到被阻止的動作480* 如果重試持續失敗,請繼續進行唯讀任務,稍後再回到被阻止的動作
227* 這是暫時的,與[自動模式資格](/docs/zh-TW/permission-modes#eliminate-prompts-with-auto-mode)無關;您不需要變更設定481* 在 Amazon Bedrock 上,如果訊息在每次重試時返回,請檢查您的帳戶是否可以叫用它名稱的模型:對於標準 Amazon Bedrock 模型,確認您的 [IAM 政策](/docs/zh-TW/amazon-bedrock#iam-configuration)允許叫用它;對於 Mantle 模型 ID,[聯絡您的 AWS 帳戶團隊](/docs/zh-TW/amazon-bedrock#mantle-endpoint-errors)
228 482
229當分類器傳回無法解析的回應時:483當分類器請求失敗是因為您的 OAuth 令牌過期或被另一個工作階段輪換時,Claude Code 會重新整理令牌並重試請求一次,因此例行令牌過期不會作為此訊息出現。在 v2.1.216 之前,過期或輪換的令牌會導致每個分類器請求失敗,auto mode 會以此訊息拒絕每個檢查的動作,直到令牌被重新整理。
484
485當分類器返回無法解析的回應時:
230 486
231```text theme={null}487```text theme={null}
232Auto mode could not evaluate this action and is blocking it for safety — run with --debug for details488Auto mode could not evaluate this action and is blocking it for safety — run with --debug for details
237* 重試該動作;這通常在下一次嘗試時成功493* 重試該動作;這通常在下一次嘗試時成功
238* 執行 `claude --debug` 並重複該動作以在偵錯日誌中查看基礎分類器回應494* 執行 `claude --debug` 並重複該動作以在偵錯日誌中查看基礎分類器回應
239 495
240當單獨的 API 安全檢查因為較早的對話內容而阻止了分類器請求時:496當單獨的 API 安全檢查因為早期對話內容而阻止分類器請求時:
241 497
242```text theme={null}498```text theme={null}
243Auto mode could not evaluate this action and is blocking it for safety — a safety check separate from auto mode blocked this request because of earlier conversation content — it isn't about the action itself — run with --debug for details499Auto mode could not evaluate this action and is blocking it for safety — a safety check separate from auto mode blocked this request because of earlier conversation content — it isn't about the action itself — run with --debug for details
244```500```
245 501
502Claude Code 拒絕該動作,但告訴 Claude 這不是對該動作不安全的判斷,並繼續進行其他任務而不是重試。這些拒絕不計入 [auto mode 的暫停閾值](/docs/zh-TW/permission-modes#when-auto-mode-falls-back)。在[非互動式](/docs/zh-TW/headless) `-p` 執行中,Claude Code 不會停止執行。Claude 接收的內容取決於它在哪裡請求該動作:
503
504* 對於 `-p` 執行中沒有 `--input-format stream-json` 的[背景子代理](/docs/zh-TW/sub-agents#run-subagents-in-foreground-or-background),Claude Code 會返回包含 `Agent aborted: auto mode classifier request refused by the safety safeguard in headless mode` 的錯誤結果
505* 在其他地方,包括互動式工作階段和 `-p` 執行的主對話,Claude Code 會將該拒絕返回給 Claude
506
507在 v2.1.225 之前,Claude Code 計算這些拒絕以達到暫停閾值,並返回與真正分類器區塊相同的拒絕訊息。
508
246**該怎麼做:**509**該怎麼做:**
247 510
248* 這不是關於您的動作的決定。您對話中已有的內容在自動模式將對話傳送給分類器時觸發了 API 上的安全篩選器511* 這不是對您的動作的決定。您對話中已有的內容在 auto mode 將對話傳送給分類器時觸發了 API 上的安全篩選器
249* 重試無法幫助;相同的對話內容會再次觸發篩選器512* 重試無法幫助;相同的對話內容將再次觸發篩選器
250* 切換到不同的[權限模式](/docs/zh-TW/permission-modes),以便在出現提示時批准該動作,或開始一個沒有觸發內容的新對話513* 在互動式工作階段中,切換到不同的[權限模式](/docs/zh-TW/permission-modes),以便您可以在提示時批准該動作
514* 開始一個新的對話,不包含觸發內容
251 515
252當對話大小超過分類器的上下文視窗時:516當對話增長超過分類器的上下文視窗時:
253 517
254```text theme={null}518```text theme={null}
255Auto mode classifier transcript exceeded context window — falling back to manual approval (try /compact to reduce conversation size)519Auto mode classifier transcript exceeded context window — falling back to manual approval (try /compact to reduce conversation size)
256```520```
257 521
258在互動式工作階段中,自動模式會為該動作回退到正常的權限提示,以便您可以手動批准或拒絕它。在[非互動式模式](/docs/zh-TW/headless)中,執行會中止,因為文字記錄只會增長,重試無法成功。522動作發生的情況取決於 Claude 在哪裡請求它:
523
524* 在互動式工作階段中,auto mode 會回退到該動作的正常權限提示,以便您可以手動批准或拒絕它
525* 對於 [非互動式](/docs/zh-TW/headless) `-p` 執行中沒有 `--input-format stream-json` 的[背景子代理](/docs/zh-TW/sub-agents#run-subagents-in-foreground-or-background),Claude Code 會返回包含 `Agent aborted: auto mode classifier transcript exceeded context window in headless mode` 的錯誤結果,執行繼續
526* 在 `-p` 執行中的其他地方,沒有 [`--permission-prompt-tool`](/docs/zh-TW/cli-reference#cli-flags),沒有提示可以回退到,因此動作不執行,執行繼續
259 527
260**該怎麼做:**528**該怎麼做:**
261 529
262* 在出現的提示中批准或拒絕該動作530* 在互動式工作階段中,在出現的提示中批准或拒絕該動作
263* 執行 `/compact` 以減少對話大小,以便後續動作再次適應分類器視窗531* 在互動式工作階段中,執行 `/compact` 以減少對話大小,以便後續動作再次適應分類器視窗
264 532
265<h3 id="agent-terminated-early-due-to-an-api-error">533<h3 id="agent-terminated-early-due-to-an-api-error">
266 代理因 API 錯誤而提前終止534 Agent terminated early due to an API error
267</h3>535</h3>
268 536
269[子代理](/docs/zh-TW/sub-agents)的 API 請求終止失敗,例如因為達到使用限制或伺服器錯誤的重試用盡,所以子代理在完成其任務之前停止。此訊息需要 Claude Code v2.1.199 或更新版本;在此之前,API 錯誤文字被傳回給 Claude,就像它是子代理的結果一樣。537[子代理](/docs/zh-TW/sub-agents)的 API 請求終止失敗,例如因為達到使用限制或伺服器錯誤的重試用完,所以子代理在完成其任務之前停止。此訊息需要 Claude Code v2.1.199 或更高版本;在此之前,API 錯誤文字被返回給 Claude,就像它是子代理的結果一樣。
270 538
271```text theme={null}539```text theme={null}
272Agent terminated early due to an API error: <error detail>540Agent terminated early due to an API error: <error detail>
274 542
275**該怎麼做:**543**該怎麼做:**
276 544
277* 將冒號後的錯誤詳細資訊與此頁面上的自己的部分相符,例如[使用限制](#usage-limits)或[伺服器錯誤](#server-errors),並遵循該部分的步驟545* 將冒號後的錯誤詳細資訊與此頁面上的其自己的部分相符,例如[使用限制](#usage-limits)或[伺服器錯誤](#server-errors),並遵循該部分的步驟
278* 一旦基礎錯誤清除,請要求 Claude 重試任務或[恢復子代理](/docs/zh-TW/sub-agents#resume-subagents)546* 一旦基礎錯誤清除,請要求 Claude 重試任務或[恢復子代理](/docs/zh-TW/sub-agents#resume-subagents)
279 547
280當速率限制、超載或伺服器錯誤中斷已經產生文字輸出的前景子代理時,Claude 會收到該部分輸出標記為不完整,而不是此錯誤。只有工具呼叫輸出的子代理也會收到此錯誤;在 v2.1.199 中,該形狀改為傳回空的部分結果。請參閱[子代理中的 API 錯誤](/docs/zh-TW/sub-agents#api-errors-in-subagents)。548當速率限制、過載或伺服器錯誤中斷已經產生文字輸出的前景子代理時,Claude 會收到該部分輸出標記為不完整,而不是此錯誤。其唯一輸出是工具呼叫的子代理也會收到此錯誤;在 v2.1.199 中,該形狀返回了空部分結果。請參閱[子代理中的 API 錯誤](/docs/zh-TW/sub-agents#api-errors-in-subagents)。
281 549
282<h2 id="usage-limits">550<h2 id="usage-limits">
283 使用限制551 使用限制
284</h2>552</h2>
285 553
286這些錯誤表示與您的帳戶或方案相關的配額已達到。它們與[伺服器錯誤](#server-errors)不同,伺服器錯誤會影響所有人。554本節中的大多數錯誤表示與您的帳戶或方案相關的配額已達到。其中三個的運作方式不同:[`伺服器暫時限制請求`](#server-is-temporarily-limiting-requests) 是與您的方案配額無關的伺服器端節流,[`1M 上下文需要使用額度`](#usage-credits-required-for-1m-context) 是權利檢查而非耗盡的配額,[`確認提示未獲回應`](#the-prompt-to-confirm-went-unanswered) 表示使用額度同意提示已關閉且未獲回應,無論是否達到配額。
287 555
288<h3 id="youve-hit-your-session-limit">556<h3 id="youve-hit-your-session-limit">
289 您已達到工作階段限制557 您已達到工作階段限制
295You've hit your session limit · resets 3:45pm563You've hit your session limit · resets 3:45pm
296You've hit your weekly limit · resets Mon 12:00am564You've hit your weekly limit · resets Mon 12:00am
297You've hit your Opus limit · resets 3:45pm565You've hit your Opus limit · resets 3:45pm
566You've hit your Sonnet limit · resets 3:45pm
298```567```
299 568
300Claude Code 會阻止進一步的請求,直到訊息中顯示的重設時間。工作階段和每週限制在所有模型中共享,因此切換模型不會恢復存取。Opus 限制僅適用於 Opus 請求,因此使用 `/model` 切換到另一個模型可讓您繼續工作。569Claude Code 會阻止進一步的請求,直到訊息中顯示的重設時間。工作階段和每週限制在所有模型中共享,因此切換模型不會恢復存取。Opus 和 Sonnet 限制各自僅適用於對該模型系列的請求,因此使用 `/model` 切換到該系列外的模型可讓您繼續工作。
570
571在使用 claude.ai 訂閱登入的互動式工作階段中,Claude Code 也可以在開啟的工作階段中等待,並在重設後不久繼續中斷的任務。等待時,工作階段底部的一行會顯示 `Usage limit reached · continuing automatically at 3:45pm · esc to cancel`。在空提示處按 `Esc` 可取消等待。請參閱[等待使用限制重設](/docs/zh-TW/interactive-mode#wait-for-a-usage-limit-to-reset)以了解您看到的內容、如何開始或取消等待,以及如何關閉自動繼續。在 v2.1.234 之前,Claude Code 不提供此等待功能。
301 572
302使用額度會同時計入工作階段和每週額度。單一次的大量活動突發,例如大型工作流程扇出,可能會在工作階段視窗重設之前耗盡每週額度。573使用量同時計入工作階段和每週額度。單次大量活動突發(例如大型工作流程扇出)可能會在工作階段視窗重設之前耗盡每週額度。
303 574
304**該怎麼做:**575**該怎麼做:**
305 576
306* 等待錯誤訊息中顯示的重設時間577* 等待錯誤中顯示的重設時間
307* 對於 Opus 限制,執行 `/model` 並切換到另一個模型以繼續工作578* 在[桌面應用程式](/docs/zh-TW/desktop)的 Code 標籤中,工作階段限制卡片提供**達到限制時自動繼續**核取方塊。每週限制卡片則不提供。勾選後,桌面應用程式會在重設後重試中斷的回合,並在卡片上顯示重試時間。桌面核取方塊和 CLI 在 `/config` 中的**達到使用限制時自動繼續**設定是分開的,因此請分別關閉每一個。
308* 執行 `/usage` 以查看您的方案限制及其重設時間579* 對於 Opus 或 Sonnet 限制,執行 `/model` 並切換到該系列外的模型以繼續工作。每個模型都有自己的提示快取,因此下一個請求會重新讀取整個對話,沒有快取命中;請參閱[切換模型](/docs/zh-TW/prompt-caching#switching-models)
309* 執行 `/usage-credits` 以在 Pro 和 Max 上購買額外使用額度,或在 Team 和 Enterprise 上向您的管理員請求。請參閱[付費方案的使用額度](https://support.claude.com/en/articles/12429409-extra-usage-for-paid-claude-plans)以了解如何計費。580* 執行 `/usage` 以查看您的方案限制和重設時間
581* 執行 `/usage-credits` 以在 Pro 和 Max 上購買額外使用量,或在 Team 和 Enterprise 上向您的管理員請求。請參閱[付費方案的使用額度](https://support.claude.com/en/articles/12429409-extra-usage-for-paid-claude-plans)以了解如何計費。
310* 若要升級您的方案以獲得更高的基本限制,請參閱 [claude.com/pricing](https://claude.com/pricing)582* 若要升級您的方案以獲得更高的基本限制,請參閱 [claude.com/pricing](https://claude.com/pricing)
311 583
312若要在達到限制之前監控您的剩餘額度,請將 `rate_limits` 欄位新增至[自訂狀態列](/docs/zh-TW/statusline#rate-limit-usage),或在桌面應用程式中按一下模型選擇器旁的[使用量環](/docs/zh-TW/desktop#check-usage)。584若要在達到限制之前監視您的剩餘額度,請將 `rate_limits` 欄位新增至[自訂狀態行](/docs/zh-TW/statusline#rate-limit-usage),或在桌面應用程式中按一下模型選擇器旁的[使用量環](/docs/zh-TW/desktop#check-usage)。
313 585
314<h3 id="usage-credits-required-for-1m-context">586<h3 id="usage-credits-required-for-1m-context">
315 1M 上下文需要使用額度587 1M 上下文需要使用額度
316</h3>588</h3>
317 589
318選定的模型使用 1M 令牌擴展上下文視窗,而您的方案僅透過使用額度包含它。590選定的模型使用 1M 權杖擴展上下文視窗,而您的方案僅透過使用額度包括它。
319 591
320```text theme={null}592```text theme={null}
321API Error: Usage credits required for 1M context · run /usage-credits to turn them on, or /model to switch to standard context593API Error: Usage credits required for 1M context · run /usage-credits to turn them on, or /model to switch to standard context
322```594```
323 595
324這是一項權利檢查,而不是配額耗盡。即使您的工作階段和每週額度仍有容量,它也會觸發。請參閱[擴展上下文](/docs/zh-TW/model-config#extended-context)以了解哪些方案直接包含 1M 上下文,哪些需要使用額度。596這是權利檢查,而非配額耗盡。即使您的工作階段和每週額度有剩餘容量,它也會觸發。請參閱[擴展上下文](/docs/zh-TW/model-config#extended-context)以了解哪些方案直接包括 1M 上下文,哪些需要使用額度。Claude Code 在您使用 `/model` 選擇模型時執行此檢查,且僅在直接連接到 Anthropic API 時執行;如果您將 `ANTHROPIC_BASE_URL` 指向[LLM 閘道](/docs/zh-TW/llm-gateway),`/model` 允許 `[1m]` 選擇,閘道決定請求是否成功。
325 597
326當此錯誤在對話中途出現,因為上下文增長超過 200K 令牌時,Claude Code 會自動將對話壓縮回標準上下文限制以下,並在之後將工作階段保持在該限制,因此無需採取任何行動。在 v2.1.172 之前的版本上,錯誤會在每個後續請求(包括 `/compact`)上重複出現;在這些版本上執行 `/clear` 以恢復。以下步驟適用於您明確選擇 `[1m]` 模型的情況。598當此錯誤在對話中期出現,因為上下文增長超過 200K 權杖時,Claude Code 會自動將對話壓縮回標準上下文限制以下,並之後將工作階段保持在該限制,因此無需採取任何行動。在 v2.1.172 之前的版本上,錯誤會在每個後續請求(包括 `/compact`)上重複;在這些版本上執行 `/clear` 以恢復。以下步驟適用於您明確選擇 `[1m]` 模型的情況。
327 599
328**該怎麼做:**600**該怎麼做:**
329 601
330* 執行 `/model` 並選擇不帶 `[1m]` 後綴的變體以回退到標準上下文視窗602* 執行 `/model` 並選擇不帶 `[1m]` 後綴的變體以回退到標準上下文視窗
331* 執行 `/usage-credits` 以在 Pro 和 Max 上開啟 1M 變體的計量計費,或在 Team 和 Enterprise 上向您的管理員請求603* 訊息提及 `/usage-credits` 的地方,執行它以在 Pro 和 Max 上為 1M 變體開啟計量計費,或在 Team 和 Enterprise 上向您的管理員請求使用額度
332* 如果 `/model` 後錯誤仍然存在,1M 模型 ID 可能在其他地方設定。請參閱[選定的模型有問題](#theres-an-issue-with-the-selected-model)以按優先順序檢查配置位置。604* 如果 `/model` 後錯誤仍然存在,1M 模型 ID 可能在其他地方設定。請參閱[設定您的模型](/docs/zh-TW/model-config#setting-your-model)以按優先順序檢查設定位置。
333* 若要從模型選擇器中完全移除 1M 變體,請設定 [`CLAUDE_CODE_DISABLE_1M_CONTEXT=1`](/docs/zh-TW/env-vars)605* 若要從模型選擇器中完全移除 1M 變體,請設定 [`CLAUDE_CODE_DISABLE_1M_CONTEXT=1`](/docs/zh-TW/env-vars)
334 606
607<h3 id="the-prompt-to-confirm-went-unanswered">
608 確認提示未獲回應
609</h3>
610
611如果您的帳戶需要 [Fable 使用額度同意](/docs/zh-TW/model-config#fable-and-usage-credits),Claude Code 會要求您在 Fable 請求計費使用額度之前確認。當沒有人在可能沒有人在其終端的工作階段中回應該同意提示時,Claude Code 會關閉提示並以以下其中一條訊息結束回合:
612
613```text theme={null}
614Fable limit reached · continuing on Fable 5.1 uses usage credits, and the prompt to confirm went unanswered — nothing was sent · answer it where this session is running, or /model to change
615Fable 5.1 now uses usage credits · the prompt to confirm went unanswered — nothing was sent · answer it where this session is running, or /model to change
616```
617
618訊息會命名工作階段的 Fable 模型,因此在 Fable 5 上它們會讀作 `continuing on Fable 5` 和 `Fable 5 now uses usage credits`。在 v2.1.257 之前,第一條訊息以 `Fable 5 limit reached` 開頭。
619
620這發生在[遠端控制](/docs/zh-TW/remote-control)工作階段、[背景工作階段](/docs/zh-TW/agent-view)和[代理團隊](/docs/zh-TW/agent-teams)隊友工作階段中。Claude Code 僅在工作階段自己的互動式檢視中顯示同意提示:執行它的終端,或對於背景工作階段,一旦您附加,[代理檢視](/docs/zh-TW/agent-view)。遠端控制用戶端無法顯示它。Claude Code 在 [`dialogExpiry`](/docs/zh-TW/settings-reference#dialogexpiry) 截止時間(預設為五分鐘)關閉提示,或在沒有人在該終端輸入時立即有新提示到達,例如從遠端控制用戶端發送的提示。在執行工作階段的終端輸入會取消截止時間,Claude Code 會等待您的回答。在附加的背景工作階段檢視中,輸入不會取消截止時間,新提示仍會關閉同意提示,因此請在任一情況發生之前回答。Claude Code 不發送任何內容並保持您的模型,因此當您發送下一個提示時,Claude Code 會再次顯示同意提示。
621
622**該怎麼做:**
623
624* 在執行工作階段的終端,發送另一個提示,當同意提示重新出現時回答它。對於背景工作階段,請先從[代理檢視](/docs/zh-TW/agent-view)附加到它。從遠端控制用戶端重新發送會再次顯示此訊息,因為用戶端無法顯示提示。
625* 執行 `/model` 以切換到不計費使用額度的模型
626* 若要給自己更多時間到達該終端,請將 [`dialogExpiry`](/docs/zh-TW/settings-reference#dialogexpiry) 設定為更長的值或 `"never"`
627
628在 v2.1.236 之前,此訊息不會出現:當遠端控制用戶端已連接時,Claude Code 會等待 60 秒以獲得答案,然後在您的預設模型上繼續回合。
629
335<h3 id="server-is-temporarily-limiting-requests">630<h3 id="server-is-temporarily-limiting-requests">
336 伺服器暫時限制請求631 伺服器暫時限制請求
337</h3>632</h3>
342API Error: Server is temporarily limiting requests (not your usage limit)637API Error: Server is temporarily limiting requests (not your usage limit)
343```638```
344 639
345Claude Code 透過真實限制回應所攜帶的統一配額標頭的缺失來區分這些與您的方案限制。自 v2.1.199 起,無論您如何驗證,這都會[自動重試](#automatic-retries)並進行退避,然後才會顯示。在較早的版本上,使用 claude.ai 訂閱登入的工作階段在第一次出現時失敗;只有 API 金鑰和 Enterprise 登入會重試它。640Claude Code 通過真實限制回應所攜帶的統一配額標頭的缺失來區分這些。自 v2.1.199 起,無論您如何驗證,這都會[自動重試](#automatic-retries)並進行退避,然後才顯示。在較早的版本上,使用 claude.ai 訂閱登入的工作階段在第一次出現時失敗回合;只有 API 金鑰和 Enterprise 登入重試它。
346 641
347**該怎麼做:**642**該怎麼做:**
348 643
353 請求被拒絕 (429)648 請求被拒絕 (429)
354</h3>649</h3>
355 650
356您已達到為 API 金鑰、Amazon Bedrock 專案或 Google Cloud 專案配置的速率限制。651您已達到為您的 API 金鑰、Amazon Bedrock 專案或 Google Cloud 專案設定的速率限制。
357 652
358```text theme={null}653```text theme={null}
359API Error: Request rejected (429) · this may be a temporary capacity issue. If it persists, check https://status.claude.com.654API Error: Request rejected (429) · this may be a temporary capacity issue. If it persists, check https://status.claude.com.
360```655```
361 656
362尾部句子命名檢查服務健康狀況的位置,並因提供者而異。Amazon Bedrock、Google Cloud 的 Agent Platform 和 Microsoft Foundry 配置會命名該提供者的服務狀態,而不是 Anthropic 狀態頁面。自訂 `ANTHROPIC_BASE_URL` 會命名閘道主機。657尾部句子命名檢查服務健康狀況的位置,並因提供者而異。Amazon Bedrock、Google Cloud 的 Agent Platform 和 Microsoft Foundry 設定會命名該提供者的服務狀態,而不是 Anthropic 狀態頁面。自訂 `ANTHROPIC_BASE_URL` 會命名閘道主機。
363 658
364**該怎麼做:**659**該怎麼做:**
365 660
366* 執行 `/status` 並確認作用中的認證是您預期的認證。環境中的流浪 `ANTHROPIC_API_KEY` 可能會透過低階金鑰而不是您的訂閱來路由請求。661* 執行 `/status` 並確認作用中的認證是您預期的認證。環境中的流浪 `ANTHROPIC_API_KEY` 可能會透過低階金鑰而不是您的訂閱路由請求。
367* 檢查您的提供者主控台以了解作用中的限制,並在需要時請求更高的層級662* 檢查您的提供者主控台以了解作用中的限制,並在需要時請求更高的層級
368* 對於 Anthropic API 金鑰,請參閱[速率限制參考](https://platform.claude.com/docs/en/api/rate-limits)以了解層級如何運作以及如何設定每個工作區的上限663* 對於 Anthropic API 金鑰,請參閱[速率限制參考](https://platform.claude.com/docs/en/api/rate-limits)以了解層級如何運作以及如何設定每個工作區的上限
369* 降低並行性:降低 [`CLAUDE_CODE_MAX_TOOL_USE_CONCURRENCY`](/docs/zh-TW/env-vars)、避免執行許多平行子代理,或使用 `/model` 切換到較小的模型以進行大量指令碼執行664* 降低並行性:降低 [`CLAUDE_CODE_MAX_TOOL_USE_CONCURRENCY`](/docs/zh-TW/env-vars)、避免執行許多平行子代理,或使用 `/model` 切換到較小的模型以進行高容量指令碼執行
665
666<h3 id="spend-limit-reached">
667 已達到支出限制
668</h3>
669
670您透過[Claude 應用程式閘道](/docs/zh-TW/claude-apps-gateway)連接,並已超過閘道運營商設定的[支出上限](/docs/zh-TW/claude-apps-gateway-spend-limits)。閘道會阻止您的請求,直到命名的期間重設或運營商提高上限。它將每個被阻止的 `429` 回應標記為 `x-should-retry: false`,因此 Claude Code 會顯示此訊息而不重試。
671
672```text theme={null}
673spend limit reached (daily; resets 2026-08-09 00:00 UTC)
674```
675
676訊息會命名上限的期間和重設時間,當運營商設定了 `blocked_message` 時,他們的指示會跟在它後面。在 v2.1.225 之前,訊息只讀 `spend limit reached`;較舊版本上的閘道仍會發送該較短的形式。
677
678**該怎麼做:**
679
680* 等待訊息命名的重設時間,或如果訊息包含運營商的指示,請遵循它們
681* 如果您經常達到上限,請要求您的閘道運營商提高上限
682
683相關訊息 `spend limit unavailable` 表示閘道無法讀取其支出記錄,並作為預防措施而不是超過您的上限而阻止了請求。它通常會自行清除;如果它持續,請告訴您的閘道運營商。
370 684
371<h3 id="credit-balance-is-too-low">685<h3 id="credit-balance-is-too-low">
372 信用額度餘額過低686 信用額度餘額過低
373</h3>687</h3>
374 688
375您的 Console 組織已用完預付信用額度。689您的 Console 組織已用完預付額度,或 Claude Code 正在使用 Console API 金鑰發送您的請求,而您打算使用您的訂閱。
376 690
377```text theme={null}691```text theme={null}
378Credit balance is too low692Credit balance is too low
380 694
381**該怎麼做:**695**該怎麼做:**
382 696
383* 在 [platform.claude.com/settings/billing](https://platform.claude.com/settings/billing) 新增信用額度,並考慮在那裡啟用自動重新載入,以便在餘額達到零之前進行補充697* 如果您有 Pro、Max、Team 或 Enterprise 方案並看到此訊息,執行 `/status` 並檢查 `API key` 列。環境中已核准的 `ANTHROPIC_API_KEY` 會透過該金鑰而不是您的訂閱路由請求。在目前的 shell 中取消設定它,並從您的 shell 設定檔中移除它,然後重新啟動 `claude`。如果您還沒有使用您的訂閱登入,請執行 `/login`。
384* 如果您有 Pro、Max、Team 或 Enterprise 方案,請使用 `/login` 切換到訂閱驗證698* 在 [platform.claude.com/settings/billing](https://platform.claude.com/settings/billing) 新增額度,並考慮在那裡啟用自動重新載入,以便在餘額達到零之前重新填充
385* 在 Console 中設定每個工作區的支出上限,以防止單一專案耗盡組織餘額。請參閱[有效管理成本](/docs/zh-TW/costs)。699* 在 Console 中設定每個工作區的支出上限,以防止單個專案耗盡組織餘額。請參閱[有效管理成本](/docs/zh-TW/costs)。
700
701<h3 id="could-not-update-your-spend-limit">
702 無法更新您的支出限制
703</h3>
704
705伺服器拒絕了您從達到支出限制時出現的提示中進行的支出限制變更。
706
707```text theme={null}
708Could not update your spend limit: <reason from the server>
709```
710
711當伺服器解釋拒絕時,訊息以該原因結尾,重試相同值會再次失敗。當失敗沒有伺服器提供的原因(例如連接中斷)時,訊息會讀作 `Could not update your spend limit. Press Enter to retry.`,重試可能會成功。在 v2.1.216 之前,Claude Code 為每個失敗顯示通用形式。
712
713**該怎麼做:**
714
715* 如果訊息包含原因,請選擇滿足它的限制,例如較低的金額
716* 如果訊息僅顯示通用形式,請重試;失敗可能是暫時的
717* 如果變更持續失敗,請改為在瀏覽器中從您的 [claude.ai 計費設定](https://support.claude.com/en/articles/12429409-extra-usage-for-paid-claude-plans)進行變更
386 718
387<h2 id="authentication-errors">719<h2 id="authentication-errors">
388 驗證錯誤720 驗證錯誤
389</h2>721</h2>
390 722
391這些錯誤表示 Claude Code 無法向 API 證明您的身份。隨時執行 `/status` 以查看目前使用的認證方式。723這些錯誤表示 Claude Code 無法向 API 證明您的身份。隨時執行 `/status` 以查看目前哪個認證資格處於活動狀態。
392 724
393<h3 id="not-logged-in">725<h3 id="not-logged-in">
394 未登入726 未登入
395</h3>727</h3>
396 728
397此工作階段沒有有效的認證方式可用。729此工作階段沒有有效的認證資格可用。
398 730
399```text theme={null}731```text theme={null}
400Not logged in · Please run /login732Not logged in · Please run /login
401```733```
402 734
403**應該怎麼做:**735**該怎麼做:**
404 736
405* 執行 `/login` 以使用您的 Claude 訂閱或 Console 帳戶進行驗證737* 執行 `/login` 以使用您的 Claude 訂閱或 Console 帳戶進行驗證
406* 如果您預期使用環境變數進行驗證,請確認 `ANTHROPIC_API_KEY` 已在啟動 `claude` 的 shell 中設定並匯出738* 如果您預期環境變數會驗證您,請確認 `ANTHROPIC_API_KEY` 已在啟動 `claude` 的 shell 中設定並匯出
407* 對於無法進行互動式登入的 CI 或自動化環境,請設定一個 [`apiKeyHelper`](/docs/zh-TW/settings#available-settings) 指令碼,在啟動時取得金鑰739* 對於無法進行互動式登入的 CI 或自動化,請設定一個 [`apiKeyHelper`](/docs/zh-TW/settings-reference#apikeyhelper) 指令碼,在啟動時擷取金鑰
408* 請參閱[驗證優先順序](/docs/zh-TW/authentication#authentication-precedence)以了解當存在多個認證方式時,Claude Code 使用哪一個740* 請參閱[驗證優先順序](/docs/zh-TW/authentication#authentication-precedence)以瞭解當存在多個認證資格時 Claude Code 使用哪一個
409 741
410如果系統反覆提示您登入,請參閱[未登入或權杖已過期](/docs/zh-TW/troubleshoot-install#not-logged-in-or-token-expired)以取得系統時鐘和 macOS Keychain 的修復方法。742如果系統反覆提示您登入,請參閱[未登入或權杖已過期](/docs/zh-TW/troubleshoot-install#not-logged-in-or-token-expired)以取得系統時鐘檢查和 macOS 認證儲存復原步驟。
411 743
412<h3 id="could-not-resolve-authentication-method">744<h3 id="could-not-resolve-authentication-method">
413 無法解析驗證方法745 無法解析驗證方法
414</h3>746</h3>
415 747
416工作階段到達 API 用戶端時沒有任何認證方式。這會出現在[背景工作階段](/docs/zh-TW/agent-view)、雲端工作階段和 Agent SDK 環境中,其中互動式登入檢查在第一個請求之前不會執行。748工作階段到達 API 用戶端時沒有任何認證資格。[背景工作階段](/docs/zh-TW/agent-view)和雲端工作階段在背景工作程序啟動時沒有認證資格時會顯示此訊息。互動式、`-p` 和 Agent SDK 執行會將相同條件報告為[未登入](#not-logged-in),並僅將此字串寫入其偵錯記錄,因此如果您在那裡找到它,請改為遵循該項目。
417 749
418```text theme={null}750```text theme={null}
419Could not resolve authentication method. Expected one of apiKey, authToken, credentials, config, or profile to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted751Could not resolve authentication method. Expected one of apiKey, authToken, credentials, config, or profile to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted
420```752```
421 753
422在 v2.1.174 之前,指派給閒置預初始化背景工作程序的背景或雲端工作階段即使已設定有效認證方式也可能以此方式失敗。請升級以恢復。在目前版本中,此錯誤表示背景工作程序沒有可用的認證方式。754在目前版本上,此錯誤表示背景工作程序沒有可用的認證資格。在 v2.1.174 之前,指派給閒置預初始化背景工作程序的背景工作階段即使在設定了有效認證資格時也可能以此方式失敗。在 v2.1.176 之前,在被聲稱之前處於閒置狀態的雲端工作階段也可能如此。請升級以復原。
423 755
424**應該怎麼做:**756**該怎麼做:**
425 757
426* 如果此錯誤出現在背景或雲端工作階段中且您的認證方式已設定,請升級至 v2.1.174 或更新版本758* 如果此訊息出現在背景或雲端工作階段中,且您的認證資格已設定,請升級至 v2.1.176 或更新版本
427* 確認 `ANTHROPIC_API_KEY`、`CLAUDE_CODE_OAUTH_TOKEN` 或您的雲端提供者認證方式已在啟動背景工作程序的環境中設定,而不僅在您的互動式 shell 中759* 確認 `ANTHROPIC_API_KEY`、`CLAUDE_CODE_OAUTH_TOKEN` 或您的雲端提供者認證資格已在啟動背景工作程序的環境中設定,而不僅在您的互動式 shell 中設定
428* 對於 Agent SDK,請參閱[驗證設定](/docs/zh-TW/agent-sdk/overview#get-started)760* 對於 Agent SDK,請參閱[快速入門中的驗證設定](/docs/zh-TW/agent-sdk/quickstart#setup)
429* 在相同環境中的互動式工作階段中執行 `/status` 以確認哪個認證方式來源可以解析761* 在相同環境中的互動式工作階段中執行 `/status` 以確認哪個認證資格來源會解析
430 762
431<h3 id="invalid-api-key">763<h3 id="invalid-api-key">
432 無效的 API 金鑰764 無效的 API 金鑰
433</h3>765</h3>
434 766
435`ANTHROPIC_API_KEY` 環境變數或 `apiKeyHelper` 指令碼傳回的金鑰被 API 拒絕。767`ANTHROPIC_API_KEY` 環境變數或 `apiKeyHelper` 指令碼傳回的金鑰被 API 拒絕,或 Claude Code 在傳送前阻止了來自 `ANTHROPIC_API_KEY` 的金鑰。
436 768
437```text theme={null}769```text theme={null}
438Invalid API key · Fix external API key770Invalid API key · Fix external API key
439```771```
440 772
441**應該怎麼做:**773當訊息在 `Fix external API key` 之後繼續,並帶有描述(例如 `Invalid X-Api-Key header value from ANTHROPIC_API_KEY: it contains a line break at character 41 (120 characters on 2 lines).`)時,API 從未看到該金鑰。Claude Code 發現了 HTTP 標頭無法攜帶的字元,並在傳送前停止了請求。請參閱[無效的請求標頭值](#invalid-request-header-value)以瞭解如何讀取描述並修正該值。
442 774
443* 檢查是否有拼寫錯誤,並確認該金鑰未在 [Console](https://platform.claude.com/settings/keys) 中被撤銷775**該怎麼做:**
444* 在相同的 shell 中執行 `env | grep ANTHROPIC`。direnv、dotenv shell 外掛程式和 IDE 終端等工具可能會從您專案中的 `.env` 檔案載入過時的金鑰,而您並未明確設定它776
777* 檢查拼寫錯誤,並確認金鑰未在 [Console](https://platform.claude.com/settings/keys) 中被撤銷
778* 在相同的 shell 中,執行 `env | grep ANTHROPIC`,或在 PowerShell 中執行 `Get-ChildItem Env:ANTHROPIC*`。direnv、dotenv shell 外掛程式和 IDE 終端機等工具可以從您專案中的 `.env` 檔案載入過時的金鑰,而無需您明確設定它
445* 取消設定 `ANTHROPIC_API_KEY` 並執行 `/login` 以改用訂閱驗證779* 取消設定 `ANTHROPIC_API_KEY` 並執行 `/login` 以改用訂閱驗證
446* 如果金鑰來自 [`apiKeyHelper`](/docs/zh-TW/settings#available-settings) 指令碼,請直接執行該指令碼以確認它在 stdout 上列印有效的金鑰780* 如果金鑰來自 [`apiKeyHelper`](/docs/zh-TW/settings-reference#apikeyhelper) 指令碼,請直接執行該指令碼以確認它在 stdout 上列印有效的金鑰
447* 執行 `/status` 以確認 Claude Code 實際使用的認證方式來源781* 執行 `/status` 以確認 Claude Code 實際使用的認證資格來源
448 782
449<h3 id="your-apikeyhelper-script-is-failing">783<h3 id="your-apikeyhelper-script-is-failing">
450 您的 apiKeyHelper 指令碼失敗784 您的 apiKeyHelper 指令碼失敗
451</h3>785</h3>
452 786
453在 [`apiKeyHelper`](/docs/zh-TW/settings#available-settings) 設定中設定的命令已結束並出現錯誤、逾時或未在 stdout 上列印任何內容。如果沒有來自指令碼的金鑰,請求會到達 API 並使用預留位置認證方式,API 會以 `401` 拒絕它。787Claude Code 執行了您的 [`apiKeyHelper`](/docs/zh-TW/settings-reference#apikeyhelper) 設定中的命令,但沒有取回金鑰。沒有金鑰,請求會到達 API,並帶有預留位置認證資格,API 會以 `401` 拒絕它。終端機中的 `Authentication` 面板顯示發生了以下哪種情況:
788
789* 命令以錯誤結束或逾時
790* 命令未向 stdout 列印任何內容
791* 命令列印了除金鑰以外的內容,例如登入橫幅或記錄行。面板顯示 `returned output that cannot be used as an API key` 並說明出了什麼問題,而不重複輸出。在 v2.1.227 之前,Claude Code 會傳送命令列印的任何內容,在修剪周圍空白後。
454 792
455```text theme={null}793```text theme={null}
456Your apiKeyHelper script is failing · This usually means you need to re-authenticate with your provider · Run /status to see the script's error output794Your apiKeyHelper script is failing · This usually means you need to re-authenticate with your provider · Run /status to see the script's error output
457```795```
458 796
459Claude Code 會重新執行指令碼並在顯示此訊息之前最多重試兩次請求,因此失敗會在三次嘗試內出現。在 v2.1.208 之前,Claude Code 花費完整的[重試預算](#automatic-retries)使用預留位置認證方式重新傳送請求,然後報告通用的 `401` 驗證錯誤而不是指令碼失敗。797在[非互動式模式](/docs/zh-TW/headless)中,stderr 也會帶有具體原因,前綴為 `apiKeyHelper failed:`。
460 798
461執行 `/login` 在此無法幫助:只要設定存在,協助程式的輸出[優先於](/docs/zh-TW/authentication#authentication-precedence)已儲存的登入。799Claude Code 會重新執行指令碼並在顯示此訊息之前最多重試請求兩次,因此失敗會在三次嘗試內出現。在 v2.1.208 之前,Claude Code 會花費完整的[重試預算](#automatic-retries)使用預留位置認證資格重新傳送請求,然後報告通用 `401` 驗證錯誤,而不是指令碼失敗。
462 800
463**應該怎麼做:**801執行 `/login` 在這裡沒有幫助:只要設定存在,協助程式的輸出就會[優先於](/docs/zh-TW/authentication#authentication-precedence)已儲存的登入。
802
803**該怎麼做:**
804
805* 直接在您的 shell 中執行在 `apiKeyHelper` 中設定的命令以重現失敗
806* 如果命令報告工作階段已過期,請使用您的認證資格提供者重新驗證,例如再次登入您的 SSO 或機密保管庫
807* 修正命令,使其僅將金鑰列印到 stdout,作為單一可列印 ASCII 權杖,最多 16,384 個字元,並以代碼 0 結束。請參閱[使用 apiKeyHelper 輪換認證資格](/docs/zh-TW/llm-gateway-connect#rotate-credentials-with-apikeyhelper)以取得有效的設定。
808* 執行 `/status` 以確認 `apiKeyHelper` 是活動認證資格來源。每次命令失敗時,其結束代碼和錯誤輸出都會出現在終端機中的 `Authentication` 面板中。在 v2.1.212 之前,該面板的標題為 `Cloud authentication`。
809
810<h3 id="invalid-request-header-value">
811 無效的請求標頭值
812</h3>
813
814Claude Code 即將作為請求標頭傳送的值包含 HTTP 標頭無法攜帶的字元:換行符、NUL 位元組或 `U+00FF` 以上的字元,例如彎引號或零寬空格。Claude Code 在傳送任何內容之前停止請求,並命名要修正的變數或設定。常見原因是從帶有隱藏字元或雜散換行符的文件或聊天中貼上的認證資格。
815
816Claude Code 在直接向 Claude API 或透過 [LLM 閘道](/docs/zh-TW/llm-gateway)傳送請求時執行此檢查。在第三方雲端提供者(例如 [Amazon Bedrock](/docs/zh-TW/amazon-bedrock))上,Claude Code 在傳送前不執行此檢查。
817
818```text theme={null}
819Invalid auth token · Fix external auth token
820Invalid ANTHROPIC_CUSTOM_HEADERS · Fix the environment variable
821Invalid request header from the environment · Fix the environment variable
822```
823
824訊息的第一部分取決於不良值的來源:
825
826* `Invalid auth token`:來自 [`ANTHROPIC_AUTH_TOKEN`](/docs/zh-TW/env-vars) 或 [`CLAUDE_CODE_OAUTH_TOKEN`](/docs/zh-TW/env-vars) 的持有人權杖
827* `Invalid ANTHROPIC_CUSTOM_HEADERS`:您在 [`ANTHROPIC_CUSTOM_HEADERS`](/docs/zh-TW/env-vars) 中設定的標頭名稱或值。描述計算哪個 `Name: Value` 對有問題,例如 `distinct header 2 of 3 parsed from ANTHROPIC_CUSTOM_HEADERS`,而不重複名稱或值,因為您選擇了兩者。
828* `Invalid request header from the environment`:Claude Code 從另一個環境變數(例如 `CLAUDE_AGENT_SDK_CLIENT_APP`)複製到請求標頭中的值。描述命名要修正的變數。
829
830Claude Code 將此檢查捕獲的不良 `ANTHROPIC_API_KEY` 報告為[無效的 API 金鑰](#invalid-api-key),具有相同的尾部描述。它將不良的已儲存 `/login` 認證資格報告為[未登入](#not-logged-in);執行 `/login` 以儲存新的認證資格。[`apiKeyHelper`](/docs/zh-TW/settings-reference#apikeyhelper) 指令碼的輸出永遠不會到達此檢查:Claude Code 在指令碼執行時驗證它,標頭無法攜帶的輸出會失敗,並顯示[您的 apiKeyHelper 指令碼失敗](#your-apikeyhelper-script-is-failing)。
831
832在第二個 `·` 之後,訊息描述問題,如此完整範例所示:
833
834```text theme={null}
835Invalid auth token · Fix external auth token · Invalid Authorization header value from ANTHROPIC_AUTH_TOKEN: it contains a line break at character 41 (120 characters on 2 lines).
836```
837
838位置從 1 開始計算字元。描述是從固定短語和字元計數建立的,因此它永遠不包括值本身。它僅在字元是眾所周知的隱藏或排版字元(例如位元組順序標記、零寬空格或彎引號)時命名該字元,並將其他任何內容報告為 `a non-ASCII character`。
839
840**該怎麼做:**
464 841
465* 在您的 shell 中直接執行在 `apiKeyHelper` 中設定的命令以重現失敗842* 重新設定訊息命名的變數或設定,重新輸入報告位置周圍的字元,而不是從相同來源再次貼上
466* 如果命令報告工作階段已過期,請使用您的認證方式提供者重新驗證,例如再次登入您的 SSO 或機密保管庫843* 對於 `ANTHROPIC_CUSTOM_HEADERS`,每行保留一個 `Name: Value` 對,並重寫訊息計數的對
467* 修復命令以便它將金鑰列印到 stdout 並以代碼 0 結束。請參閱[使用 apiKeyHelper 輪換認證方式](/docs/zh-TW/llm-gateway-connect#rotate-credentials-with-apikeyhelper)以取得有效的設定。844* 執行 `/status` 以確認哪個認證資格來源處於活動狀態
468* 執行 `/status` 以確認 `apiKeyHelper` 是使用中的認證方式來源。每次命令失敗時,其結束代碼和錯誤輸出會出現在終端中的 `Cloud authentication` 面板中。
469 845
470<h3 id="this-organization-has-been-disabled">846<h3 id="this-organization-has-been-disabled">
471 此組織已被停用847 此組織已被停用
472</h3>848</h3>
473 849
474來自已停用 Console 組織的過時 `ANTHROPIC_API_KEY` 正在覆蓋您的訂閱登入。850Claude Code 正在使用來自已停用 Console 組織的過時 `ANTHROPIC_API_KEY`。當您有已儲存的訂閱登入時,金鑰會覆蓋它。
475 851
476```text theme={null}852```text theme={null}
477Your ANTHROPIC_API_KEY belongs to a disabled organization · Unset the environment variable to use your other credentials853Your ANTHROPIC_API_KEY belongs to a disabled organization · Unset the environment variable to use your subscription instead
854Your ANTHROPIC_API_KEY belongs to a disabled organization · Update or unset the environment variable
478API Error: 400 ... This organization has been disabled.855API Error: 400 ... This organization has been disabled.
479```856```
480 857
481環境變數優先於 `/login`,因此即使您有有效的 Pro 或 Max 訂閱,在 shell 設定檔中匯出或從 `.env` 檔案載入的金鑰也會被使用。在非互動模式 (`-p`) 中,當金鑰存在時總是使用該金鑰。858`·` 之後的提示取決於您的已儲存認證資格:當已儲存的 `/login` 可以在您取消設定金鑰後接管時出現第一種形式,當金鑰是您唯一的認證資格時出現第二種形式。
482 859
483**應該怎麼做:**860環境變數優先於 `/login`,因此在您的 shell 設定檔中匯出或從 `.env` 檔案載入的金鑰即使在您有有效的 Pro 或 Max 訂閱時也會被使用。在非互動式模式 (`-p`) 中,當存在金鑰時總是使用該金鑰。
861
862**該怎麼做:**
484 863
485* 在目前 shell 中取消設定 `ANTHROPIC_API_KEY` 並從您的 shell 設定檔中移除它,然後重新啟動 `claude`864* 在目前的 shell 中取消設定 `ANTHROPIC_API_KEY` 並從您的 shell 設定檔中移除它,然後重新啟動 `claude`
486* 之後執行 `/status` 以確認使用中的認證方式是您的訂閱865* 如果訊息說 `Update or unset`,您沒有已儲存的登入可以回退到。取消設定金鑰並執行 `/login`,或將金鑰替換為來自活動 Console 組織的金鑰。
487* 如果未設定環境變數且錯誤仍然存在,則已停用的組織是與您的 `/login` 相關聯的組織。請聯絡支援或使用不同的帳戶登入。866* 之後執行 `/status` 以確認活動認證資格是您的訂閱
867* 如果未設定環境變數且錯誤仍然存在,已停用的組織是與您的 `/login` 相關聯的組織。聯絡支援或使用不同帳戶登入。
488 868
489<h3 id="your-organization-has-disabled-api-key-authentication">869<h3 id="your-organization-has-disabled-api-key-authentication">
490 您的組織已停用 API 金鑰驗證870 您的組織已停用 API 金鑰驗證
491</h3>871</h3>
492 872
493此訊息需要 Claude Code v2.1.169 或更新版本。您的 Console 組織管理員已關閉 API 金鑰驗證,因此 API 拒絕了 Claude Code 正在傳送的金鑰。`·` 之後的恢復提示會根據金鑰的來源而有所不同:873此訊息需要 Claude Code v2.1.169 或更新版本。您的 Console 組織管理員已關閉 API 金鑰驗證,因此 API 拒絕 Claude Code 正在傳送的金鑰。恢復提示在 `·` 之後會根據金鑰的來源而異:
494 874
495```text theme={null}875```text theme={null}
496Your organization has disabled API key authentication · Run /login to sign in with your claude.ai account876Your organization has disabled API key authentication · Run /login to sign in with your claude.ai account
499Your organization has disabled API key authentication · Unset the apiKeyHelper setting and run /login to sign in with your claude.ai account879Your organization has disabled API key authentication · Unset the apiKeyHelper setting and run /login to sign in with your claude.ai account
500```880```
501 881
502環境變數和 `apiKeyHelper` 優先於 `/login`,因此當其中任一個仍在提供金鑰時,單獨執行 `/login` 無法幫助。請參閱[驗證優先順序](/docs/zh-TW/authentication#authentication-precedence)。882環境變數和 `apiKeyHelper` 優先於 `/login`,因此在任一個仍在提供金鑰時單獨執行 `/login` 沒有幫助。請參閱[驗證優先順序](/docs/zh-TW/authentication#authentication-precedence)。
503 883
504**應該怎麼做:**884**該怎麼做:**
505 885
506* 如果訊息提及 `ANTHROPIC_API_KEY`,請在目前 shell 中取消設定它,並從您的 shell 設定檔或 `.env` 檔案中移除它,然後重新啟動 `claude`886* 如果訊息命名 `ANTHROPIC_API_KEY`,在目前的 shell 中取消設定它,並從您的 shell 設定檔或 `.env` 檔案中移除它,然後重新啟動 `claude`
507* 如果訊息提及 `apiKeyHelper`,請從您的 `settings.json` 中移除 [`apiKeyHelper`](/docs/zh-TW/settings#available-settings) 設定887* 如果訊息命名 `apiKeyHelper`,從您的 `settings.json` 中移除 [`apiKeyHelper`](/docs/zh-TW/settings-reference#apikeyhelper) 設定
508* 執行 `/login` 以使用您的 claude.ai 帳戶登入888* 執行 `/login` 以使用您的 claude.ai 帳戶登入
509* 之後執行 `/status` 以確認使用中的認證方式是您的訂閱而不是 API 金鑰889* 之後執行 `/status` 以確認活動認證資格是您的訂閱,而不是 API 金鑰
510* 如果您需要 API 金鑰驗證進行自動化,請要求您的組織管理員在 Console 中重新啟用它890* 如果您需要 API 金鑰驗證來進行自動化,請要求您的組織管理員在 Console 中重新啟用它
511 891
512<h3 id="your-organization-has-disabled-claude-subscription-access">892<h3 id="your-organization-has-disabled-claude-subscription-access">
513 您的組織已停用 Claude 訂閱存取893 您的組織已停用 Claude 訂閱存取
514</h3>894</h3>
515 895
516您的 Claude 組織不允許使用訂閱登入來登入 Claude Code。使用相同帳戶再次執行 `/login` 會傳回相同的錯誤。896您的 Claude 組織不允許使用訂閱登入登入 Claude Code。使用相同帳戶再次執行 `/login` 會傳回相同的錯誤。
517 897
518```text theme={null}898```text theme={null}
519Your organization has disabled Claude subscription access for Claude Code · Use an Anthropic API key instead, or ask your admin to enable access899Your organization has disabled Claude subscription access for Claude Code · Use an Anthropic API key instead, or ask your admin to enable access
521 901
522這是伺服器端組織設定,因此無法從本機設定、環境變數或 CLI 旗標覆蓋。902這是伺服器端組織設定,因此無法從本機設定、環境變數或 CLI 旗標覆蓋。
523 903
524Agent SDK 和 `-p` 非互動模式將此顯示為 `oauth_org_not_allowed` 錯誤代碼。904Agent SDK 和 `-p` 非互動式模式將此呈現為 `oauth_org_not_allowed` 錯誤代碼。
525 905
526**應該怎麼做:**906**該怎麼做:**
527 907
528* 要求您的管理員為您的組織啟用 Claude Code 存取908* 要求您的管理員為您的組織啟用 Claude Code 存取
529* 使用 Console API 金鑰而不是您的訂閱進行驗證。請參閱 [Claude Console 驗證](/docs/zh-TW/authentication#claude-console-authentication)以進行設定。909* 使用 Console API 金鑰而不是您的訂閱進行驗證。請參閱 [Claude Console 驗證](/docs/zh-TW/authentication#claude-console-authentication)以取得設定。
530* 如果您是管理員且看不到啟用存取的選項,請聯絡 [Anthropic 支援](https://support.claude.com)910* 如果您是管理員且看不到啟用存取的選項,請聯絡 [Anthropic 支援](https://support.claude.com)
531 911
532<h3 id="routines-are-disabled-by-your-organizations-policy">912<h3 id="routines-are-disabled-by-your-organizations-policy">
533 例行工作已被您的組織政策停用913 您的組織政策已停用例行程序
534</h3>914</h3>
535 915
536您的 Team 或 Enterprise 組織中的擁有者已在組織層級關閉例行工作。當您嘗試建立或執行例行工作時(包括從 `/schedule` 和 claude.ai/code 上的[例行工作](/docs/zh-TW/routines) UI),會出現此錯誤。916您的 Team 或 Enterprise 組織中的擁有者已在組織層級關閉例行程序。當您嘗試建立或執行例行程序時會出現此錯誤,例如從 claude.ai/code 上的[例行程序](/docs/zh-TW/routines) UI。在 Claude Code v2.1.227 或更新版本上,相同的設定也會[隱藏 CLI 中的 `/schedule`](/docs/zh-TW/routines#troubleshooting)。
537 917
538```text theme={null}918```text theme={null}
539Routines are disabled by your organization's policy.919Routines are disabled by your organization's policy.
541 921
542這是伺服器端設定,因此無法從本機設定、環境變數或 CLI 旗標覆蓋。922這是伺服器端設定,因此無法從本機設定、環境變數或 CLI 旗標覆蓋。
543 923
544**應該怎麼做:**924**該怎麼做:**
545 925
546* 要求您的組織中的擁有者在 [claude.ai/admin-settings/claude-code](https://claude.ai/admin-settings/claude-code) 啟用**例行工作**切換926* 要求您的組織中的擁有者在 [claude.ai/admin-settings/claude-code](https://claude.ai/admin-settings/claude-code) 啟用**例行程序**切換
547* 對於不需要組織層級例行工作的一次性排程工作,請參閱[排程工作](/docs/zh-TW/scheduled-tasks)927* 對於不需要組織層級例行程序的一次性排程工作,請參閱[排程工作](/docs/zh-TW/scheduled-tasks)
548 928
549<h3 id="remote-control-requires-the-anthropic-api">929<h3 id="remote-control-requires-the-anthropic-api">
550 Remote Control 需要 Anthropic API930 Remote Control 需要 Anthropic API
553工作階段未直接與 Anthropic API 通訊,因此沒有 claude.ai 後端供 [Remote Control](/docs/zh-TW/remote-control) 配對。933工作階段未直接與 Anthropic API 通訊,因此沒有 claude.ai 後端供 [Remote Control](/docs/zh-TW/remote-control) 配對。
554 934
555```text theme={null}935```text theme={null}
556Remote Control is only available when using Claude via api.anthropic.com.936Remote Control is only available when using Claude via api.anthropic.com. CLAUDE_CODE_USE_BEDROCK is set, so this session is using Amazon Bedrock — unset it (or run in a shell without it) to use Remote Control.
557```937```
558 938
559這會出現在 Amazon Bedrock、Google Cloud 的 Agent Platform 和 Microsoft Foundry 上。從 v2.1.196 開始,當 [`ANTHROPIC_BASE_URL`](/docs/zh-TW/env-vars) 指向 `api.anthropic.com` 以外的主機(例如 [LLM 閘道](/docs/zh-TW/llm-gateway)或代理)時,即使您使用 claude.ai 登入,也會出現此訊息。939第二句解釋了什麼將工作階段路由到遠離 Anthropic API;在 v2.1.219 之前,訊息僅為第一句。根據原因,訊息命名:
560 940
561**應該怎麼做:**941* `CLAUDE_CODE_USE_*` 提供者變數,例如 [Amazon Bedrock](/docs/zh-TW/amazon-bedrock) 的 `CLAUDE_CODE_USE_BEDROCK` 或 [Google Cloud 的 Agent Platform](/docs/zh-TW/google-vertex-ai) 的 `CLAUDE_CODE_USE_VERTEX`
942* [`ANTHROPIC_BASE_URL`](/docs/zh-TW/env-vars) 指向 `api.anthropic.com` 以外的主機,例如 [LLM 閘道](/docs/zh-TW/llm-gateway)或代理,即使您使用 claude.ai 登入;在 v2.1.196 之前,自訂基礎 URL 不會阻止 Remote Control
943* 企業[雲端閘道](/docs/zh-TW/claude-apps-gateway)透過 `/login` 進行的登入,不支援 Remote Control,且沒有變數可取消設定
562 944
563* 取消設定 `ANTHROPIC_BASE_URL` 並重新啟動工作階段,或從直接與 Anthropic API 通訊的工作階段啟動 Remote Control945**該怎麼做:**
564* 對於此訊息和其他 Remote Control 啟動訊息,請參閱[疑難排解 Remote Control](/docs/zh-TW/remote-control#troubleshooting)
565 946
566<h3 id="oauth-token-revoked-or-expired">947* 取消設定訊息命名的變數,例如 `CLAUDE_CODE_USE_BEDROCK` 或 `ANTHROPIC_BASE_URL`,並重新啟動工作階段,或從直接與 Anthropic API 通訊的工作階段啟動 Remote Control
567 OAuth 權杖已撤銷或已過期948* 如果變數未在您的 shell 中設定,請檢查您的[設定檔](/docs/zh-TW/settings#where-settings-live)中的 `env` 金鑰,該金鑰將環境變數套用到每個工作階段
949* 對於此和其他 Remote Control 啟動訊息,請參閱[疑難排解 Remote Control](/docs/zh-TW/remote-control#troubleshooting)
950
951<h3 id="remote-control-couldnt-refresh-your-login">
952 Remote Control 無法重新整理您的登入
568</h3>953</h3>
569 954
570您儲存的登入不再有效。撤銷的權杖表示您已在所有地方登出或管理員移除了存取;過期的權杖表示自動重新整理在工作階段中途失敗。955Claude Code 在短期認證資格上執行即時 [Remote Control](/docs/zh-TW/remote-control) 連線,該認證資格是使用您已儲存的 claude.ai 登入取得和更新的。當 claude.ai 停止接受該登入,或 Claude Code 沒有剩餘的已儲存登入時,Claude Code 會停止 Remote Control 並需要您再次登入。任一失敗都可能在 Claude Code 仍在連線時或稍後在更新認證資格時發生。
571 956
572兩個訊息都報告 API 為 Claude Code 傳送的請求傳回的拒絕。當已儲存的登入在失敗的重新整理後已被清除時,您會看到[登入已過期](#login-expired)。957當 Claude Code 要求登入服務重新整理您的已儲存登入並且沒有收到答案時,它會保持 Remote Control 執行並在連線的目前認證資格仍然有效時再次嘗試重新整理。當 Claude Code 無法到達登入服務、請求逾時或服務在不拒絕您的登入的情況下失敗時,重新整理會沒有答案。如果登入服務在該認證資格過期時仍未回答,Claude Code 會停止 Remote Control 並報告 `OAuth token refresh failed`。
958
959當 Claude Code 停止 Remote Control 時,它會在警告和以 `Remote Control disconnected` 開頭的文字記錄行中顯示原因。您的本機工作階段會繼續執行,但沒有 Remote Control。本節涵蓋這些行:
573 960
574```text theme={null}961```text theme={null}
575OAuth token revoked · Please run /login962Remote Control disconnected — Claude.ai login expired — run /login to restore Remote Control
576OAuth token has expired · Please run /login963Remote Control disconnected — Claude.ai login expired — run /login, then /remote-control
577API Error: 401 ... authentication_error964Remote Control disconnected — Claude.ai login was rejected — run /login, then /remote-control
965Remote Control disconnected — OAuth token unavailable — run /login to restore Remote Control
966Remote Control disconnected — OAuth token refresh failed — run /login to re-authenticate
967Remote Control disconnected — JWT refresh failed: no OAuth token — run /login
968Remote Control disconnected — Signed out of Claude — run /login, then /remote-control
578```969```
579 970
580**應該怎麼做:**971Claude Code 在訊息中間命名原因:
581 972
582* 執行 `/login` 以重新登入973* ` Claude.ai login expired` 和 `Claude.ai login was rejected`:claude.ai 不再接受您的已儲存登入權杖,因為它已過期或被撤銷
583* 如果在同一工作階段中重新驗證後錯誤仍然出現,請先執行 `/logout` 以完全清除儲存的權杖,然後執行 `/login`974* ` OAuth token unavailable`:當連線的認證資格到期進行更新時,Claude Code 沒有已儲存的登入權杖
584* 對於跨啟動的重複登入提示,請參閱[疑難排解](/docs/zh-TW/troubleshoot-install#not-logged-in-or-token-expired)中的系統時鐘和 macOS Keychain 檢查975* `OAuth token refresh failed`:claude.ai 在 Claude Code 重新連線時拒絕了您的已儲存登入權杖,重新整理權杖未產生新的權杖
585* 對於其他失敗(包括 `403 Forbidden` 和 OAuth 瀏覽器問題),請參閱[登入和驗證](/docs/zh-TW/troubleshoot-install#login-and-authentication)976* `JWT refresh failed: no OAuth token`:Claude Code 找不到已儲存的登入權杖來更新
977* ` Signed out of Claude`:您在此機器上登出,例如在另一個終端機中執行 `/logout`,因此 Claude Code 沒有剩餘的已儲存登入來更新連線
586 978
587<h3 id="login-expired">979**該怎麼做:**
588 登入已過期
589</h3>
590 980
591Claude Code 嘗試更新您儲存的 claude.ai 或 Claude Console 登入,OAuth 服務拒絕了儲存的重新整理權杖,因此 Claude Code 清除了儲存的認證方式。之後,每個請求在到達 API 之前都會在本機停止,因為只有 `/login` 可以建立新的認證方式。在 v2.1.206 之前,Claude Code 無論如何都會傳送請求,並使用環境中剩餘的任何認證方式,然後每個模型都會失敗並出現[所選模型有問題](#theres-an-issue-with-the-selected-model)或 401 而不是登入提示。981* 執行 `/login` 以再次登入
982* 執行 `/remote-control` 以重新連線工作階段。以 `run /login to restore Remote Control` 結尾的訊息不需要此步驟:Claude Code 在您登入後會自動重新連線。
592 983
593```text theme={null}984在 v2.1.224 之前,`OAuth token refresh failed — run /login to re-authenticate` 讀作 `OAuth token refresh failed — re-authenticate, then re-enable Remote Control`,`JWT refresh failed: no OAuth token — run /login` 讀作 `no OAuth token available for recovery (code <N>)`。` Claude.ai login expired`、`Claude.ai login was rejected` 和 `OAuth token unavailable` 訊息已在 v2.1.225 中新增。
594Login expired · Please run /login985
595```986在 v2.1.238 之前,Claude Code 將現在說 `Signed out of Claude` 的情況報告為 `JWT refresh failed: no OAuth token — run /login`,並在一次登入重新整理沒有收到答案時立即停止 Remote Control,並顯示 `Claude.ai login expired — run /login to restore Remote Control`。
987
988<h3 id="remote-control-stopped-because-the-signed-in-account-changed">
989 Remote Control 因為已登入帳戶已變更而停止
990</h3>
991
992Claude Code 在 [Remote Control](/docs/zh-TW/remote-control) 工作階段期間顯示此行,當您在此機器上登入不同的 claude.ai 帳戶或組織時。您在 Claude Code 工作階段外進行了切換,例如在另一個終端機中執行 `/login`。
596 993
597在[非互動模式](/docs/zh-TW/headless)(`-p`) 和 [Agent SDK](/docs/zh-TW/agent-sdk/overview) 中,訊息如下所示,結構化錯誤代碼為 `authentication_failed`:994您在透過 `/login` 登入時啟動的 Remote Control 工作階段屬於當時登入的 claude.ai 帳戶和組織。
598 995
599```text theme={null}996```text theme={null}
600Failed to authenticate: OAuth session expired and could not be refreshed997Remote Control disconnected — signed-in claude.ai account or organization changed on this machine — run /remote-control to start a session for the current account, or /login to switch back, then /remote-control
601```998```
602 999
603這與[OAuth 權杖已撤銷或已過期](#oauth-token-revoked-or-expired)的狀態不同。這些訊息報告 API 傳回的 401。Claude Code 本身為已失敗更新的登入產生 `Login expired`,因此它不傳送任何請求。1000Claude Code 在 claude.ai 確認帳戶或組織已變更後立即停止 Remote Control 工作階段。您的本機工作階段會繼續執行,但沒有 Remote Control。
604 1001
605使用 API 金鑰、[`CLAUDE_CODE_OAUTH_TOKEN`](/docs/zh-TW/env-vars) 或第三方提供者驗證的工作階段不使用儲存的登入,永遠不會看到此訊息。1002**該怎麼做:**
606 1003
607**應該怎麼做:**1004* 執行 `/remote-control` 以在目前帳戶或組織下啟動新的 Remote Control 工作階段
1005* 若要切換回去,請執行 `/login` 並再次登入先前的帳戶或組織。然後執行 `/remote-control`。
608 1006
609* 執行 `/login` 以重新登入。在不登入的情況下重試會在每個請求上顯示相同的訊息。1007在 v2.1.234 之前,當您在 Claude Code 工作階段外切換到不同帳戶或組織時,Claude Code 沒有注意到。Claude Code 保持 Remote Control 工作階段連線,直到稍後對 Remote Control 伺服器的請求失敗,並顯示 `Remote Control server rejected the request (HTTP 404)`。該失敗可能在切換後數小時才出現。
610* 在非互動模式中,在相同環境中執行 `claude`,完成 `/login`,然後重新執行您的命令。對於無法互動式登入的自動化,請使用 `ANTHROPIC_API_KEY` 進行驗證或[使用 `claude setup-token` 產生長期權杖](/docs/zh-TW/authentication#generate-a-long-lived-token)。
611* 如果登入持續失敗,請參閱[登入和驗證](/docs/zh-TW/troubleshoot-install#login-and-authentication)
612 1008
613<h3 id="oauth-scope-requirement">1009<h3 id="remote-control-stopped-because-the-app-running-the-session-signed-out-or-switched-accounts">
614 OAuth 範圍要求1010 Remote Control 因為執行工作階段的應用程式登出或切換帳戶而停止
615</h3>1011</h3>
616 1012
617儲存的權杖早於較新功能所需的權限範圍。您最常從 `/usage` 和狀態列使用量指示器看到此訊息:1013當 Claude 桌面應用程式或 IDE 主持您的工作階段時,Claude Code 從該應用程式而不是從 `/login` 取得其登入權杖。當 claude.ai 拒絕該權杖時,Claude Code 要求應用程式提供新的權杖。如果應用程式回答它已登出,或它現在已登入不同的 Claude 帳戶,Claude Code 會結束 [Remote Control](/docs/zh-TW/remote-control) 工作階段並向應用程式傳送以下其中一行:
618 1014
619```text theme={null}1015```text theme={null}
620OAuth token does not meet scope requirement: user:profile1016Remote Control stopped — the app running this session is now signed in to a different Claude account
1017Remote Control stopped — the app running this session is signed out of Claude. Sign in there, then turn Remote Control back on
621```1018```
622 1019
623**應該怎麼做:**1020您的本機工作階段會繼續執行,但沒有 Remote Control。
624 1021
625* 執行 `/login` 以取得具有目前範圍的新權杖。您不需要先登出。1022**該怎麼做:**
626 1023
627<h3 id="aws-credentials-expired-or-invalid">1024* 如果應用程式已登出,請再次登入,然後在應用程式中重新開啟 Remote Control
628 AWS 認證方式已過期或無效1025* 如果應用程式切換了帳戶,Claude Code 無法在新帳戶下繼續已結束的工作階段。在該帳戶下啟動新的 Remote Control 工作階段。
1026
1027在 v2.1.238 之前,Claude Code 在兩種情況下都向應用程式傳送了[Remote Control 無法重新整理您的登入](#remote-control-couldnt-refresh-your-login)下列出的 `run /login` 訊息。
1028
1029<h3 id="oauth-token-revoked-or-expired">
1030 OAuth 權杖已撤銷或已過期
629</h3>1031</h3>
630 1032
631此訊息需要 Claude Code v2.1.198 或更新版本,且僅在您的設定檔中設定了 [`awsAuthRefresh`](/docs/zh-TW/amazon-bedrock#advanced-credential-configuration) 時出現。您的 AWS 工作階段權杖已過期或被拒絕,Claude Code 已執行的自動重新整理未產生 API 接受的認證方式。它會出現在來自 [Claude Platform on AWS](/docs/zh-TW/claude-platform-on-aws) 或 [Mantle 端點](/docs/zh-TW/amazon-bedrock#use-the-mantle-endpoint) 的 401 上,這是這些提供者報告過期安全權杖的方式。1033您的已儲存登入不再有效。撤銷的權杖表示您在任何地方登出或管理員移除了存取;已過期的權杖表示自動重新整理在工作階段中失敗。
632 1034
633中間的動作提示會命名您設定中的 `awsAuthRefresh` 命令,因此會有所不同。穩定的部分是前導的 `AWS credentials expired or invalid`:1035兩個訊息都報告 API 為 Claude Code 傳送的請求傳回的拒絕。當已儲存的登入在失敗的重新整理後已被清除時,您會看到[登入已過期](#login-expired)。如果您在 [`CLAUDE_CODE_OAUTH_TOKEN`](/docs/zh-TW/env-vars) 中使用長期權杖進行驗證,當該權杖過期或被撤銷時,您會看到相同的訊息。
634 1036
635```text theme={null}1037```text theme={null}
636AWS credentials expired or invalid · run /login and select "Claude Platform on AWS · refresh credentials", or run `aws sso login --profile myprofile` in another terminal · API Error: 401 ...1038OAuth token revoked · Please run /login
1039OAuth token has expired · Please run /login
1040API Error: 401 ... authentication_error
637```1041```
638 1042
639如果未設定 `awsAuthRefresh`,相同的 401 會改為顯示通用的 `Please run /login` 訊息,該訊息無法重新整理 AWS 認證方式。1043**該怎麼做:**
640
641**應該怎麼做:**
642 1044
643* 在另一個終端中執行訊息中命名的 `awsAuthRefresh` 命令(例如 `aws sso login --profile myprofile`)並完成瀏覽器登入,然後重試1045* 執行 `/login` 以再次登入
644* 在互動式工作階段中,執行 `/login`,選擇 **3rd-party platform**,然後在 **Using 3rd-party platforms** 下選擇 **Claude Platform on AWS · refresh credentials** 以執行相同的命令而無需重新啟動 Claude Code。請參閱[設定 AWS 認證方式](/docs/zh-TW/claude-platform-on-aws#1-configure-aws-credentials)1046* 如果在重新驗證後同一工作階段內錯誤返回,請先執行 `/logout` 以完全清除已儲存的權杖,然後執行 `/login`
645* 如果重新整理命令成功後錯誤仍然重複出現,請在相同的 shell 和設定檔中使用 `aws sts get-caller-identity` 確認身份在 Claude Code 外部有效1047* 如果您使用 `CLAUDE_CODE_OAUTH_TOKEN` 環境變數進行驗證,Claude Code 會在請求失敗並顯示 401 後繼續傳送您設定的值,而不是切換到已儲存登入的權杖。[`/status`](/docs/zh-TW/commands) 將此認證資格顯示為讀取 `CLAUDE_CODE_OAUTH_TOKEN` 的 `Auth token` 列。使用 [`claude setup-token`](/docs/zh-TW/authentication#generate-a-long-lived-token) 產生新的權杖並使用它重新啟動,或取消設定變數並執行 `/login`。在 v2.1.225 之前,Claude Code 可以在工作階段中期用已儲存登入的短期存取權杖替換變數的值,一旦該權杖過期,工作階段就會再次失敗,並顯示 401 錯誤。
1048* 對於跨啟動的重複登入提示,請參閱[疑難排解](/docs/zh-TW/troubleshoot-install#not-logged-in-or-token-expired)中的系統時鐘檢查和 macOS 認證儲存復原步驟
1049* 對於其他失敗,包括 `403 Forbidden` 和 OAuth 瀏覽器問題,請參閱[登入和驗證](/docs/zh-TW/troubleshoot-install#login-and-authentication)
646 1050
647<h3 id="aws-authentication-failed">1051<h3 id="api-error-401-invalid-authentication-credentials">
648 AWS 驗證失敗1052 API 錯誤:401 無效的驗證認證資格
649</h3>1053</h3>
650 1054
651此訊息需要 Claude Code v2.1.198 或更新版本,且僅在您的設定檔中設定了 [`awsAuthRefresh`](/docs/zh-TW/amazon-bedrock#advanced-credential-configuration) 時出現。您的 AWS 提供者傳回了 403,或 [Amazon Bedrock](/docs/zh-TW/amazon-bedrock) 傳回了 401。1055API 識別了您的認證資格格式,但拒絕了其背後的帳戶或組織。當認證資格最近被撤銷、組織被停用或移除了您的存取,或帳戶本身被停用時,Anthropic 會傳回此訊息,因此過期的權杖不是原因。認證資格可以是您的已儲存登入或已核准的 `ANTHROPIC_API_KEY`,修正方式不同,因此首先執行 `/status` 以查看哪一個處於活動狀態。
652
653Claude Code 無法判斷您遇到了哪個原因。Amazon Bedrock 將過期的安全權杖報告為 403,但 403 也是它報告授權拒絕的方式,例如來自遺失 IAM 權限或未為您的帳戶啟用的模型的 `AccessDeniedException`。
654
655來自 Amazon Bedrock 的 401 也會落在此處而不是在 [AWS 認證方式已過期或無效](#aws-credentials-expired-or-invalid) 下,因為 Amazon Bedrock 不會將過期的權杖報告為 401。來自該端點的 401 通常來自請求路徑中的其他內容,例如公司代理。
656
657認證方式重新整理可以修復過期的權杖,無法修復其他原因,因此訊息提供了兩者:
658 1056
659```text theme={null}1057```text theme={null}
660AWS authentication failed · run /login and select "Claude Platform on AWS · refresh credentials", or run `aws sso login --profile myprofile` in another terminal · if credentials are current, check AWS permissions and model access · API Error: 403 ...1058Please run /login · API Error: 401 Invalid authentication credentials
661```1059```
662 1060
663中間的動作提示會命名您設定中的 `awsAuthRefresh` 命令,因此會有所不同。穩定的部分是前導的 `AWS authentication failed`。1061**該怎麼做:**
664
665**應該怎麼做:**
666 1062
667* 執行訊息中命名的 `awsAuthRefresh` 命令或 `aws sso login`,以防過期的認證方式是原因1063* 如果 `/status` 顯示未標記為未使用的 `API key` 列,則已核准的 [`ANTHROPIC_API_KEY`](/docs/zh-TW/authentication#authentication-precedence) 是活動認證資格,優先於您的登入,因此 `/login` 不會替換它。在 Claude Console 中輪換金鑰,或執行 `unset ANTHROPIC_API_KEY` 回退到您的訂閱,或在 PowerShell 中執行 `Remove-Item Env:ANTHROPIC_API_KEY`。
668* 如果您的認證方式是最新的,請確認 [IAM 配置](/docs/zh-TW/amazon-bedrock#iam-configuration) 中的 IAM 權限已附加到您使用的身份,且所選模型已為您的帳戶和區域啟用1064* 如果 `/status` 僅顯示您的登入,請執行 `/login` 一次。如果認證資格被撤銷,新的登入會替換它。
669* 執行 `aws sts get-caller-identity` 以確認您的請求使用哪個身份;過時的 `AWS_PROFILE` 或預設設定檔是權限不匹配的常見原因1065* 如果相同的訊息對相同的登入帳戶返回,則帳戶或組織不再活動。檢查 `/status` 報告的帳戶和組織,並要求您的組織管理員恢復存取。
1066* 如果 [`ANTHROPIC_BASE_URL`](/docs/zh-TW/env-vars) 指向 [LLM 閘道](/docs/zh-TW/llm-gateway),`401` 之後的文字是您的閘道訊息,而不是 Anthropic 的訊息,`/login` 不會改變它。改為修正您的閘道期望的認證資格。
670 1067
671<h3 id="aws-default-chain-credential-resolve-timed-out">1068<h3 id="login-expired">
672 AWS 預設鏈認證方式解析逾時1069 登入已過期
673</h3>1070</h3>
674 1071
675AWS 預設認證方式提供者鏈在 60 秒內未產生認證方式,因此 Claude Code 停止了解析並使請求失敗。失敗是本機認證方式解析:請求永遠未到達 [Amazon Bedrock](/docs/zh-TW/amazon-bedrock)、[Claude Platform on AWS](/docs/zh-TW/claude-platform-on-aws) 或 [Mantle 端點](/docs/zh-TW/amazon-bedrock#use-the-mantle-endpoint)。Claude Code 在此錯誤出現之前會清除其[認證方式快取](/docs/zh-TW/amazon-bedrock#credential-caching-and-resolution-timeout)並在重複嘗試後重試,因此當您看到它時鏈已在重複嘗試上停滯。1072Claude Code 嘗試更新您已儲存的 claude.ai 或 Claude Console 登入,OAuth 服務拒絕了已儲存的重新整理權杖,因此 Claude Code 清除了已儲存的認證資格。之後,每個模型請求在到達 API 之前都會在本機停止,並顯示此訊息,因為只有 `/login` 可以建立新的認證資格。
1073
1074在 v2.1.206 之前,Claude Code 無論如何都會傳送模型請求,並使用環境中剩餘的任何認證資格,每個模型都會失敗,並顯示[所選模型有問題](#theres-an-issue-with-the-selected-model)或 401,而不是登入提示。
676 1075
677```text theme={null}1076```text theme={null}
678API Error: AWS default-chain credential resolve timed out1077Login expired · Please run /login
679```1078```
680 1079
681常見原因是您的 AWS 設定檔中的 `credential_process` 命令等待它無法接收的輸入,以及容器或 VM 的執行個體中繼資料服務 (IMDS) 永遠不會回答鏈的探測。在 v2.1.207 之前,停滯的鏈會讓請求無限期等待,而不是以此訊息失敗。1080在[非互動式模式](/docs/zh-TW/headless)(`-p`) 和 [Agent SDK](/docs/zh-TW/agent-sdk/overview) 中,訊息讀作如下,結構化錯誤代碼為 `authentication_failed`:
682 1081
683**應該怎麼做:**1082```text theme={null}
1083Failed to authenticate: OAuth session expired and could not be refreshed
1084```
684 1085
685* 在相同的 shell 中使用相同的 `AWS_PROFILE` 執行 `aws sts get-caller-identity`。如果它也掛起,請修復設定檔;互動式提示的 `credential_process` 命令是常見原因。1086這與[OAuth 權杖已撤銷或已過期](#oauth-token-revoked-or-expired)的狀態不同。這些訊息報告 API 傳回的 401。Claude Code 本身為已失敗更新的登入產生 `Login expired`,因此它不傳送請求。當更新失敗是因為帳戶本身被暫停而不是登入過時時,Claude Code 會改為顯示[您的帳戶已被暫停](#your-account-is-on-hold)。
686* 在啟動 Claude Code 之前完成登入步驟,例如 `aws sso login --profile myprofile`,以便鏈從本機 SSO 快取解析而不是等待瀏覽器流程
687* 如果您的鏈執行合法需要超過 60 秒的互動式登入,例如透過 `aws-vault` 等包裝程式的 SSO 搭配 MFA,請使用 [`CLAUDE_CODE_AWS_CHAIN_RESOLVE_TIMEOUT_MS`](/docs/zh-TW/env-vars) 以毫秒為單位提高限制
688 1087
689<h2 id="network-and-connection-errors">1088使用 API 金鑰、[`CLAUDE_CODE_OAUTH_TOKEN`](/docs/zh-TW/env-vars) 或第三方提供者進行驗證的工作階段不使用已儲存的登入,永遠不會看到此訊息。
690 網路和連線錯誤
691</h2>
692 1089
693這些錯誤表示來自 Claude Code 的網路請求無法到達其目的地,或 Claude Code 和 API 之間的某些東西在回程中改變了回應。它們通常源自您的本機網路、代理伺服器或防火牆,或雲端環境的網路政策。1090您可以在請求失敗之前檢查此狀態:[`/status`](/docs/zh-TW/commands) 顯示讀作 `Expired — log in again` 的 `Login` 列,加上它為過期登入儲存的組織和電子郵件。該列僅在已儲存的登入是您的活動認證資格且無法再更新時出現。以其他方式進行驗證的工作階段不會顯示該列,即使已儲存的過期登入仍然存在。在 v2.1.210 之前,`/status` 在此狀態下沒有指示登入曾經存在過,因為已清除的認證資格沒有留下任何內容供其報告。
694 1091
695<h3 id="unable-to-connect-to-api">1092**該怎麼做:**
696 無法連線到 API1093
1094* 執行 `/login` 以再次登入。在不登入的情況下重試會在每個請求上顯示相同的訊息。
1095* 在非互動式模式中,在相同環境中執行 `claude`,完成 `/login`,然後重新執行您的命令。對於無法以互動方式登入的自動化,使用 `ANTHROPIC_API_KEY` 或[使用 `claude setup-token` 產生長期權杖](/docs/zh-TW/authentication#generate-a-long-lived-token)進行驗證。
1096* 如果登入持續失敗,請參閱[登入和驗證](/docs/zh-TW/troubleshoot-install#login-and-authentication)
1097
1098<h3 id="administrator-policy-requires-a-cloud-gateway-sign-in">
1099 管理員政策需要雲端閘道登入
697</h3>1100</h3>
698 1101
699與 API 的 TCP 連線失敗或從未完成。1102此機器上的管理員[受管設定](/docs/zh-TW/managed-settings)將 [`forceLoginMethod`](/docs/zh-TW/settings-reference#forceloginmethod) 設定為 `"gateway"` 或設定 [`forceLoginGatewayUrl`](/docs/zh-TW/settings-reference#forcelogingatewayurl)。除非您透過 `CLAUDE_CODE_USE_BEDROCK` 等變數選擇雲端提供者,Claude Code 只接受 [Claude 應用程式閘道](/docs/zh-TW/claude-apps-gateway)登入。您會看到以下兩個訊息之一:
700 1103
701```text theme={null}1104```text theme={null}
702Unable to connect to API. Check your internet connection1105Not signed in to the Cloud gateway — run /login.
703Unable to connect to API (ECONNREFUSED)
704Unable to connect to API (ECONNRESET)
705Unable to connect to API (ETIMEDOUT)
706fetch failed
707Request timed out. Check your internet connection and proxy settings
708```1106```
709 1107
710常見原因包括沒有網際網路存取、阻止 `api.anthropic.com` 的 VPN,或未設定的必要公司代理伺服器。1108當工作階段沒有閘道登入時,模型請求會失敗,並顯示此訊息,例如因為您自政策到達機器後未執行 `/login`。
1109
1110如果您也有 `ANTHROPIC_API_KEY`、`ANTHROPIC_AUTH_TOKEN` 或 `apiKeyHelper` 認證資格已設定,且受管設定設定了 `forceLoginMethod`,Claude Code 會在啟動時改為結束,並顯示以下開頭的訊息:
1111
1112```text theme={null}
1113Administrator policy requires a Cloud gateway sign-in on this machine; the
1114Anthropic-issued credential configured here (ANTHROPIC_API_KEY,
1115ANTHROPIC_AUTH_TOKEN, or apiKeyHelper) is not used.
1116```
711 1117
712**該怎麼做:**1118**該怎麼做:**
713 1119
714* 透過在同一個 shell 中執行 `curl -I https://api.anthropic.com` 來確認您可以到達 API 主機。在 Windows PowerShell 上使用 `curl.exe -I https://api.anthropic.com`,以免使用內建的 `Invoke-WebRequest` 別名。1120* 執行 `/login` 並在**雲端閘道**畫面上完成登入
715* 如果您在公司代理伺服器後面,請在啟動 Claude Code 前設定 `HTTPS_PROXY`,並參閱[網路設定](/docs/zh-TW/network-config)1121* 對於啟動訊息,移除您設定的 `ANTHROPIC_API_KEY`、`ANTHROPIC_AUTH_TOKEN` 或 `apiKeyHelper` 設定,然後啟動 `claude` 並執行 `/login`
716* 如果您透過 LLM 閘道或中繼站路由,請將 [`ANTHROPIC_BASE_URL`](/docs/zh-TW/env-vars) 設定為其位址。請參閱[將 Claude Code 連線到 LLM 閘道](/docs/zh-TW/llm-gateway-connect)以取得設定說明。1122* 如果您認為機器不應該需要閘道,請要求管理該機器的管理員從其受管設定中移除 `forceLoginMethod` 和 `forceLoginGatewayUrl`
717* 確保您的防火牆允許[網路存取需求](/docs/zh-TW/network-config#network-access-requirements)中列出的主機
718* 間歇性故障會[自動重試](#automatic-retries);持續性故障指向本機網路問題
719 1123
720如果 `curl` 成功但 Claude Code 仍然失敗,原因通常是執行時間和網路之間的某些東西,而不是網路本身:1124在 v2.1.265 上,迴歸也在某些使用 API 金鑰、`apiKeyHelper` 或自訂標頭進行驗證的 LLM 閘道和代理設定中顯示第一個訊息,即使機器上沒有管理員要求。更新至 v2.1.266 或更新版本。您不需要變更您的設定。
721 1125
722* 在 Linux 和 WSL 上,檢查 `/etc/resolv.conf` 是否有無法到達的名稱伺服器。特別是 WSL 可能會從主機繼承損壞的解析器。1126在 v2.1.261 之前,在將 `forceLoginMethod` 設定為 `"gateway"` 的機器上,Claude Code 使用剩餘的已儲存登入,而不是失敗模型請求,並報告已設定的環境認證資格,並顯示 `This machine's managed settings require a first-party login` 而不是啟動訊息。在 v2.1.265 之前,其受管設定僅設定 `forceLoginGatewayUrl` 的機器不需要閘道登入,Claude Code 在那裡使用剩餘的認證資格。
723* 在 macOS 上,已斷開連線或卸載的 VPN 用戶端可能會留下隧道介面或路由規則。檢查 `ifconfig` 是否有過時的 `utun` 介面,並在系統設定中移除 VPN 的網路擴充功能。
724* Docker Desktop 和類似的容器執行時間可能會攔截出站流量。結束它們並重試以排除此可能性。
725 1127
726<h3 id="bedrock-streaming-response-has-an-unexpected-content-type">1128<h3 id="your-account-is-on-hold">
727 Bedrock 串流回應有非預期的 content-type1129 您的帳戶已被暫停
728</h3>1130</h3>
729 1131
730Claude Code 和 [Amazon Bedrock](/docs/zh-TW/amazon-bedrock) 之間的閘道或代理伺服器正在轉換串流回應本體或其 `Content-Type` 標頭。Amazon Bedrock 將回應串流為 `application/vnd.amazon.eventstream`,而 Claude Code 會拒絕報告不同 content-type 的成功串流回應,而不是解碼它無法讀取的本體。該請求不會重試。1132Claude 帳戶背後的登入已被暫停。Claude Code 在嘗試更新您的已儲存登入並瞭解暫停時顯示第一個訊息,在您在瀏覽器中完成的登入報告時顯示第二個訊息:
731 1133
732```text theme={null}1134```text theme={null}
733Bedrock streaming response has content-type "text/event-stream"; expected "application/vnd.amazon.eventstream". A gateway or proxy between Claude Code and Bedrock is likely transforming the response body — Bedrock's binary event-stream format must be passed through unmodified. Set CLAUDE_CODE_DISABLE_BEDROCK_CONTENT_TYPE_GUARD=1 to suppress this check while the gateway is being fixed.1135Your account is on hold and can't use Claude Code. View details or appeal: https://claude.ai/restricted
1136Your account is on hold and can't sign in to Claude Code. View details or appeal: https://claude.ai/restricted
734```1137```
735 1138
736在 v2.1.208 之前,相同的設定錯誤會在整個回應被緩衝後顯示為 `API Error: Truncated event message received`。1139使用相同帳戶再次登入不會清除訊息,因為暫停是在帳戶上,而不是登入上。在[非互動式模式](/docs/zh-TW/headless)(`-p`) 和 [Agent SDK](/docs/zh-TW/agent-sdk/overview) 中,結構化錯誤代碼為 `account_on_hold`。在 v2.1.235 之前,Claude Code 將被暫停的帳戶報告為[登入已過期 · 請執行 /login](#login-expired),其復原步驟無法清除暫停。
737 1140
738**該怎麼做:**1141**該怎麼做:**
739 1142
740* 設定閘道以不修改地傳遞 `InvokeModelWithResponseStream` 回應本體及其 `Content-Type` 標頭。將串流重新發出為伺服器傳送事件的中介是常見原因。1143* 開啟訊息中的連結以檢視暫停的詳細資訊或對其提出異議
741* 如果閘道只重寫標頭並完整傳遞二進位本體,請設定 [`CLAUDE_CODE_DISABLE_BEDROCK_CONTENT_TYPE_GUARD=1`](/docs/zh-TW/env-vars) 以在閘道修復前跳過檢查。請參閱[閘道或代理伺服器後的串流錯誤](/docs/zh-TW/amazon-bedrock#streaming-errors-behind-a-gateway-or-proxy)。1144* 如果您有另一個 Claude 帳戶或不受暫停影響的 API 金鑰,您可以在暫停解決期間繼續工作:執行 `/login` 使用該帳戶,或使用 `ANTHROPIC_API_KEY` 設定金鑰
742 1145
743<h3 id="ssl-certificate-errors">1146<h3 id="anthropic-profile-login-expired">
744 SSL 憑證錯誤1147 Anthropic 設定檔登入已過期
745</h3>1148</h3>
746 1149
747您網路上的代理伺服器或安全設備正在用其自己的憑證攔截 TLS 流量,而 Claude Code 不信任它。1150Claude Code 透過 Anthropic 認證資格設定檔進行驗證,其已儲存的登入認證資格已過期,且設定檔沒有 Claude Code 可用來更新它的重新整理認證資格。Claude Code 在本機停止每個請求,不重試,因為重試會讀取相同的過期認證資格。
748 1151
749```text theme={null}1152```text theme={null}
750Unable to connect to API: SSL certificate verification failed. Check your proxy or corporate SSL certificates1153Anthropic profile login expired · Re-authenticate your Anthropic profile
751Unable to connect to API: Self-signed certificate detected1154Anthropic profile login expired · Run /login to use your claude.ai account instead, or re-authenticate the profile
752```1155```
753 1156
754自 v2.1.199 起,憑證驗證失敗不會重試,因此此錯誤會在第一次嘗試時出現,而不是在完整[重試預算](#automatic-retries)後出現。較早的版本在顯示它之前會花費幾分鐘重試。暫時性 TLS 條件(例如握手逾時)仍會重試。1157這僅在活動認證資格來自 Anthropic 認證資格設定檔時出現,您可以使用 `ANTHROPIC_PROFILE` 環境變數選擇該設定檔,Claude Code 在您的 Anthropic 設定目錄中發現為活動設定檔,或 Claude Code 在您[登入時沒有 API 金鑰](/docs/zh-TW/authentication#sign-in-without-an-api-key)時寫入。使用 `/login` 的 claude.ai 選項、API 金鑰、持有人權杖(例如 `ANTHROPIC_AUTH_TOKEN`)或第三方提供者進行驗證的工作階段永遠不會看到此訊息。
755 1158
756在 `/login` 和啟動連線檢查期間,同樣的失敗會以 OpenSSL 代碼和內聯修復報告:1159在[提供無金鑰登入](/docs/zh-TW/authentication#sign-in-without-an-api-key)的機器上,執行 `/login`,選擇 Anthropic Console 帳戶,然後再次登入以更新無金鑰 Console 登入或 Claude Platform CLI 的 `ant auth login` 寫入的設定檔。Claude Code 替換該設定檔中的過期認證資格。對於聯盟設定檔或另一個工具建立的設定檔,`/login` 不會更新認證資格。您看到的形式取決於您是否明確選擇了設定檔或 Claude Code 發現了它:
757 1160
758```text theme={null}1161* 當您明確設定 `ANTHROPIC_PROFILE` 時,訊息以 `Re-authenticate your Anthropic profile` 結尾。
759SSL certificate error (UNABLE_TO_GET_ISSUER_CERT_LOCALLY). If you are behind a corporate proxy or TLS-intercepting firewall, set NODE_EXTRA_CA_CERTS to your CA bundle path, or ask IT to allowlist *.anthropic.com. Run `claude doctor` for details.1162* 當 Claude Code 從您的設定目錄發現設定檔時,訊息提供 `/login`,因為 Claude Code 優先使用有效的 `/login` 而不是發現的設定檔,然後改為使用您的 claude.ai 或 Console 帳戶進行驗證。在 v2.1.234 之前,Claude Code 在此情況下也顯示 `Re-authenticate your Anthropic profile` 形式。
760```
761 1163
762**該怎麼做:**1164**該怎麼做:**
763 1165
764* 匯出您組織的 CA 套件,並使用 `NODE_EXTRA_CA_CERTS=/path/to/ca-bundle.pem` 將 Claude Code 指向它1166* 再次登入設定檔,然後重試:在[提供無金鑰登入](/docs/zh-TW/authentication#sign-in-without-an-api-key)的機器上,執行 `/login` 並為無金鑰 Console 登入或 Claude Platform CLI 的 `ant auth login` 寫入的設定檔選擇 Anthropic Console 帳戶;對於其他設定檔,使用建立它們的工具
765* 請參閱[網路設定](/docs/zh-TW/network-config#custom-ca-certificates)以取得完整設定說明1167* 如果管理員佈建了設定檔的認證資格,請要求他們簽發新的認證資格
766* 不要設定 `NODE_TLS_REJECT_UNAUTHORIZED=0`,這會完全停用憑證驗證1168* 執行 `/status` 以確認活動認證資格來源和設定檔名稱
1169* 若要停止使用設定檔,如果您設定了 `ANTHROPIC_PROFILE`,請取消設定它,然後以其他方式進行驗證,例如 `/login` 或 `ANTHROPIC_API_KEY`
767 1170
768<h3 id="host-not-allowed-in-a-cloud-session">1171<h3 id="oauth-scope-requirement">
769 雲端工作階段中不允許的主機1172 OAuth 範圍要求
770</h3>1173</h3>
771 1174
772來自雲端工作階段或例行程序的出站 HTTP 請求被環境的網路政策阻止。1175已儲存的權杖早於較新功能需要的權限範圍。您最常從 `/usage` 和狀態行使用指標看到此訊息:
773 1176
774```text theme={null}1177```text theme={null}
775HTTP 4031178OAuth token does not meet scope requirement: user:profile
776x-deny-reason: host_not_allowed
777```1179```
778 1180
779您也可能看到與目的地實際憑證不符的 TLS 憑證。雲端環境透過代理伺服器路由出站流量以強制執行網路政策,因此不符的憑證表示代理伺服器終止了連線,而不是目的地。
780
781這不是用戶端網路問題。雲端工作階段和[例行程序](/docs/zh-TW/routines)在沙箱環境內執行,其出站流量被篩選到環境的允許清單。**預設**環境使用**信任**存取,允許[預設允許清單](/docs/zh-TW/claude-code-on-the-web#default-allowed-domains)的套件登錄、雲端提供者 API、容器登錄和常見開發網域,但阻止其他所有內容。
782
783**該怎麼做:**1181**該怎麼做:**
784 1182
785* 開啟例行程序進行編輯,或啟動雲端工作階段。選擇顯示您環境名稱(例如**預設**)的雲端圖示以開啟選擇器。將滑鼠懸停在您的環境上,然後按一下設定圖示。1183* 執行 `/login` 以取得具有目前範圍的新權杖。您不需要先登出。
786* 在**更新雲端環境**對話方塊中,將**網路存取**從**信任**變更為**自訂**,然後將被阻止的網域新增到**允許的網域**。每行輸入一個網域。勾選**也包含常見套件管理員的預設清單**以在自訂網域旁保留[預設允許清單](/docs/zh-TW/claude-code-on-the-web#default-allowed-domains)。如果您想要不受限制的存取,請改為選擇**完整**。
787* 按一下**儲存變更**。下一次執行會使用更新的允許清單。
788
789請參閱[網路存取](/docs/zh-TW/claude-code-on-the-web#network-access)以取得存取層級和預設允許清單。本機 CLI 工作階段不受此政策影響。
790 1184
791<h3 id="couldnt-reconnect-to-your-remote-control-session">1185<h3 id="claude-ai-rejected-the-session-token">
792 無法重新連線到您的遠端控制工作階段1186 claude.ai 拒絕了工作階段權杖
793</h3>1187</h3>
794 1188
1189[claude.ai 連接器](/docs/zh-TW/mcp#use-mcp-servers-from-claude-ai)請求失敗,因為 claude.ai 拒絕了來自您的 Claude Code 登入的權杖,通常是已過期且無法更新的登入。被拒絕的權杖是您的登入,而不是連接器在 claude.ai 中的自身授權,因此再次授權連接器不會解決它。在 `/mcp` 中,連接器顯示為 `connected · session token rejected`,其詳細資訊檢視讀作:
1190
795```text theme={null}1191```text theme={null}
796Couldn't reconnect to your Remote Control session. Retry, or start a fresh session without --resume.1192claude.ai rejected the session token. Run /login, then reconnect.
797```1193```
798 1194
799使用 `claude --resume` 或 `claude --continue` 恢復會重新連線到該對話中記錄的[遠端控制](/docs/zh-TW/remote-control)工作階段。此訊息表示重新連線因可能是暫時性的原因(例如網路中斷或伺服器錯誤)而失敗,因此 Claude Code 無法確認遠端工作階段是否仍然存在。您的本機工作階段會繼續執行,但不使用遠端控制。
800
801**該怎麼做:**1195**該怎麼做:**
802 1196
803* 執行 `/remote-control` 以重試連線1197* 執行 `/login` 以再次登入
804* 啟動 Claude Code 時不使用 `--resume` 以建立新的遠端控制工作階段1198* 從 `/mcp` 重新連線連接器,或執行 `/mcp reconnect <server>`。在您再次登入之前重新連線會使連接器處於相同狀態。`/mcp` 面板的**重新連線**選項報告 `your claude.ai session token was rejected`;輸入的 `/mcp reconnect <server>` 形式報告成功重新連線,即使權杖仍被拒絕。
805* 如需其他遠端控制啟動訊息,請參閱[遠端控制疑難排解](/docs/zh-TW/remote-control#troubleshooting)
806
807當伺服器確認前一個工作階段不再存在時,您不會看到此訊息;Claude Code 在這種情況下會建立一個新的工作階段。在 v2.1.200 之前,任何重新連線失敗都會建立新的遠端控制工作階段,這在 claude.ai/code 的工作階段清單中留下額外的工作階段。
808
809<h2 id="request-errors">
810 請求錯誤
811</h2>
812 1199
813這些錯誤與您的請求內容有關。大多數來自 API 在拒絕請求後的回應;少數是由 Claude Code 在發送任何請求之前在本地產生的。1200在 v2.1.222 之前,Claude Code 改為將連接器標記為需要驗證,這指向您進行連接器的授權流程,即使完成它也不會解決狀態。
814 1201
815<h3 id="prompt-is-too-long">1202<h3 id="issuer-mismatch-in-authorization-response">
816 提示詞過長1203 授權回應中的簽發者不匹配
817</h3>1204</h3>
818 1205
819對話加上附加檔案超過了模型的上下文視窗。1206在 [MCP OAuth 登入](/docs/zh-TW/mcp#authenticate-with-remote-mcp-servers)期間,授權伺服器重新導向回 Claude Code,並帶有 `iss` 參數,該參數不命名 Claude Code 從伺服器的 OAuth 中繼資料預期的簽發者。此步驟中的簽發者錯誤是授權伺服器混合攻擊的樣子,因此 Claude Code 失敗登入,而不是交換授權代碼。Claude Code 在瀏覽器登入後在 `/mcp` 伺服器功能表中顯示錯誤:
820 1207
821```text theme={null}1208```text theme={null}
822Prompt is too long1209Issuer mismatch in authorization response (RFC 9207): expected "https://auth.example.com", received "https://other.example.com"
823```1210```
824 1211
1212`expected` 是來自伺服器的 OAuth 中繼資料的簽發者,`received` 是重新導向攜帶的 `iss` 值。其重新導向不攜帶 `iss` 參數的登入通過檢查,除非伺服器的中繼資料設定 `authorization_response_iss_parameter_supported`,在這種情況下 Claude Code 失敗登入。
1213
825**該怎麼做:**1214**該怎麼做:**
826 1215
827* 執行 `/compact` 來總結早期的回合並釋放空間,或執行 `/clear` 來重新開始1216* 嘗試從 `/mcp` 再次登入
828* 執行 `/context` 來查看視窗消耗的詳細分解:系統提示詞、工具、記憶檔案和訊息1217* 如果錯誤重複,請向伺服器操作員報告。修正是伺服器端的:授權伺服器必須在 `iss` 參數中傳回與在其中繼資料中宣傳的相同簽發者
829* 使用 `/mcp disable <name>` 停用您未使用的 MCP 伺服器,以從上下文中移除其工具定義1218* 若要在伺服器被修正時進行連線,請使用 [`MCP_SDK_GENERATION=v1`](/docs/zh-TW/env-vars) 啟動 Claude Code,其[執行時](/docs/zh-TW/mcp#mcp-client-runtimes)不執行此檢查。這會移除對混合攻擊的保護,因此偏好伺服器端修正
830* 修剪大型 `CLAUDE.md` 記憶檔案,或將指令移至[路徑範圍規則](/docs/zh-TW/memory#path-specific-rules),這些規則只在相關時載入
831* 子代理繼承父工作階段中的每個 MCP 工具定義,這可能會在第一個回合之前填滿其上下文視窗。在生成子代理之前停用您未使用的 MCP 伺服器。
832* 自動壓縮預設為開啟,通常可防止此錯誤。如果您已設定 [`DISABLE_AUTO_COMPACT`](/docs/zh-TW/env-vars),請重新啟用它或在視窗填滿之前手動執行 `/compact`。
833 1219
834請參閱[探索上下文視窗](/docs/zh-TW/context-window)以取得上下文如何填滿的互動式檢視。1220在 v2.1.232 之前,Claude Code 僅在逐步推出中或當您設定 `MCP_SDK_GENERATION=v2` 時使用 v2 執行時。
835 1221
836<h3 id="error-during-compaction-conversation-too-long">1222<h3 id="aws-credentials-expired-or-invalid">
837 壓縮期間出錯:對話過長1223 AWS 認證資格已過期或無效
838</h3>1224</h3>
839 1225
840`/compact` 本身失敗,因為沒有足夠的可用上下文來保存它產生的摘要。1226此訊息需要 Claude Code v2.1.198 或更新版本,且僅在您的設定檔中設定 [`awsAuthRefresh`](/docs/zh-TW/amazon-bedrock#advanced-credential-configuration) 時出現。您的 AWS 工作階段權杖已過期或被拒絕,Claude Code 已執行的自動重新整理未產生 API 接受的認證資格。它出現在來自 [Claude Platform on AWS](/docs/zh-TW/claude-platform-on-aws) 或 [Mantle 端點](/docs/zh-TW/amazon-bedrock#use-the-mantle-endpoint) 的 401 上,這是這些提供者報告過期安全權杖的方式。
1227
1228中間的動作提示命名您設定中的 `awsAuthRefresh` 命令,因此它會有所不同。穩定的部分是前導 `AWS credentials expired or invalid`:
841 1229
842```text theme={null}1230```text theme={null}
843Error during compaction: Conversation too long. Press esc twice to go up a few messages and try again.1231AWS credentials expired or invalid · run /login and select "Claude Platform on AWS · refresh credentials", or run `aws sso login --profile myprofile` in another terminal · API Error: 401 ...
844```1232```
845 1233
846當視窗在自動壓縮觸發時已滿,或當您在看到 `Prompt is too long` 後執行 `/compact` 時,可能會發生這種情況。1234如果未設定 `awsAuthRefresh`,相同的 401 會改為顯示通用 `Please run /login` 訊息,該訊息無法重新整理 AWS 認證資格。
847 1235
848**該怎麼做:**1236**該怎麼做:**
849 1237
850* 按 Esc 兩次以開啟訊息清單並回溯幾個回合。這會從上下文中移除最近的訊息。然後再次執行 `/compact`。1238* 在另一個終端機中執行訊息中命名的 `awsAuthRefresh` 命令,例如 `aws sso login --profile myprofile`,並完成瀏覽器登入,然後重試
851* 如果回溯沒有釋放足夠的空間,執行 `/clear` 以開始新的工作階段。您之前的對話會被保留,可以使用 `/resume` 重新開啟。1239* 在互動式工作階段中,執行 `/login`,選擇**第三方平台**,然後在**使用第三方平台**下選擇 **Claude Platform on AWS · refresh credentials** 以執行相同命令,而無需重新啟動 Claude Code。請參閱[設定 AWS 認證資格](/docs/zh-TW/claude-platform-on-aws#1-configure-aws-credentials)
1240* 如果重新整理命令成功後錯誤重複,請在相同 shell 和設定檔中使用 `aws sts get-caller-identity` 確認身份在 Claude Code 外有效
852 1241
853<h3 id="request-too-large">1242<h3 id="aws-authentication-failed">
854 請求過大1243 AWS 驗證失敗
855</h3>1244</h3>
856 1245
857原始請求主體在標記化之前超過了 API 的位元組限制,通常是因為貼上了大型檔案或附件。1246此訊息需要 Claude Code v2.1.198 或更新版本,且僅在您的設定檔中設定 [`awsAuthRefresh`](/docs/zh-TW/amazon-bedrock#advanced-credential-configuration) 時出現。您的 AWS 提供者傳回 403,或 [Amazon Bedrock](/docs/zh-TW/amazon-bedrock) 傳回 401。
1247
1248Claude Code 無法判斷您遇到了哪個原因。Amazon Bedrock 將過期的安全權杖報告為 403,但 403 也是它報告授權拒絕的方式,例如來自遺漏 IAM 權限或未為您的帳戶啟用的模型的 `AccessDeniedException`。
1249
1250來自 Amazon Bedrock 的 401 也會落在這裡,而不是在[AWS 認證資格已過期或無效](#aws-credentials-expired-or-invalid)下,因為 Amazon Bedrock 不將過期的權杖報告為 401。來自該端點的 401 通常來自請求路徑中的其他內容,例如公司代理。
1251
1252認證資格重新整理可以修正過期的權杖,無法修正其他原因,因此訊息提供兩者:
858 1253
859```text theme={null}1254```text theme={null}
860Request too large (max 30 MB). Double press esc to go back and remove or shrink the attached content.1255AWS authentication failed · run /login and select "Claude Platform on AWS · refresh credentials", or run `aws sso login --profile myprofile` in another terminal · if credentials are current, check AWS permissions and model access · API Error: 403 ...
861```1256```
862 1257
863這是 HTTP 請求的大小限制,與[上下文視窗限制](#prompt-is-too-long)分開。1258中間的動作提示命名您設定中的 `awsAuthRefresh` 命令,因此它會有所不同。穩定的部分是前導 `AWS authentication failed`。
864 1259
865**該怎麼做:**1260**該怎麼做:**
866 1261
867* 按 Esc 兩次並回溯到添加超大內容的回合之前1262* 執行訊息中命名的 `awsAuthRefresh` 命令或 `aws sso login`,以防過期的認證資格是原因
868* 按路徑參考大型檔案而不是貼上其內容,以便 Claude 可以分塊讀取它們1263* 如果您的認證資格是最新的,請確認 [IAM 設定](/docs/zh-TW/amazon-bedrock#iam-configuration)中的 IAM 權限已附加到您使用的身份,且所選模型已為您的帳戶和區域啟用
869* 對於影像,請參閱下面的[影像過大](#image-was-too-large)1264* 執行 `aws sts get-caller-identity` 以確認您的請求使用哪個身份;過時的 `AWS_PROFILE` 或預設設定檔是權限不匹配的常見原因
870 1265
871<h3 id="image-was-too-large">1266<h3 id="could-not-load-aws-or-google-cloud-credentials">
872 影像過大1267 無法載入 AWS 或 Google Cloud 認證資格
873</h3>1268</h3>
874 1269
875貼上或附加的影像超過了 API 的大小或尺寸限制。1270Claude Code 無法從 AWS 認證資格提供者鏈或從它執行的機器上的 Google 應用程式預設認證資格取得可用的認證資格,因此沒有請求到達您的雲端提供者。Claude Code 清除其快取的認證資格並在顯示此訊息之前重試兩次。`·` 之後的詳細資訊命名具體原因,例如過期的 SSO 工作階段、遺漏的應用程式預設認證資格報告為 `Could not load the default credentials`,或被拒絕的登入報告為 `invalid_grant`:
876 1271
877```text theme={null}1272```text theme={null}
878Image was too large. Double press esc to go back and try again with a smaller image.1273API Error: Could not load AWS credentials · Could not load credentials from any providers. Check or refresh your AWS credentials and try again.
879API Error: 400 ... image dimensions exceed max allowed size1274API Error: Could not load Google Cloud credentials · invalid_grant. Check or refresh your Google Cloud credentials and try again.
880```1275```
881 1276
882Claude Code 將無法處理的影像替換為文字佔位符並重試,因此後續訊息會成功。在 2.1.142 之前的版本上,貼上的影像可能會保留在對話中,並在每個後續訊息上重複相同的錯誤。若要在這些版本上恢復,請按 Esc 兩次並回溯到添加影像的回合之前。1277在[非互動式模式](/docs/zh-TW/headless)中使用 `-p` 和在 [Agent SDK](/docs/zh-TW/agent-sdk/overview) 中,結構化錯誤代碼為 `cloud_credential_error`。在 v2.1.267 之前,訊息僅顯示 `API Error:` 之後的詳細資訊文字,結構化代碼為 `server_error` 或 `unknown`。
883 1278
884**該怎麼做:**1279**該怎麼做:**
885 1280
886* 在貼上之前調整影像大小。API 接受單個影像最長邊最多 8000 像素的影像,或當許多影像在上下文中時為 2000 像素。1281* 執行您的提供者的登入命令,例如 `aws sso login --profile myprofile` 或 `gcloud auth application-default login`,然後重試。[Bedrock、Agent Platform 或 Foundry 認證資格未載入](/docs/zh-TW/troubleshoot-install#bedrock-agent-platform-or-foundry-credentials-not-loading)顯示如何在 Claude Code 外確認認證資格
887* 拍攝相關區域的更緊密螢幕截圖,而不是整個螢幕1282* 如果詳細資訊讀作 `AWS default-chain credential resolve timed out`,鏈掛起而不是失敗,因此改為遵循 [AWS default-chain credential resolve timed out](#aws-default-chain-credential-resolve-timed-out)
888 1283
889<h3 id="unable-to-resize-image">1284<h3 id="aws-default-chain-credential-resolve-timed-out">
890 無法調整影像大小1285 AWS default-chain credential resolve 逾時
891</h3>1286</h3>
892 1287
893Claude Code 無法在將附加影像發送到 API 之前將其縮小。1288AWS 預設認證資格提供者鏈未在 60 秒內產生認證資格,因此 Claude Code 停止了解析並失敗了請求。此逾時是[無法載入 AWS 或 Google Cloud 認證資格](#could-not-load-aws-or-google-cloud-credentials)的一個原因。失敗是本機認證資格解析:請求永遠不會到達 [Amazon Bedrock](/docs/zh-TW/amazon-bedrock)、[Claude Platform on AWS](/docs/zh-TW/claude-platform-on-aws) 或 [Mantle 端點](/docs/zh-TW/amazon-bedrock#use-the-mantle-endpoint)。Claude Code 在此錯誤出現之前清除其[認證資格快取](/docs/zh-TW/amazon-bedrock#credential-caching-and-resolution-timeout)並重試,因此到您看到它時,鏈已在重複嘗試中停滯。
894 1289
895```text theme={null}1290```text theme={null}
896Unable to resize image — image processing is unavailable and dimensions could not be read from the file header. Please convert the image to PNG, JPEG, GIF, or WebP.1291API Error: Could not load AWS credentials · AWS default-chain credential resolve timed out. Check or refresh your AWS credentials and try again.
897Unable to resize image — dimensions exceed the 2000x2000px limit and image processing failed. Please resize the image to reduce its pixel dimensions.
898Unable to resize image (… raw, … base64). The image exceeds the … API limit and compression failed. Please resize the image manually or use a smaller image.
899Unable to resize image — could not verify image dimensions are within the 2000x2000px API limit.
900```1292```
901 1293
902Claude Code 通常會自動調整大型影像的大小。這些錯誤意味著原生影像處理器無法載入或返回錯誤,因此無法調整影像大小以符合 API 限制。1294常見原因是您的 AWS 設定檔中的 `credential_process` 命令等待它無法接收的輸入,以及其執行個體中繼資料服務 (IMDS) 永遠不會回答鏈探測的容器或 VM。
1295
1296在 v2.1.267 之前,訊息讀作 `API Error: AWS default-chain credential resolve timed out`。
1297在 v2.1.207 之前,停滯的鏈使請求無限期等待,而不是失敗。
903 1298
904**該怎麼做:**1299**該怎麼做:**
905 1300
906* 如果訊息要求您轉換影像,請將其轉換為 PNG、JPEG、GIF 或 WebP,然後再次附加。Claude Code 可以驗證這些格式的尺寸,無需影像處理器。1301* 在相同 shell 中使用相同 `AWS_PROFILE` 執行 `aws sts get-caller-identity`。如果它也掛起,請修正設定檔;以互動方式提示的 `credential_process` 命令是常見原因。
907* 如果訊息報告尺寸或大小限制,請在附加之前將影像調整或重新壓縮到該限制以下。1302* 在啟動 Claude Code 之前完成登入步驟,例如 `aws sso login --profile myprofile`,以便鏈從本機 SSO 快取解析,而不是等待瀏覽器流程
1303* 如果您的鏈執行合法需要超過 60 秒的互動式登入,例如透過 `aws-vault` 等包裝程式的 SSO 與 MFA,請使用 [`CLAUDE_CODE_AWS_CHAIN_RESOLVE_TIMEOUT_MS`](/docs/zh-TW/env-vars) 以毫秒為單位提高限制
908 1304
909<h3 id="pdf-errors">1305<h3 id="bedrock-setup-verification-timed-out-waiting-for-aws">
910 PDF 錯誤1306 Bedrock 設定驗證逾時等待 AWS
911</h3>1307</h3>
912 1308
913您附加的 PDF 無法處理。1309在 [Bedrock 設定精靈](/docs/zh-TW/amazon-bedrock#sign-in-with-bedrock)的認證資格驗證期間對 AWS 的呼叫(例如認證資格查詢或身份檢查)未在 60 秒限制內完成。精靈停止等待並失敗驗證步驟:
914 1310
915```text theme={null}1311```text theme={null}
916PDF too large (max 100 pages, 32 MB). Try splitting it or extracting text first.1312Timed out after 60s waiting for AWS. Check your network and proxy settings; if a credential helper needs longer to prompt you, raise CLAUDE_CODE_AWS_CHAIN_RESOLVE_TIMEOUT_MS.
917PDF is password protected. Try removing protection or extracting text first.
918The PDF file was not valid. Try converting to a different format first.
919```1313```
920 1314
921**該怎麼做:**1315該數字反映您的限制:預設 60 秒,或您在 [`CLAUDE_CODE_AWS_CHAIN_RESOLVE_TIMEOUT_MS`](/docs/zh-TW/env-vars) 中設定的值。
922 1316
923* 對於超大 PDF,請要求 Claude 使用 Read 工具讀取頁面範圍,而不是附加整個檔案,或使用 `pdftotext` 之類的工具提取文字並按路徑參考輸出檔案1317常見原因是停滯對 AWS 的請求的網路或代理,包括 SSO 權杖重新整理,以及仍在等待您看不到的輸入的認證資格協助程式。僅在協助程式合法需要更多時間時提高限制。
924* 對於受保護或無效的 PDF,移除密碼或從其源應用程式重新匯出檔案,然後重試
925 1318
926<h3 id="extra-inputs-are-not-permitted">1319對 AWS 的單一停滯請求也可能在其自身的每個請求逾時上失敗,這在相同步驟上顯示較短的訊息:
1320
1321```text theme={null}
1322A request to AWS timed out. Check your network and proxy settings, then try again.
1323```
1324
1325當相同的逾時發生在模型釘選步驟上時,精靈會將模型標記為 `unreachable`,而不是顯示任一訊息。
1326
1327**該怎麼做:**
1328
1329* 在相同 shell 中執行 `aws sts get-caller-identity`。如果它也掛起,停滯在 Claude Code 外,在您的網路、您的代理或您的 AWS 設定檔中的認證資格協助程式中;首先修正那個。
1330* 在開啟精靈之前完成任何互動式登入,例如 `aws sso login --profile myprofile`
1331* 如果您的 AWS 設定檔中的認證資格協助程式合法需要超過 60 秒來提示您,請使用 [`CLAUDE_CODE_AWS_CHAIN_RESOLVE_TIMEOUT_MS`](/docs/zh-TW/env-vars) 以毫秒為單位提高限制
1332
1333<h3 id="cloud-gateway-session-expired">
1334 雲端閘道工作階段已過期
1335</h3>
1336
1337您透過 [Claude 應用程式閘道](/docs/zh-TW/claude-apps-gateway)登入,此機器上儲存的閘道工作階段已過期且無法更新,或閘道不再接受它,例如在閘道的 [JWT 機密被替換](/docs/zh-TW/claude-apps-gateway-deploy#jwt-secret-rotation)後。如果您在以互動方式啟動 `claude` 時看到此行,工作階段已開啟,未登入閘道:
1338
1339```text theme={null}
1340Cloud gateway session expired — run /login to reconnect.
1341```
1342
1343相同的行可以在工作階段中期出現,當閘道認證資格過期且 Claude Code 無法更新它時。
1344
1345在[非互動式](/docs/zh-TW/headless)執行、背景或其他無人值守工作階段或 `claude` 子命令(除了 `claude auth`)中,Claude Code 會在閘道不再接受工作階段時改為結束,並顯示此訊息:
1346
1347```text theme={null}
1348Cloud gateway <url> no longer accepts this session. Start `claude` and sign in again with /login.
1349```
1350
1351**該怎麼做:**
1352
1353* 在工作階段中執行 `/login` 並完成瀏覽器登入
1354* 對於非互動式啟動,在相同環境中啟動 `claude`,執行 `/login`,然後重新執行您的命令
1355
1356<h2 id="network-and-connection-errors">
1357 網路和連線錯誤
1358</h2>
1359
1360大多數這些錯誤表示來自 Claude Code 的網路請求無法到達其目的地,或 Claude Code 和 API 之間的某些東西在回程中改變了回應;如果條目也有本機原因(例如失敗的封存寫入),其內容會說明。它們通常源自您的本機網路、代理或防火牆,或雲端環境的網路原則。
1361
1362<h3 id="unable-to-connect-to-api">
1363 無法連線到 API
1364</h3>
1365
1366到 API 的 TCP 連線失敗或從未完成。對於常見的連線錯誤代碼,訊息會命名失敗的類型並在括號中保留代碼:
1367
1368```text theme={null}
1369Unable to connect to API. Check your internet connection
1370Connection refused — a firewall or proxy may be blocking it (ConnectionRefused)
1371Can't reach the API server — check your internet or DNS (ENOTFOUND)
1372No internet route — check your connection or VPN (EHOSTUNREACH)
1373Couldn't connect through your proxy (ERR_PROXY_TUNNEL)
1374Connection dropped (ECONNRESET)
1375fetch failed
1376Request timed out. Check your internet connection and proxy settings
1377```
1378
1379Claude Code 無法識別的代碼會顯示為 `Unable to connect to API` 後跟括號中的代碼。某些這些訊息可以顯示多個代碼:例如 `Connection refused` 可以顯示 `ConnectionRefused` 或 `ECONNREFUSED`,而 `Can't reach the API server` 可以顯示 `ENOTFOUND` 或 `FailedToOpenSocket`。
1380
1381在 v2.1.227 之前,這些編碼訊息中的每一個都讀作 `Unable to connect to API` 後跟代碼,例如 `Unable to connect to API (ECONNREFUSED)`。
1382
1383常見原因包括沒有網際網路存取、阻止 `api.anthropic.com` 的 VPN,或未設定的必需公司代理。
1384
1385**該怎麼做:**
1386
1387* 通過從同一個 shell 執行 `curl -I https://api.anthropic.com` 來確認您可以到達 API 主機。在 Windows PowerShell 上使用 `curl.exe -I https://api.anthropic.com`,以便不使用內建的 `Invoke-WebRequest` 別名。
1388* 如果您在公司代理後面,在啟動 Claude Code 之前設定 `HTTPS_PROXY` 並查看[網路設定](/docs/zh-TW/network-config)
1389* 如果您通過 LLM 閘道或中繼路由,將 [`ANTHROPIC_BASE_URL`](/docs/zh-TW/env-vars) 設定為其位址。請參閱[將 Claude Code 連線到 LLM 閘道](/docs/zh-TW/llm-gateway-connect)以進行設定。
1390* 確保您的防火牆允許[網路存取要求](/docs/zh-TW/network-config#network-access-requirements)中列出的主機
1391* 間歇性故障會[自動重試](#automatic-retries);持續故障指向本機網路問題
1392
1393如果 `curl` 成功但 Claude Code 仍然失敗,原因通常是執行時和網路之間的某些東西,而不是網路本身:
1394
1395* 在 Linux 和 WSL 上,檢查 `/etc/resolv.conf` 是否有無法到達的名稱伺服器。特別是 WSL 可以從主機繼承損壞的解析器。
1396* 在 macOS 上,已斷開連線或卸載的 VPN 用戶端可能會留下隧道介面或路由規則。檢查 `ifconfig` 是否有過時的 `utun` 介面,並在系統設定中移除 VPN 的網路擴充功能。
1397* Docker Desktop 和類似的容器執行時可以攔截出站流量。退出它們並重試以排除這種可能性。
1398
1399<h3 id="unable-to-connect-to-anthropic-services">
1400 無法連線到 Anthropic 服務
1401</h3>
1402
1403在首次執行設定期間,Claude Code 會檢查它是否可以到達 `api.anthropic.com` 和 `platform.claude.com`,然後才顯示登入步驟。當任一檢查失敗時,Claude Code 會列印原因並退出。
1404
1405```text theme={null}
1406Unable to connect to Anthropic services
1407Failed to connect to api.anthropic.com: ECONNREFUSED
1408Connection to api.anthropic.com timed out after 10 seconds
1409A proxy is configured via HTTPS_PROXY. Check that it allows connections to the host above.
1410```
1411
1412Claude Code 通過與 API 請求相同的[代理設定](/docs/zh-TW/network-config)發送檢查,並給每個探測 10 秒。當失敗的探測通過代理時,訊息會命名設定它的環境變數,例如 `HTTPS_PROXY`。在 v2.1.222 之前,檢查使用不同的代理傳輸,沒有逾時:在具有 `https://` 方案的代理 URL 後面,它可能會在 `Checking connectivity...` 上無限期停滯,然後即使通過同一代理的 API 請求成功也會失敗。
1413
1414當[受管設定檔案、MDM 原則或原則協助程式](/docs/zh-TW/managed-settings)將 [`forceLoginMethod`](/docs/zh-TW/settings-reference#forceloginmethod) 設定為 `"gateway"`,或設定 [`forceLoginGatewayUrl`](/docs/zh-TW/settings-reference#forcelogingatewayurl) 而不設定 `forceLoginMethod` 時,Claude Code 會跳過此檢查。使用任一設定,Claude Code 會在**雲端閘道**畫面上開啟登入步驟,而不是 Anthropic 登入方法。當機器上存在受管設定來源但無法讀取時,Claude Code 也會跳過檢查,因為該來源可能保有閘道設定。在 v2.1.247 之前,Claude Code 在此設定下也執行檢查,當 Anthropic 的端點無法到達時以此錯誤退出。
1415
1416**該怎麼做:**
1417
1418* 如果訊息命名代理變數,檢查其值是否指向正確的代理,並要求您的網路團隊允許通過它到訊息中主機的 HTTPS 連線。請參閱[網路設定](/docs/zh-TW/network-config)。
1419* 完成[無法連線到 API](#unable-to-connect-to-api) 中的檢查。那裡的 `curl` 測試和防火牆指導也適用於此檢查。
1420* 如果您的組織通過[雲端閘道](/docs/zh-TW/claude-apps-gateway)登入,並且此錯誤出現在首次執行時,請更新到 Claude Code v2.1.247 或更新版本。
1421* 如果您的網路是開放的,故障仍然存在,Claude Code 可能在您的國家[無法使用](https://www.anthropic.com/supported-countries)
1422
1423<h3 id="socket-is-closed">
1424 Socket 已關閉
1425</h3>
1426
1427`Socket is closed` 表示承載串流回應的連線在回應仍在到達時被關閉。最常見的原因是 Windows 上的公司代理在回應中途丟棄已建立的隧道。
1428
1429根據回應進行的距離,Claude Code 會重試請求、保留 Claude 產生的內容,或結束回合。請參閱[自動重試](#automatic-retries)。
1430
1431在 v2.1.214 之前,Claude Code 不會重試此故障,回合會停止並出現包含 `Socket is closed` 的錯誤。
1432
1433**該怎麼做:**
1434
1435* 如果您看到此錯誤,請使用 `claude update` 更新到 v2.1.214 或更新版本,然後再次傳送您的訊息
1436* 如果在更新後回合在同一代理後面持續失敗,請完成[無法連線到 API](#unable-to-connect-to-api) 並檢查[網路設定](/docs/zh-TW/network-config)中的代理設定
1437
1438<h3 id="api-returned-an-empty-or-malformed-response">
1439 API 傳回空的或格式不正確的回應
1440</h3>
1441
1442當 Claude Code 對失敗的串流請求進行非串流重試時,如果獲得 HTTP 成功狀態但主體不是 Claude API 訊息,Claude Code 會顯示此錯誤:通常是 HTML 錯誤或登入頁面、空主體或其他格式的 JSON。代理、閘道或網路登入頁面代替 API 回答是常見來源。Claude Code 不會重試請求,回合以此錯誤結束。
1443
1444```text theme={null}
1445API returned an empty or malformed response (HTTP 200) — check for a proxy or gateway intercepting the request.
1446```
1447
1448在該開頭之後,訊息會報告返回的內容以及哪個請求失敗:
1449
1450* 一個 `Response:` 子句,包含內容類型、主體類型(例如 `body is an HTML page` 或 `empty body`)、其大小(以位元組為單位),以及回應是否攜帶 Anthropic 請求 id。當回應命名可識別的伺服器(例如 `nginx` 或 `cloudflare`)或攜帶中介標頭(例如 `cf-ray` 或 `via`)時,子句也會列出這些。
1451* 一個句子,命名失敗的串流請求的 id 和觸發重試的故障。當串流在故障前開啟時,它也會報告有多少串流事件到達,以及如果有的話,當嘗試失敗時串流已沉默多長時間。
1452
1453在 v2.1.234 之前,訊息在 `intercepting the request` 後結束。
1454
1455**該怎麼做:**
1456
1457* 閱讀 `Response:` 子句以查看哪個系統回答。HTML 主體、沒有 Anthropic 請求 id 或命名的伺服器(例如 `nginx` 或 `cloudflare`)表示 Claude Code 和 API 之間的某些東西代替它回答
1458* 如果您通過[LLM 閘道](/docs/zh-TW/llm-gateway-connect#troubleshoot-gateway-errors)路由,使用直接請求測試路由,並修復返回非 API 回應的跳躍
1459* 在具有登入頁面的網路上(例如訪客 Wi-Fi),在瀏覽器中完成登入,然後重試
1460* 如果只有通過您的閘道的非串流路由損壞,設定 [`CLAUDE_CODE_DISABLE_NONSTREAMING_FALLBACK=1`](/docs/zh-TW/env-vars#variables),以便在串流中途失敗的請求進入正常重試路徑而不是此回退,除非串流端點本身傳回 `404`,Claude Code 仍然會回退
1461
1462<h3 id="streaming-response-ended-before-any-complete-data-was-received">
1463 串流回應在收到任何完整資料之前結束
1464</h3>
1465
1466來自您的模型提供者的串流回應完成,但未傳遞任何可用資料,因此 Claude Code 重新傳送請求而不進行串流以完成回合。Claude Code 每個工作階段顯示一次警告,僅在互動式工作階段中。在 v2.1.239 之前,Claude Code 無聲地重試而不進行串流。
1467
1468```text theme={null}
1469Streaming response ended before any complete data was received. Retrying without streaming. If this keeps happening, check any proxy or gateway between Claude Code and your model provider.
1470```
1471
1472Claude Code 傳送每個受影響的請求兩次:空串流嘗試和重試。常見原因是在回程中消耗或轉換串流回應主體的代理或閘道。
1473
1474**該怎麼做:**
1475
1476* 設定 Claude Code 和您的模型提供者之間的任何代理或閘道,以未修改的方式傳遞串流回應主體及其標頭
1477* 在 [Amazon Bedrock](/docs/zh-TW/amazon-bedrock) 上,請參閱[閘道或代理後面的串流錯誤](/docs/zh-TW/amazon-bedrock#streaming-errors-behind-a-gateway-or-proxy)以了解標頭和主體要求
1478
1479<h3 id="bedrock-streaming-response-has-an-unexpected-content-type">
1480 Bedrock 串流回應具有意外的 content-type
1481</h3>
1482
1483Claude Code 和 [Amazon Bedrock](/docs/zh-TW/amazon-bedrock) 之間的閘道或代理正在轉換串流回應主體或其 `Content-Type` 標頭。Amazon Bedrock 將回應串流為 `application/vnd.amazon.eventstream`。Claude Code 不會解碼無法讀取的主體,而是拒絕報告不同 content-type 的成功串流回應。Claude Code 不會重試請求。
1484
1485```text theme={null}
1486Bedrock streaming response has content-type "text/event-stream"; expected "application/vnd.amazon.eventstream". A gateway or proxy between Claude Code and Bedrock is likely transforming the response body — Bedrock's binary event-stream format must be passed through unmodified. Set CLAUDE_CODE_DISABLE_BEDROCK_CONTENT_TYPE_GUARD=1 to suppress this check while the gateway is being fixed.
1487```
1488
1489在 v2.1.208 之前,相同的設定錯誤在整個回應被緩衝後顯示為 `API Error: Truncated event message received`。
1490
1491**該怎麼做:**
1492
1493* 設定閘道以未修改的方式傳遞 `InvokeModelWithResponseStream` 回應主體及其 `Content-Type` 標頭。重新發出串流為伺服器傳送事件的中介是常見原因。
1494* 設定 [`CLAUDE_CODE_DISABLE_BEDROCK_CONTENT_TYPE_GUARD=1`](/docs/zh-TW/env-vars) 會隱藏此錯誤,但 Claude Code 不會在重寫的標頭下解碼二進位主體,因此這些請求會回退到較慢的非串流路徑。請參閱[閘道或代理後面的串流錯誤](/docs/zh-TW/amazon-bedrock#streaming-errors-behind-a-gateway-or-proxy)。
1495
1496<h3 id="ssl-certificate-errors">
1497 SSL 憑證錯誤
1498</h3>
1499
1500您網路上的代理或安全應用程式正在使用自己的憑證攔截 TLS 流量,Claude Code 不信任它。
1501
1502```text theme={null}
1503Unable to connect to API: SSL certificate verification failed. Check your proxy or corporate SSL certificates
1504Unable to connect to API: Self-signed certificate detected. Check your proxy or corporate SSL certificates
1505```
1506
1507從 v2.1.199 開始,憑證驗證失敗不會重試,因此此錯誤會在第一次嘗試時出現,而不是在完整[重試預算](#automatic-retries)後出現。較早的版本在顯示它之前花費幾分鐘重試。暫時性 TLS 條件(例如握手逾時)仍然會重試。
1508
1509在 `/login` 和啟動連線檢查期間,相同的故障會報告為 OpenSSL 代碼和內聯修復:
1510
1511```text theme={null}
1512SSL certificate error (UNABLE_TO_GET_ISSUER_CERT_LOCALLY). If you are behind a corporate proxy or TLS-intercepting firewall, set NODE_EXTRA_CA_CERTS to your CA bundle path, or ask IT to allowlist *.anthropic.com. Run `claude doctor` for details.
1513```
1514
1515在 [Amazon Bedrock](/docs/zh-TW/amazon-bedrock) 上,Claude Code 本身發送給 AWS 的請求(例如 STS 和 SSO 角色認證呼叫、模型發現和設定精靈的檢查)取決於相同的憑證設定。請參閱[TLS 檢查代理後面的憑證錯誤](/docs/zh-TW/amazon-bedrock#certificate-errors-behind-a-tls-inspecting-proxy)。
1516
1517**該怎麼做:**
1518
1519* 匯出您組織的 CA 套件,並使用 `NODE_EXTRA_CA_CERTS=/path/to/ca-bundle.pem` 將 Claude Code 指向它
1520* 請參閱[網路設定](/docs/zh-TW/network-config#custom-ca-certificates)以了解完整設定說明
1521* 不要設定 `NODE_TLS_REJECT_UNAUTHORIZED=0`,這會完全停用憑證驗證
1522
1523<h3 id="host-not-allowed-in-a-cloud-session">
1524 雲端工作階段中不允許主機
1525</h3>
1526
1527來自雲端工作階段或例行程式的出站 HTTP 請求被環境的網路原則阻止。
1528
1529```text theme={null}
1530HTTP 403
1531x-deny-reason: host_not_allowed
1532```
1533
1534您也可能看到與目的地的真實憑證不符的 TLS 憑證。雲端工作階段通過代理路由出站流量,該代理強制執行網路原則,因此不符的憑證表示代理終止了連線,而不是目的地。
1535
1536這不是用戶端網路問題。雲端工作階段和[例行程式](/docs/zh-TW/routines)在沙箱 VM 內執行,其通過工作階段網路的出站流量被過濾到[雲端環境的](/docs/zh-TW/cloud-environments)允許清單;[GitHub 操作](/docs/zh-TW/cloud-environments#github-proxy)和 MCP 連接器流量使用單獨的通道,這就是為什麼它們可以在其他主機被阻止時繼續工作。**預設**環境使用**信任**存取,允許[預設允許清單](/docs/zh-TW/cloud-environments#default-allowed-domains)的套件登錄、雲端提供者 API、容器登錄和常見開發網域,並阻止該路徑上的其他網域。
1537
1538**該怎麼做:**
1539
1540* 開啟例行程式進行編輯,或啟動雲端工作階段。選擇顯示您環境名稱的雲端圖示(例如**預設**)以開啟選擇器。將滑鼠懸停在您的環境上,然後按一下設定圖示。
1541* 在**更新雲端環境**對話方塊中,將**網路存取**從**信任**變更為**自訂**,然後將被阻止的網域新增到**允許的網域**。每行輸入一個網域。檢查**也包括常見套件管理員的預設清單**以在您的自訂網域旁邊保留[預設允許清單](/docs/zh-TW/cloud-environments#default-allowed-domains)。如果您想要不受限制的存取,請改為選擇**完整**。
1542* 按一下**儲存變更**。下一次執行使用更新的允許清單。
1543
1544請參閱[網路存取](/docs/zh-TW/cloud-environments#network-access)以了解存取層級和預設允許清單。本機 CLI 工作階段不受此原則影響。
1545
1546<h3 id="the-proxy-refused-the-connection">
1547 代理拒絕了連線
1548</h3>
1549
1550當 Claude 通過您在 `HTTPS_PROXY` 中設定的代理或相關[代理變數](/docs/zh-TW/network-config#environment-variables)讀取[成品](/docs/zh-TW/artifacts)時,您會看到此訊息。成品內容來自 `*.frame.claudeusercontent.com`,因此 Claude Code 首先向代理傳送 `CONNECT` 請求,要求它開啟到該主機的隧道。當代理拒絕時,沒有任何東西到達主機,訊息攜帶代理的 HTTP 狀態:
1551
1552```text theme={null}
1553artifact content fetch failed (proxy refused the connection: HTTP 407)
1554artifact content fetch failed (proxy refused the connection: HTTP 403)
1555the proxy refused the connection to the artifact's content host (HTTP 502)
1556```
1557
1558狀態是代理對 `CONNECT` 的回答。主機從未回答,因此每個狀態指向不同的修復:
1559
1560* `HTTP 407`:代理需要它沒有獲得的認證。將它們放在代理 URL 中,如[基本驗證](/docs/zh-TW/network-config#basic-authentication)所示。
1561* `HTTP 403`:代理拒絕隧道到 `*.frame.claudeusercontent.com`。要求運行代理的人允許該主機,[網路存取要求](/docs/zh-TW/network-config#network-access-requirements)會列出該主機。
1562* 任何其他狀態,例如 `HTTP 502`:代理因其自身原因未開啟隧道,例如無法到達主機。在代理的日誌中查詢狀態。
1563* `unreadable reply` 代替狀態:代理位址上的任何東西都沒有用 HTTP 狀態行回答。檢查位址是否為 HTTP 代理。
1564
1565**該怎麼做:**
1566
1567* 檢查代理變數中的位址和認證,如[代理設定](/docs/zh-TW/network-config#proxy-configuration)所述,然後從啟動 Claude Code 的 shell 執行 `curl -x http://proxy.example.com:8080 -I https://api.anthropic.com`,使用您自己的代理 URL。在 Windows PowerShell 上,執行 `curl.exe`。如果此探測以相同方式失敗,請先修復代理設定。如果成功,拒絕特定於成品主機。
1568* 如果您的網路讓 Claude Code 直接到達成品主機,將 `.frame.claudeusercontent.com` 新增到 [`NO_PROXY`](/docs/zh-TW/network-config#environment-variables)。保持條目狹窄:更廣泛的 `.claudeusercontent.com` 條目也會繞過 `bridge.claudeusercontent.com` 的代理,具有 [IP 允許清單](/docs/zh-TW/network-config#organization-ip-allowlists-and-proxy-egress)的組織需要將其保留在代理上。
1569
1570在 v2.1.238 之前,Claude Code 將拒絕的隧道報告為通用網路錯誤。
1571
1572<h3 id="the-cloud-environments-service-returned-an-empty-or-unexpected-response">
1573 雲端環境服務傳回空的或意外的回應
1574</h3>
1575
1576Claude Code 在多個點請求您的[雲端環境](/docs/zh-TW/cloud-environments)清單,例如當您從 CLI 建立雲端工作階段或執行 [`/remote-env`](/docs/zh-TW/cloud-environments#select-an-environment-from-the-cli) 時。當它無法讀取伺服器的回答時,它會顯示以下其中一個訊息:
1577
1578```text theme={null}
1579The cloud environments service returned an empty response (HTTP 200 with no body). This is usually temporary — try again in a moment.
1580The cloud environments service returned a response in an unexpected format (HTTP 200 with a non-JSON body). This is usually temporary — try again in a moment.
1581The cloud environments service returned a response in an unexpected format (HTTP 200 without a usable environments list). This is usually temporary — try again in a moment.
1582```
1583
1584伺服器接受了請求,但用不是環境清單的主體回答:空、不是 JSON 或沒有清單的 JSON。這通常伴隨服務端中斷,並自行清除。根據請求清單的表面,Claude Code 可能會新增前綴,例如 `/remote-env` 對話方塊中的 `couldn't list environments:`。
1585
1586**該怎麼做:**
1587
1588* 重試該操作。Claude Code 每次都會再次請求清單
1589* 如果訊息持續出現,請檢查 [status.claude.com](https://status.claude.com) 以了解活躍的事件
1590
1591在 v2.1.236 之前,Claude Code 顯示原始 JavaScript TypeError 而不是這些訊息。
1592
1593<h3 id="couldnt-reconnect-to-your-remote-control-session">
1594 無法重新連線到您的 Remote Control 工作階段
1595</h3>
1596
1597```text theme={null}
1598Couldn't reconnect to your Remote Control session. Retry, or start a fresh session without --resume.
1599```
1600
1601使用 `claude --resume` 或 `claude --continue` 重新開始會重新連線到該對話中記錄的 [Remote Control](/docs/zh-TW/remote-control) 工作階段。此訊息表示重新連線因可能是暫時的原因(例如網路中斷或伺服器錯誤)而失敗,因此 Claude Code 無法確認遠端工作階段是否仍然存在。您的本機工作階段在沒有 Remote Control 的情況下繼續執行。
1602
1603**該怎麼做:**
1604
1605* 執行 `/remote-control` 以重試連線
1606* 使用 `claude --remote-control` 啟動新工作階段以建立新的 Remote Control 工作階段
1607* 對於其他 Remote Control 啟動訊息,請參閱[Remote Control 疑難排解](/docs/zh-TW/remote-control#troubleshooting)
1608
1609如果伺服器改為報告前一個工作階段已消失,您不會看到此訊息。Claude Code 會在其位置啟動新工作階段或顯示 [`Previous session is unavailable — run /remote-control to start a new one`](/docs/zh-TW/remote-control#previous-session-is-unavailable),取決於[對話的重新連線記錄](/docs/zh-TW/remote-control#resume-outcomes)。從 v2.1.227 到 v2.1.231,Claude Code 改為顯示以 `Remote Control could not resume the previous session under the current login` 開頭的訊息,[較早的版本行為也不同](/docs/zh-TW/remote-control#reconnect-history)。
1610
1611<h3 id="sessions-ended-while-this-machine-was-offline">
1612 此機器離線時工作階段已結束
1613</h3>
1614
1615Claude Code 在執行 [`claude remote-control`](/docs/zh-TW/remote-control#start-a-remote-control-session) 的終端中顯示此訊息,在您的機器離線足夠長的時間後,伺服器清理了您的機器正在提供的 Remote Control 環境。該環境中的工作階段已結束,您無法恢復它們。計數是已結束的工作階段數。
1616
1617```text theme={null}
16182 sessions ended while this machine was offline — the environment was cleaned up on the server and can't be resumed.
1619```
1620
1621**該怎麼做:**
1622
1623* 當 Claude Code 在此訊息下列出保留的 worktrees 時,從它們中拿起任何未提交的工作
1624* 執行 `claude remote-control` 以啟動新環境
1625
1626<h3 id="couldnt-share-the-transcript">
1627 無法共享文字記錄
1628</h3>
1629
1630在您同意從調查提示(例如[工作階段品質調查](/docs/zh-TW/data-usage#session-quality-surveys))共享您的工作階段文字記錄後,Claude Code 將其上傳到 Anthropic,或在第三方提供者上、[Claude apps 閘道](/docs/zh-TW/claude-apps-gateway)工作階段上以及當沒有 Anthropic 認證可用時改為儲存本機封存。此訊息表示共享未完成。
1631
1632```text theme={null}
1633Couldn't share the transcript.
1634```
1635
1636上傳必須符合 8 MiB 限制。在長工作階段上,Claude Code 逐步丟棄共享的部分,最後一個請求的模型設定優先,然後是結構化對話和子代理文字記錄,並且只在無法傳送任何縮減版本或網路或伺服器錯誤停止上傳時顯示此訊息。當 Claude Code 改為儲存本機封存時,訊息表示它無法寫入封存。
1637
1638**該怎麼做:**
1639
1640* 執行 `/feedback` 以傳送文字記錄並描述發生了什麼。如果您的環境中無法使用 `/feedback`,請參閱[報告錯誤](#report-an-error)
1641* 如果其他請求也失敗,請檢查您的網路連線並查看[無法連線到 API](#unable-to-connect-to-api)
1642
1643<h2 id="request-errors">
1644 請求錯誤
1645</h2>
1646
1647這些錯誤與您的請求內容有關。大多數來自 API 在拒絕請求後的回應;少數是由 Claude Code 在發送任何請求之前在本地產生的。
1648
1649<h3 id="prompt-is-too-long">
1650 提示詞過長
1651</h3>
1652
1653對話加上附加檔案超過了模型的上下文視窗。
1654
1655```text theme={null}
1656Prompt is too long
1657```
1658
1659在互動式工作階段中,Claude Code 將此錯誤顯示為:
1660
1661```text theme={null}
1662Context limit reached · /compact or /clear to continue
1663```
1664
1665當設定了 [`DISABLE_COMPACT`](/docs/zh-TW/env-vars) 時,該行僅命名 `/clear`。較長形式的錯誤,例如下面的壓縮失敗形式,保留 `Prompt is too long ·` 的措辭。在 `-p` 輸出和文字記錄中,文字保持為 `Prompt is too long`。
1666
1667當您在 [使用者設定](/docs/zh-TW/settings-reference#autocompactenabled) 中關閉自動壓縮時,該行也會說明這一點:
1668
1669```text theme={null}
1670Context limit reached · /compact or /clear to continue · auto-compact is off · /config to turn it on
1671```
1672
1673`/config` 中的 **Auto-compact** 切換會將 `autoCompactEnabled` 寫入使用者設定。該提示僅在 `/config` 變更會生效時出現。例如,當 [`DISABLE_AUTO_COMPACT`](/docs/zh-TW/env-vars) 或 [`DISABLE_COMPACT`](/docs/zh-TW/env-vars) 關閉自動壓縮時,它不會出現。當更高優先級的範圍(例如專案或受管設定)將 `autoCompactEnabled` 設定為 `false` 時,它也不會出現。在 v2.1.235 之前,該行不包含自動壓縮提示。
1674
1675Amazon Bedrock 將此狀況報告為 `Input is too long for requested model.`,Claude Code 以相同方式處理。在 v2.1.217 之前,Claude Code 沒有識別 Bedrock 的措辭,因此自動壓縮從未在其上觸發,`/compact` 失敗並出現相同錯誤。
1676
1677[Claude apps gateway](/docs/zh-TW/claude-apps-gateway-config#upstream-error-messages) 在雲端上游以提供者自己的錯誤形狀拒絕請求時,將此狀況報告為 `capability_rejected: prompt_too_long`。Claude Code 將該令牌視為與 `Prompt is too long` 相同。在 v2.1.228 之前,Claude Code 沒有識別該令牌,因此自動壓縮沒有在其上觸發。
1678
1679當自動壓縮在此輪上執行並在基礎錯誤(例如不可用的模型或驗證失敗)上失敗時,該訊息在分隔符後命名該錯誤:
1680
1681```text theme={null}
1682Prompt is too long · automatic compaction failed: <the underlying error>
1683```
1684
1685首先解決命名的錯誤;在您這樣做之前,`/compact` 會在相同錯誤上失敗。在 v2.1.229 之前,失敗的自動壓縮會顯示 `Prompt is too long` 而不顯示原因。
1686
1687單一交換對話沒有較早的輪次可以總結。當自動壓縮會在其上執行時,Claude Code 會跳過嘗試並解釋填充請求的內容。當 API 在其錯誤中不報告令牌計數時,訊息讀取:
1688
1689```text theme={null}
1690Prompt is too long · this conversation is a single exchange and cannot be compacted — the request size comes mostly from system prompt, tool definitions, or attachments.
1691```
1692
1693當 API 在其錯誤中報告令牌計數時,Claude Code 將其與自己對對話大小的估計進行比較,以判斷請求的大部分是什麼:對話自己的內容,或 Claude Code 與其一起發送的系統提示、工具定義和附加內容。當對話自己的內容是請求的大部分時,訊息讀取:
1694
1695```text theme={null}
1696Prompt is too long · the request is ~<request tokens> tokens (limit <limit>) and this conversation's own content is most of it. A single-exchange conversation cannot be compacted; start with less content (smaller files or pasted text).
1697```
1698
1699當請求的大部分在對話之外時,訊息讀取:
1700
1701```text theme={null}
1702Prompt is too long · the request is ~<request tokens> tokens (limit <limit>) but this conversation is only ~<conversation tokens> tokens — the rest is system prompt, tool definitions, and attachment content. A single-exchange conversation cannot be compacted; reduce attached files/tools or start with less context.
1703```
1704
1705在 v2.1.162 之前,Claude Code 嘗試了壓縮,並在失敗時顯示裸露的 `Prompt is too long`。
1706
1707**該怎麼辦:**
1708
1709* 在多輪對話中,執行 `/compact` 以總結較早的輪次並釋放空間,或執行 `/clear` 以重新開始。單一交換對話無法壓縮,因此請縮小請求
1710* 執行 `/context` 以查看視窗消耗內容的分解:系統提示、工具、記憶檔案和訊息
1711* 使用 `/mcp disable <name>` 禁用您未使用的 MCP 伺服器,以從上下文中移除其工具定義
1712* 修剪大型 `CLAUDE.md` 記憶檔案,或將指示移至 [路徑範圍規則](/docs/zh-TW/memory#path-specific-rules),這些規則僅在相關時載入
1713* 子代理繼承父工作階段的每個 MCP 工具定義,這可能在第一輪之前填滿其上下文視窗。在生成子代理之前,禁用您未使用的 MCP 伺服器。
1714* 自動壓縮預設為開啟,通常可防止此錯誤。如果您在 `/config` 中或使用 [`DISABLE_AUTO_COMPACT`](/docs/zh-TW/env-vars) 關閉了它,請將其重新開啟。如果您保持關閉,請在視窗填滿之前自己執行 `/compact`。
1715
1716請參閱 [探索上下文視窗](/docs/zh-TW/context-window) 以互動方式查看上下文如何填滿。
1717
1718<h3 id="context-exceeds-the-token-limit">
1719 上下文超過令牌限制
1720</h3>
1721
1722當對話超過模型的上下文視窗時,`/context` 在其輸出頂部顯示此警告。在您釋放空間之前,請求會失敗並出現 [`Prompt is too long`](#prompt-is-too-long)。互動式工作階段將該錯誤顯示為 `Context limit reached` 行。
1723
1724```text theme={null}
1725Context exceeds the 200k-token limit by 94k tokens — run /compact or /clear to continue.
1726```
1727
1728當您超過的限制是小於模型上下文視窗的壓縮視窗(例如 1M 上下文模型上的 200K 邊界)時,警告讀取方式不同。請求在壓縮視窗之外仍然成功;執行命名的命令以將使用量帶回其下方。
1729
1730```text theme={null}
1731Context is 94k tokens past the 200k-token compaction window — run /compact to reduce usage.
1732```
1733
1734當您設定了 [`DISABLE_COMPACT`](/docs/zh-TW/env-vars) 時,兩種形式都命名 `/clear` 而不是 `/compact`。
1735
1736**該怎麼辦:**
1737
1738* 在多輪對話中,執行 `/compact` 以總結較早的輪次並釋放空間。若要重新開始,請執行 `/clear`
1739* 有關減少使用量的更多方式,請參閱 [Prompt is too long](#prompt-is-too-long)
1740
1741在 v2.1.216 之前,`/context` 顯示使用量超過 100%,沒有警告行解釋這意味著什麼或如何恢復。
1742
1743<h3 id="error-during-compaction-conversation-too-long">
1744 壓縮期間出錯:對話過長
1745</h3>
1746
1747`/compact` 本身失敗,因為沒有足夠的可用上下文來保存它產生的摘要。
1748
1749```text theme={null}
1750Error during compaction: Conversation too long. Press esc twice to go up a few messages and try again.
1751```
1752
1753當視窗在自動壓縮觸發時已滿,或當您在看到 [`Prompt is too long`](#prompt-is-too-long) 後執行 `/compact` 時,可能會發生這種情況。在互動式工作階段中,該錯誤是 `Context limit reached` 行。
1754
1755**該怎麼辦:**
1756
1757* 按 Esc 兩次以開啟訊息清單並回退幾輪。這會從上下文中刪除最近的訊息。然後再次執行 `/compact`。
1758* 如果回退沒有釋放足夠的空間,請執行 `/clear` 以在同一專案中開始新的工作階段。您之前的對話已保存在磁碟上,可以使用 `/resume` 重新開啟。
1759
1760此訊息和其他 `/compact` 失敗以錯誤樣式顯示。在 v2.1.216 之前,它們以與成功命令輸出相同的暗淡樣式呈現,因此您可能將失敗的壓縮讀取為成功。
1761
1762<h3 id="request-too-large">
1763 請求過大
1764</h3>
1765
1766原始請求正文在令牌化之前超過了 API 的 32MB 限制,通常是由於大型貼上內容、工具結果或附加檔案。此限制與 [上下文視窗](#prompt-is-too-long) 分開。
1767
1768```text theme={null}
1769Request too large (max 32MB). Accumulated images and attachments in the conversation pushed the request over the limit. Run /compact, or double press esc to go back and remove attachments.
1770```
1771
1772當請求直接進入 Claude API 且 API 本身拒絕它時,Claude Code 會測量對話並根據恢復是否可行來措辭訊息。通過代理、閘道或雲端提供者,您會收到一般訊息。測量的形式:
1773
1774* `Request too large (max 32MB; 20.1MB of about 33.4MB is images or documents).`:影像或文件將請求推過限制。Claude Code 會在去除它們後重試。
1775* `Request too large for the API's 32MB request limit`:訊息本身超過限制,因此訊息說 `compacting cannot make it fit`,Claude Code 不會重試。在 [非互動模式](/docs/zh-TW/headless) 中,訊息告訴您減少輸入或改為開始新工作階段。
1776
1777在 v2.1.212 之前,具有足夠累積影像的對話在每輪上都失敗,出現 `Request too large (max 32MB). Double press esc to go back and try with a smaller file.` 在 v2.1.229 之前,Claude Code 為每次拒絕顯示附加建議,即使壓縮無法幫助。
1778
1779**該怎麼辦:**
1780
1781* 如果訊息說 `compacting cannot make it fit`,按 Esc 兩次以回退到添加大型內容的輪次之前,或執行 `/clear` 以重新開始
1782* 否則,執行 `/compact`,它會刪除累積的影像和附加檔案
1783* 按路徑參考大型檔案而不是貼上其內容,以便 Claude 可以分塊讀取它們
1784* 對於影像,請參閱下面的 [Image was too large](#image-was-too-large)
1785
1786<h3 id="image-was-too-large">
1787 影像過大
1788</h3>
1789
1790貼上或附加的影像超過了 API 的大小或尺寸限制。
1791
1792```text theme={null}
1793Image was too large. Double press esc to go back and try again with a smaller image.
1794API Error: 400 ... image dimensions exceed max allowed size
1795```
1796
1797Claude Code 用文字佔位符替換無法處理的影像並重試,因此後續訊息成功。在 2.1.142 之前的版本上,貼上的影像可能保留在對話中,並在後續每條訊息上重複相同的錯誤。若要在這些版本上恢復,按 Esc 兩次並回退到添加影像的輪次之前。
1798
1799**該怎麼辦:**
1800
1801* 在貼上之前調整影像大小。API 接受單個影像最長邊最多 8000 像素的影像,或當許多影像在上下文中時為 2000 像素。
1802* 拍攝相關區域的更緊密螢幕截圖,而不是整個螢幕
1803
1804<h3 id="unable-to-resize-image">
1805 無法調整影像大小
1806</h3>
1807
1808Claude Code 無法在將附加影像發送到 API 之前對其進行縮小。
1809
1810```text theme={null}
1811Unable to resize image — image processing is unavailable and dimensions could not be read from the file header. Please convert the image to PNG, JPEG, GIF, or WebP.
1812Unable to resize image — dimensions exceed the 2000x2000px limit and image processing failed. Please resize the image to reduce its pixel dimensions.
1813Unable to resize image (… raw, … base64). The image exceeds the … API limit and compression failed. Please resize the image manually or use a smaller image.
1814Unable to resize image — could not verify image dimensions are within the 2000x2000px API limit.
1815Unable to resize image — it is a CMYK JPEG, which Claude Code cannot decode, and at …px it is over the 2000x2000px limit, so it cannot be sent. Re-save it as an RGB PNG or JPEG and try again.
1816Unable to resize image — it is an animated WebP whose first frame Claude Code cannot decode, and at …px it is over the 2000x2000px limit, so it cannot be sent. Save its first frame as a PNG or JPEG and try again.
1817Unable to resize image — its pixels could not be decoded (the file may be damaged, or use an encoding Claude Code cannot read), and it is over the … API limit (… raw, … base64), so it cannot be sent. Re-save it as a PNG or JPEG and try again.
1818```
1819
1820Claude Code 通常會自動調整大型影像的大小。這些錯誤意味著無法解碼或調整影像大小以適應 API 限制。
1821
1822**該怎麼辦:**
1823
1824* 如果訊息要求您轉換影像,請將其轉換為 PNG、JPEG、GIF 或 WebP,然後再次附加。Claude Code 可以從檔案標頭驗證這些格式的尺寸,而無需解碼影像。
1825* 如果訊息報告尺寸或大小限制,請在附加之前將影像調整大小或重新壓縮到該限制以下。
1826* 如果訊息命名原因,例如 CMYK JPEG、動畫 WebP 或可能損壞的檔案,請以訊息建議的格式重新保存影像並再次附加。
1827
1828<h3 id="pdf-errors">
1829 PDF 錯誤
1830</h3>
1831
1832您附加的 PDF 無法處理。訊息在此處以非互動形式顯示;在互動式工作階段中,它們會提示您按 Esc 兩次並重試。
1833
1834```text theme={null}
1835PDF too large (max 100 pages, 20MB). Try reading the file a different way (e.g., extract text with pdftotext).
1836PDF is password protected. Try using a CLI tool to extract or convert the PDF.
1837The PDF file was not valid. Try converting it to text first (e.g., pdftotext).
1838```
1839
1840**該怎麼辦:**
1841
1842* 對於超大 PDF,要求 Claude 使用 Read 工具讀取頁面範圍而不是附加整個檔案,或使用 `pdftotext` 之類的工具提取文字並按路徑參考輸出檔案
1843* 對於受保護或無效的 PDF,移除密碼或從其來源應用程式重新匯出檔案,然後重試
1844
1845<h3 id="extra-inputs-are-not-permitted">
927 不允許額外輸入1846 不允許額外輸入
928</h3>1847</h3>
929 1848
930Claude Code 和 API 之間的代理或 LLM 閘道移除了 `anthropic-beta` 請求標頭,因此 API 拒絕了依賴它的欄位。1849Claude Code 和 API 之間的代理或 LLM 閘道去除了 `anthropic-beta` 請求標頭,因此 API 拒絕了依賴它的欄位。
1850
1851```text theme={null}
1852API Error: 400 ... Extra inputs are not permitted ... context_management
1853API Error: 400 ... Unexpected value(s) for the `anthropic-beta` header
1854```
1855
1856Claude Code 發送測試版專用欄位(例如 `context_management` 和 `effort`)以及啟用它們的 `anthropic-beta` 標頭。當閘道轉發正文但刪除標頭時,API 會看到它不識別的欄位。
1857
1858**該怎麼辦:**
1859
1860* 配置您的閘道以轉發 `anthropic-beta` 標頭。請參閱 [feature pass-through](/docs/zh-TW/llm-gateway-protocol#feature-pass-through) 以了解閘道必須轉發的內容。
1861* 作為備用方案,在啟動前設定 [`CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1`](/docs/zh-TW/env-vars)。[Disable pre-release capabilities](/docs/zh-TW/llm-gateway-protocol#disable-pre-release-capabilities) 涵蓋確切範圍。
1862
1863<h3 id="tool-input-schema-is-invalid">
1864 工具輸入架構無效
1865</h3>
1866
1867請求中的工具聲明了 `input_schema`,該架構未通過 API 的 JSON Schema 驗證,因此 API 拒絕了整個請求。`tools.` 後面的數字是失敗工具在請求的工具清單中的位置,而不是您可以查找的名稱。
1868
1869```text theme={null}
1870API Error: 400 ... tools.N.custom.input_schema: JSON schema is invalid
1871API Error: 400 ... tools.N.custom.input_schema.properties: Property keys should match pattern '^[a-zA-Z0-9_.-]{1,64}$'
1872```
1873
1874第一種形式意味著架構不是有效的 JSON Schema draft 2020-12。第二種意味著頂級屬性名稱與訊息引用的模式不匹配。
1875
1876Claude Code [在載入伺服器的工具時排除輸入架構會失敗此驗證的 MCP 工具](/docs/zh-TW/mcp#tools-with-invalid-input-schemas),因此請求通常永遠不會包含一個。
1877
1878在 [標誌擷取關閉的部署](/docs/zh-TW/env-vars#features-that-need-feature-flag-fetching) 上,或在標誌從未到達的機器上,Claude Code 在伺服器的日誌中記錄哪個工具會被拒絕,但仍然發送它,因此此錯誤仍然可能發生。
1879
1880該錯誤也可能發生在工具的架構在 `$schema` 中聲明 JSON Schema 方言而不是 draft 2020-12 的工具上。Claude Code 不會根據 JSON Schema 元架構檢查這些架構,儘管頂級屬性名稱檢查仍然適用。
1881
1882在 v2.1.216 之前,沒有部署執行排除檢查。
1883
1884**該怎麼辦:**
1885
1886* 如果您的 Claude Code 版本早於 v2.1.216,請執行 `claude update`。
1887* 移除或 [禁用](/docs/zh-TW/mcp#disable-a-server-without-removing-it) 聲明無效架構的 MCP 伺服器。該錯誤僅按位置命名工具。在 v2.1.216 或更新版本上,檢查每個伺服器的日誌以查找命名工具的行,其輸入架構會被拒絕。如果沒有日誌命名一個,請逐個禁用伺服器。
1888* 如果您維護伺服器,請修復工具的 `input_schema`。架構必須是有效的 JSON Schema,頂級屬性名稱必須為 1 到 64 個字元長,並且只能使用 ASCII 字母和數字、`_`、`.` 和 `-`。請參閱 [Tools with invalid input schemas](/docs/zh-TW/mcp#tools-with-invalid-input-schemas)。
1889
1890<h3 id="theres-an-issue-with-the-selected-model">
1891 選定的模型有問題
1892</h3>
1893
1894配置的模型名稱未被識別,或您的帳戶缺乏對其的存取權限。從 v2.1.160 開始,尾部提示(此處以其互動形式顯示)因表面而異。
1895
1896```text theme={null}
1897There's an issue with the selected model (claude-...). It may not exist or you may not have access to it. Run /model to pick a different model.
1898```
1899
1900**該怎麼辦:**
1901
1902* **互動式 CLI**:執行 `/model` 以從您帳戶可用的模型中選擇。
1903* **非互動模式 (`-p`)**:使用有效的別名或 ID 傳遞 `--model`,或設定 [`ANTHROPIC_MODEL`](/docs/zh-TW/env-vars)。錯誤文字在此表面上顯示 `Run --model`。
1904* **Agent SDK**:錯誤文字省略提示,因為模型是以程式設計方式設定的。在 TypeScript 中的 [`Options` 上設定 `model`](/docs/zh-TW/agent-sdk/typescript#options),或在 Python 中設定 [`ClaudeAgentOptions(model=...)`](/docs/zh-TW/agent-sdk/python#claudeagentoptions),並處理結構化 `model_not_found` 錯誤以顯示您自己的重試或模型選擇器。
1905* 使用別名(例如 `sonnet` 或 `opus`)而不是完整版本化 ID。別名解析為維護的預設值,因此它們不會過時。請參閱 [Model configuration](/docs/zh-TW/model-config)。
1906* 如果錯誤的模型在 CLI 中不斷出現,則在某處設定了過時的 ID。按 [優先順序](/docs/zh-TW/model-config#setting-your-model) 檢查您可以設定模型的位置,並移除過時的值。
1907* 新推出的模型可能在 Anthropic API 上可用,但在 Amazon Bedrock、Google Cloud 的 Agent Platform 或 Microsoft Foundry 上可用之前。如果您在其中一個提供者上固定了新模型 ID 並看到此錯誤,請檢查您提供者的模型目錄以了解您區域的可用性,並保持固定先前版本,直到新版本出現。
1908* Claude Code 將過期的 claude.ai 登入報告為 [Login expired](#login-expired),而不是此錯誤。在 v2.1.206 之前,無法再刷新的過期登入對每個模型失敗,出現此錯誤;如果您在較舊版本上看到這種情況,請執行 `/login`。
1909* 對於 Google Cloud 的 Agent Platform 部署,請參閱 [Google Cloud 的 Agent Platform 故障排除](/docs/zh-TW/google-vertex-ai#troubleshooting)。
1910
1911<h3 id="model-is-not-a-recognized-model-id">
1912 模型不是公認的模型 ID
1913</h3>
1914
1915您傳遞給模型切換的模型字串不是模型別名、此 Claude Code 版本知道的模型 ID,也不是以 `claude-` 開頭的 ID。常見原因是 ID 中的拼寫錯誤、顯示名稱(例如 `Sonnet 5`,其中需要 ID `claude-sonnet-5`),或只有較新 Claude Code 版本識別的別名。Claude Code 立即拒絕切換。在 v2.1.200 之前,Claude Code 保存字串並在下一個請求上失敗,出現 [There's an issue with the selected model](#theres-an-issue-with-the-selected-model)。
1916
1917```text theme={null}
1918Model "claud-sonnet-5" is not a recognized model id. Did you mean 'claude-sonnet-5'?
1919```
1920
1921尾部提示命名最接近的匹配別名或模型 ID。當沒有足夠接近的內容時,它讀取 `Run /model to see available models.`。
1922
1923Claude Code 在請求切換的時刻在本地產生此錯誤,在任何 API 請求之前。它適用於通過 [Agent SDK](/docs/zh-TW/agent-sdk/typescript) `setModel()` 方法設定模型、由執行 Claude Code CLI 的應用程式(例如 [Desktop app](/docs/zh-TW/desktop))設定,或當您從通過 [Remote Control](/docs/zh-TW/remote-control) 連接的裝置選擇模型時。在 v2.1.260 之前,檢查不涵蓋 Remote Control 選擇,因此 Claude Code 應用了選擇,下一個請求失敗,出現 [There's an issue with the selected model](#theres-an-issue-with-the-selected-model)。
1924
1925**該怎麼辦:**
1926
1927* 執行 `/model` 不帶引數以開啟選擇器並從您帳戶可用的模型中選擇,然後傳遞那裡顯示的別名或 ID
1928* 如果您使用了較新 Claude Code 版本支援的別名,請執行 `claude update`。以 `claude-` 開頭的完整 ID 即使模型比您的 Claude Code 版本更新,也會通過此本地檢查。伺服器仍然可能需要該模型的最低版本;請參閱 [Claude Code does not support this model](#claude-code-does-not-support-this-model)。
1929* v2.1.200 之前保存的模型不會被此檢查修復。如果過時的值不斷出現,請從 [Setting your model](/docs/zh-TW/model-config#setting-your-model) 下列出的位置移除它。
1930* 檢查僅在 Anthropic API 上執行。在任何其他提供者或閘道上,包括自訂 `ANTHROPIC_BASE_URL`,提供者定義模型名稱,因此 Claude Code 接受任何字串並將其傳遞。Claude Code 仍然可以在請求時寫入 [unrecognized-model diagnostic line](#unrecognized-model-id-on-a-request),在每個提供者上。
1931
1932<h3 id="model-not-found">
1933 找不到模型
1934</h3>
1935
1936您使用 `/model <name>` 選擇了模型,Claude Code 無法確認存在具有該名稱的模型。當名稱不是 [model alias](/docs/zh-TW/model-config#model-aliases) 或 Claude Code 在本地接受的另一種拼寫時,`/model` 使用最小 API 請求驗證它,此錯誤通常是您的 API 端點的答案。無法成為模型 ID 的名稱(例如包含空格的名稱)會收到相同訊息。
1937
1938```text theme={null}
1939Model 'claude-opus-9' not found
1940```
1941
1942在具有提供者特定模型 ID 的提供者上,訊息可能會添加 `Try '...' instead` 建議,該建議命名您提供者的備用模型 ID。
1943
1944**該怎麼辦:**
1945
1946* 執行 `/model` 不帶引數並從您帳戶可用的模型中選擇,或使用 [model alias](/docs/zh-TW/model-config#model-aliases)(例如 `sonnet`),它解析為維護的預設值
1947* 如果您輸入了完整 ID,請根據您提供者的模型目錄檢查它。新推出的模型可能在 Anthropic API 上可用,但您的提供者或區域尚未提供。
1948* 在 v2.1.265 之前,`/model` 也以此錯誤拒絕了 `opusplan[1m]` 別名拼寫。在這些版本上,更新 Claude Code,或在 [settings](/docs/zh-TW/model-config#setting-your-model) 中或使用 `--model` 設定模型。
1949
1950<h3 id="claude-opus-is-not-available-with-the-claude-pro-plan">
1951 Claude Opus 不適用於 Claude Pro 方案
1952</h3>
1953
1954您的有效訂閱方案不包括您選擇的模型。
1955
1956```text theme={null}
1957Claude Opus is not available with the Claude Pro plan. If you have updated your subscription plan recently, run /logout and /login for the plan to take effect.
1958```
1959
1960**該怎麼辦:**
1961
1962* 執行 `/model` 並選擇您的方案包括的模型
1963* 如果您最近升級了方案但仍然看到這個,請執行 `/logout` 然後 `/login`。儲存的令牌反映您登入時的方案,因此在現有工作階段中在網路上升級不會生效,直到您重新驗證。
1964* 請參閱 [claude.com/pricing](https://claude.com/pricing) 以了解每個方案包括哪些模型
1965
1966<h3 id="claude-code-does-not-support-this-model">
1967 Claude Code 不支援此模型
1968</h3>
1969
1970API 因為您的 Claude Code 版本低於所需最低版本而拒絕了請求,出現 400。您選擇的模型需要較新版本(伺服器按模型檢查),或您的組織政策需要一個。400 帶有錯誤代碼 `claude_code_version_too_old`,訊息說明適用的最低版本。
1971
1972```text theme={null}
1973API Error: 400 Claude Code 2.1.219 does not support this model; version 2.1.255 or newer is required. Run 'claude update', or update the Claude desktop app, then try again.
1974```
1975
1976組織政策措辭讀取:
1977
1978```text theme={null}
1979API Error: 400 Claude Code 2.1.240 is older than the minimum version required by your organization's policy. Run 'claude update', or update the Claude desktop app, to continue.
1980```
1981
1982**該怎麼辦:**
1983
1984* 執行 `claude update`,或更新 Claude 桌面應用程式,然後開始新的工作階段
1985* 對於按模型措辭,您可以通過使用 `/model` 切換到另一個模型來在目前工作階段中繼續工作
1986* 對於組織政策措辭,在繼續之前更新
1987
1988<h3 id="model-is-restricted-by-your-organizations-settings">
1989 模型受您的組織設定限制
1990</h3>
1991
1992您的組織管理員已在 claude.ai 管理控制台中禁用此模型,或它被受管設定中的 [`availableModels`](/docs/zh-TW/model-config#restrict-model-selection) 允許清單排除。當受限制的模型使用 `--model`、`ANTHROPIC_MODEL` 或 `model` 設定設定時,Claude Code 替換允許的模型並繼續。為受限制的模型輸入 `/model <name>` 被拒絕,出現 `Run /model to choose a different model.`,工作階段保持其目前模型。
1993
1994```text theme={null}
1995Model "claude-opus-4-8" is restricted by your organization's settings. Using claude-sonnet-4-6 instead.
1996```
1997
1998以代理、技能或命令名稱為前綴的通知意味著限制適用於該 [子代理的請求模型](/docs/zh-TW/sub-agents#choose-a-model):子代理在替換模型上執行,您的工作階段模型保持不變。在 v2.1.223 之前,Claude Code 僅對使用 Agent 工具啟動的子代理顯示通知。
1999
2000Claude Code 將模型系列別名(`opus`、`sonnet`、`haiku` 或 `fable` 之一)視為對該系列的請求,而不是對其最新版本的請求。在 Anthropic API 和 [Claude Platform on AWS](/docs/zh-TW/claude-platform-on-aws) 上,受限制的系列別名解析為您的組織和 `availableModels` 允許清單允許的系列的最新版本,替換通知命名該版本。Claude Code 僅在系列的每個版本都受限制時拒絕 `/model <alias>`。在 v2.1.205 之前,系列別名基於其最新版本單獨替換或拒絕,即使同一系列的較舊版本被允許。
2001
2002**該怎麼辦:**
2003
2004* 執行 `/model` 以從您的組織允許的模型中選擇。受限制的模型在選擇器中隱藏。
2005* 如果受限制的模型在 `--model`、`ANTHROPIC_MODEL`、設定檔案的 `model` 欄位或 [subagent](/docs/zh-TW/sub-agents#choose-a-model)、技能或命令的 `model` frontmatter 中設定,請移除或更新該值,以便通知不會再次出現
2006* 如果您需要存取受限制的模型,請要求您的組織管理員啟用它。請參閱 [Organization model restrictions](/docs/zh-TW/model-config#organization-model-restrictions)。
2007
2008<h3 id="model-switch-was-blocked-by-a-premodelswitch-hook">
2009 模型切換被 PreModelSwitch hook 阻止
2010</h3>
2011
2012[PreModelSwitch hook](/docs/zh-TW/hooks#premodelswitch) 沒有批准您或用戶端請求的模型切換,因此工作階段保持其目前模型。當切換來自 [Agent SDK](/docs/zh-TW/agent-sdk/overview) 主機或 [Remote Control](/docs/zh-TW/remote-control) 而不是您輸入的命令時,訊息讀取 `Model switch blocked by a PreModelSwitch hook` 而不命名目標模型。
2013
2014```text theme={null}
2015Model switch to Opus 4.6 was blocked by a PreModelSwitch hook: Opus 4.6 is retired for this project. Use a newer model.
2016```
2017
2018冒號後的原因說明拒絕切換的原因:
2019
2020* **hook 寫入的原因**:PreModelSwitch hook 在 [拒絕切換或要求確認](/docs/zh-TW/hooks#premodelswitch-decision-control) 時提供了該原因。解決它要求的內容,或選擇您的 hook 允許的模型。
2021* **`PreModelSwitch hook <name> did not respond before its timeout`**:在其 [timeout](/docs/zh-TW/hooks#timeouts) 之前沒有回答的 hook 會阻止切換。修復掛起的命令或提高該 hook 的 `timeout`,然後再次切換。
2022* **`confirmation required, and this session cannot ask`**:hook 回答 `ask` 而沒有原因,控制請求無法顯示確認提示。[`-p` 執行](/docs/zh-TW/headless) 中的控制請求以原因後的 `(run /model interactively to confirm)` 報告相同狀況。從互動式工作階段進行切換,或更改 hook 對此模型的決定。
2023* **`so organization-managed PreModelSwitch hooks could not be checked`**:Claude Code 無法判斷您的組織的 [managed plugins](/docs/zh-TW/settings-reference#enabledplugins) 提供哪些 PreModelSwitch hook,例如因為受管外掛程式無法載入。其中一個 hook 可能會阻止切換,因此 Claude Code 拒絕而不是應用未檢查的切換。原因的開始命名失敗的內容。Claude Code 在每次切換嘗試時重新檢查,因此已清除的失敗停止阻止;如果它繼續失敗,執行 `claude --debug` 並再次切換以捕獲詳細資訊,然後修復外掛程式或要求您的管理員修復它。
2024* **`a PreModelSwitch hook failed before answering`** 或 **`PreModelSwitch hooks were cancelled (the control stream closed) before answering`**:hook 執行在沒有判決的情況下結束,Claude Code 不將其視為批准。執行 `claude --debug` 以查看失敗的內容,然後再次切換。
2025
2026在 v2.1.260 之前,受管外掛程式拒絕讀取 `plugin hooks could not be loaded, so PreModelSwitch hooks could not be checked; see the debug log`。Claude Code 重試外掛程式載入一次,然後在工作階段中拒絕後續切換,即使您的組織沒有受管外掛程式。在這些版本上重新啟動工作階段以再次執行外掛程式載入。
2027
2028<h3 id="couldnt-save-it-as-your-default">
2029 無法將其保存為您的預設值
2030</h3>
2031
2032您選擇了一個模型以保存為您的預設值,例如使用 `/model <name>` 或 `/model` 選擇器中的 Enter,Claude Code 無法將選擇寫入您的使用者設定檔案 `~/.claude/settings.json`。切換本身已應用,因此目前工作階段在您選擇的模型上執行,但您的預設值保持不變,下一個工作階段在舊值上開始。
2033
2034```text theme={null}
2035Set model to Fable 5.1 for this session only · couldn't save it as your default: ~/.claude/settings.json can't be written (EROFS)
2036```
2037
2038檔案路徑後的原因說明失敗的內容:
2039
2040* **`can't be written (<code>)`**:寫入失敗,出現括號中的作業系統錯誤代碼,例如當檔案或它連結到的檔案位於拒絕寫入的檔案系統上時的 `EROFS`。使檔案可寫入並再次切換。如果另一個工具產生檔案,請在該工具中設定 `model` 鍵;請參閱 [A change you made in Claude Code is lost in new sessions](/docs/zh-TW/settings#a-change-you-made-in-claude-code-is-lost-in-new-sessions)。
2041* **`isn't valid JSON`**:磁碟上的檔案不解析,Claude Code 保持不動而不是覆蓋它無法讀回的內容。修復語法錯誤,然後再次切換;請參閱 [Fix a broken settings file](/docs/zh-TW/settings#fix-a-broken-settings-file)。
2042
2043以 `couldn't confirm it was saved as your default (~/.claude/settings.json is still being written)` 結尾的通知意味著寫入在三秒後未完成。它在背景中繼續,因此預設值可能仍然被保存;檢查您的下一個工作階段開始的模型,或再次執行 `/model <name>`。
2044
2045在 v2.1.265 之前,通知說模型被 `saved as your default for new sessions`,即使寫入失敗。
2046
2047<h3 id="thinking-type-enabled-is-not-supported-for-this-model">
2048 此模型不支援 thinking.type.enabled
2049</h3>
2050
2051您的 Claude Code 版本早於所選模型的最低版本。CLI 發送了模型不再接受的思考配置。
2052
2053```text theme={null}
2054API Error: 400 ... "thinking.type.enabled" is not supported for this model. Use "thinking.type.adaptive" and "output_config.effort" to control thinking behavior.
2055```
2056
2057**該怎麼辦:**
2058
2059* 執行 `claude update` 並重新啟動 Claude Code。Opus 4.7 需要 v2.1.111 或更新版本。Opus 4.8 需要 v2.1.154 或更新版本。Sonnet 5 需要 v2.1.197 或更新版本。Opus 5 需要 v2.1.219 或更新版本
2060* 如果您無法升級,執行 `/model` 並改為選擇 Opus 4.6 或 Sonnet 4.6
2061* 如果您在 [Agent SDK](/docs/zh-TW/agent-sdk/overview) 中遇到這個,請改為升級 SDK 套件。Opus 4.8 需要 TypeScript SDK v0.3.154 或更新版本和 Python SDK v0.2.88 或更新版本。Sonnet 5 需要 TypeScript SDK v0.3.197 或更新版本。Opus 5 需要 TypeScript SDK v0.3.219 或更新版本
2062
2063<h3 id="effort-isnt-available-with-thinking-turned-off">
2064 關閉思考時努力不可用
2065</h3>
2066
2067您關閉了 [extended thinking](/docs/zh-TW/model-config#extended-thinking) 並以 [effort level](/docs/zh-TW/model-config#adjust-effort-level) 高於 `high` 執行。模型不接受該組合,因此 API 拒絕了請求。
2068
2069```text theme={null}
2070API Error: Effort 'xhigh' isn't available with thinking turned off on this model · run /effort high to continue, or turn thinking back on (unset MAX_THINKING_TOKENS=0)
2071```
2072
2073**該怎麼辦:**
2074
2075* [降低努力級別](/docs/zh-TW/model-config#set-the-effort-level) 至 `high` 或以下。
2076* 打開思考,例如通過取消設定 [`MAX_THINKING_TOKENS`](/docs/zh-TW/env-vars) 或從您的設定中移除 [`"alwaysThinkingEnabled": false`](/docs/zh-TW/settings-reference#alwaysthinkingenabled)。
2077
2078在 v2.1.242 之前,Claude Code 顯示 API 自己的訊息:`API Error: 400 output_config.effort 'xhigh' is not supported when thinking is disabled on this model. Use effort 'high' or below, or enable thinking.` 在 v2.1.251 之前,Claude Code 在您設定的努力級別發送請求,因此 Opus 5 拒絕了關閉思考時高於 `high` 的每個請求。Claude Code 現在改為向它知道拒絕該組合的模型(例如 Opus 5)發送努力 `high`,因此在 v2.1.251 或更新版本上,此錯誤僅從 Claude Code 不知道拒絕它的模型到達您。
2079
2080<h3 id="thinking-budget-exceeds-output-limit">
2081 思考預算超過輸出限制
2082</h3>
2083
2084配置的擴展思考預算超過最大回應長度,因此實際答案沒有剩餘空間。
2085
2086```text theme={null}
2087API Error: 400 ... max_tokens must be greater than thinking.budget_tokens
2088```
2089
2090Claude Code 在 Anthropic API 上自動調整這些值。當 [`MAX_THINKING_TOKENS`](/docs/zh-TW/env-vars) 設定高於提供者的輸出限制,或當計畫模式提高思考預算時,您通常在 Amazon Bedrock 或 Google Cloud 的 Agent Platform 上看到此錯誤。
2091
2092**該怎麼辦:**
2093
2094* 降低 `MAX_THINKING_TOKENS`,或提高 [`CLAUDE_CODE_MAX_OUTPUT_TOKENS`](/docs/zh-TW/env-vars) 高於思考預算
2095* 請參閱 [Extended thinking](/docs/zh-TW/model-config#extended-thinking) 以了解預算如何與輸出長度互動
2096
2097<h3 id="tool-use-or-thinking-block-mismatch">
2098 工具使用或思考區塊不匹配
2099</h3>
2100
2101對話歷史記錄到達 API 時處於不一致狀態,通常在工具呼叫被中斷或輪次在串流中途被編輯後。
2102
2103```text theme={null}
2104API Error: 400 due to tool use concurrency issues. Run /rewind to recover the conversation.
2105API Error: 400 ... unexpected `tool_use_id` found in `tool_result` blocks
2106API Error: 400 ... thinking blocks ... cannot be modified
2107```
2108
2109所有三個變體都意味著相同的事情:歷史記錄中 `tool_use`、`tool_result` 和 `thinking` 區塊的序列不再與 API 期望的相符。
2110
2111**該怎麼辦:**
2112
2113* 如果您使用 Opus 4.7 或 Opus 4.8,請先執行 `claude update`。v2.1.156 之前的版本可以在正常工具使用期間觸發此錯誤,`/rewind` 不會清除它。
2114* 執行 `/rewind`,或按 Esc 兩次,以回退到損壞輪次之前的檢查點並從那裡繼續。請參閱 [Checkpointing](/docs/zh-TW/checkpointing) 以了解檢查點如何建立和恢復。
2115
2116<h3 id="unsupported-tool-content-removed">
2117 移除了不支援的工具內容
2118</h3>
2119
2120當 Claude Code 直接連接到 Anthropic API 並載入或預覽已保存的工作階段時,它會移除 Anthropic API 不接受的工具內容,並在兩個思考區塊之間移除的內容所在的位置留下此行:
2121
2122```text theme={null}
2123[Unsupported tool content removed]
2124```
2125
2126當 API 格式以外的內容回答時,此類內容到達工作階段檔案,通常是通過 [`ANTHROPIC_BASE_URL`](/docs/zh-TW/env-vars) 設定的第三方代理,它轉譯另一個提供者的工具呼叫。Claude Code 僅在工作階段直接連接到 Anthropic API 時移除它,並在工作階段通過代理或在另一個提供者上執行時按原樣載入已保存的歷史記錄。在 v2.1.246 之前,Claude Code 將工具使用及其結果發送回 API,已恢復工作階段的每輪都失敗,出現 400 錯誤,例如 `messages.1.content.0.server_tool_use.name: Input should be 'web_search', 'web_fetch', ...`。
2127
2128**該怎麼辦:**
2129
2130* 當您看到佔位符行時,無需執行任何操作。工作階段在沒有移除內容的情況下繼續。
2131* 如果已恢復工作階段的每輪都失敗,出現 400 錯誤,請執行 `claude update` 並再次恢復工作階段。v2.1.246 之前的版本不會移除內容。
2132
2133<h3 id="usage-policy-refusal">
2134 使用政策拒絕
2135</h3>
2136
2137API 拒絕回應,因為對話中的內容觸發了 [Usage Policy](https://www.anthropic.com/legal/aup) 檢查。訊息包括您可以引用給支援的請求 ID,如果您認為拒絕不正確。
2138
2139```text theme={null}
2140API Error: Opus 4.6 can't help with this. Start a new session to continue.
2141
2142Send feedback with /feedback or learn more: https://www.anthropic.com/legal/aup
2143```
2144
2145訊息命名拒絕的模型,或當沒有記錄模型時命名 `Claude`。
2146
2147檢查評估完整對話,而不僅是您的最新提示,因此在同一工作階段中發送新訊息通常會重新觸發相同的拒絕。使用 `--continue` 或 `--resume` 退出並重新開啟工作階段後也是如此,因為磁碟上的文字記錄仍然包含觸發內容。在 [Amazon Bedrock](/docs/zh-TW/amazon-bedrock)、[Google Cloud 的 Agent Platform](/docs/zh-TW/google-vertex-ai) 和 [Microsoft Foundry](/docs/zh-TW/microsoft-foundry) 上,此訊息也涵蓋模型的安全措施標記為網路安全主題的請求。請參閱 [Safety measures flagged a cybersecurity topic](#safety-measures-flagged-a-cybersecurity-topic)。
2148
2149在 v2.1.219 之前,訊息讀取 `Claude Code is unable to respond to this request, which appears to violate our Usage Policy (https://www.anthropic.com/legal/aup). Please double press esc to edit your last message or start a new session for Claude Code to assist with a different task.`
2150
2151**該怎麼辦:**
2152
2153* 按 Esc 兩次或執行 `/rewind` 以回退到觸發拒絕的輪次之前的檢查點,然後重新措辭或採取不同的方法。請參閱 [Checkpointing](/docs/zh-TW/checkpointing)。
2154* 如果您無法識別哪個輪次導致了它,執行 `/clear` 以在同一專案中開始新的對話。您之前的對話保存在磁碟上,並在 `/resume` 中保持可用。
2155* 在 [非互動模式](/docs/zh-TW/headless) (`-p`) 中,其中倒帶不可用,使用重新措辭的提示在沒有 `--continue` 的新工作階段中重試。政策檢查因模型而異,因此使用 `--model` 切換到不同的模型也可能在某些情況下解決拒絕。
2156
2157<h3 id="safety-measures-flagged-a-cybersecurity-topic">
2158 安全措施標記了網路安全主題
2159</h3>
2160
2161模型的安全措施將對話中的內容標記為網路安全主題。訊息命名標記請求的模型:
2162
2163```text theme={null}
2164API Error: Opus 4.8's safeguards flagged this message. Our intentionally broad safeguards allow us to deliver more capabilities faster, but can sometimes flag legitimate cybersecurity work. Apply to the Cyber Verification Program to reduce these interruptions. Send feedback with /feedback or learn more: https://support.claude.com/en/articles/14604842-real-time-cyber-safeguards-on-claude
2165```
2166
2167訊息連結到 [Cyber Verification Program](https://support.claude.com/en/articles/14604842-real-time-cyber-safeguards-on-claude),它為合法網路安全工作授予存取權限。
2168
2169在 [Amazon Bedrock](/docs/zh-TW/amazon-bedrock)、[Google Cloud 的 Agent Platform](/docs/zh-TW/google-vertex-ai) 和 [Microsoft Foundry](/docs/zh-TW/microsoft-foundry) 上,網路安全標記會改為產生 [Usage Policy refusal](#usage-policy-refusal) 訊息。
2170
2171防護本身是伺服器端的,早於 v2.1.203;自那時以來的用戶端版本僅更改了訊息的措辭。
2172從 v2.1.203 到 v2.1.218,訊息讀取 `<model> has safety measures that flagged this message for a cybersecurity topic. To learn about the Cyber Verification Program and apply for access, visit our help center:` 後跟相同的說明中心連結,互動式工作階段附加 `If you were not engaging in a cybersecurity topic, please send feedback via /feedback.`
2173在 v2.1.203 之前,它讀取 `<model>'s safeguards flagged this message for a cybersecurity topic. If your work requires this access, you can apply for an exemption:` 後跟豁免表單連結。
2174
2175**該怎麼辦:**
2176
2177* 如果您的工作需要此內容,請通過 [Cyber Verification Program](https://support.claude.com/en/articles/14604842-real-time-cyber-safeguards-on-claude) 申請存取權限
2178* 如果您的請求不是關於網路安全主題,執行 `/feedback` 以報告誤報
2179* 若要在同一工作階段中繼續工作,按 Esc 兩次或執行 `/rewind` 以回退到觸發標記的輪次之前的檢查點,然後採取不同的方法。請參閱 [Checkpointing](/docs/zh-TW/checkpointing)。
2180
2181<h2 id="installation-errors">
2182 安裝錯誤
2183</h2>
2184
2185這些錯誤會在安裝或更新 Claude Code 時出現,來自 [安裝指令碼](/docs/zh-TW/setup#install-claude-code)、`claude install` 或 `claude update`。如需 `command not found`、PATH、權限和設定期間的 TLS 問題,請參閱 [疑難排解安裝和登入](/docs/zh-TW/troubleshoot-install)。
2186
2187<h3 id="installation-was-killed-before-it-could-finish">
2188 安裝在完成前被中止
2189</h3>
2190
2191安裝指令碼會在 `claude install` 步驟被信號終止時報告。在 Linux 上,結束代碼 137 表示程序收到 SIGKILL,在低記憶體主機上通常是核心記憶體不足 (OOM) 殺手。指令碼會列印此說明並以代碼 137 結束:
2192
2193```text theme={null}
2194Installation was killed before it could finish (exit code 137). This usually means the system ran out of memory.
2195Claude Code needs roughly 512MB of free memory to install. Free up memory, then run this script again.
2196```
2197
2198對於任何其他致命信號,以及 macOS 上的結束代碼 137,指令碼會列印 `Installation was killed before it could finish (exit code <N>)`,其中包含實際結束代碼,並省略記憶體不足的說明。該訊息來自 macOS 和 Linux 使用的安裝指令碼,也涵蓋 WSL 內的安裝;原生 Windows 安裝指令碼永遠不會列印它。在 v2.1.200 之前,指令碼只以 shell 的裸 `Killed` 行結束。
2199
2200**該怎麼做:**
2201
2202* 停止其他程序以釋放記憶體,然後重新執行安裝程式
2203* 新增交換空間或移至更大的執行個體。請參閱 [在低記憶體 Linux 伺服器上安裝被中止](/docs/zh-TW/troubleshoot-install#install-killed-on-low-memory-linux-servers) 以取得交換檔案命令。
2204
2205<h3 id="the-connection-dropped-while-downloading-the-update">
2206 下載更新時連線中斷
2207</h3>
2208
2209在 `claude install`、`claude update` 或 [自動更新程式](/docs/zh-TW/setup#auto-updates) 擷取 Claude Code 二進位檔案時,與下載伺服器的連線已關閉,且重試未能復原。Claude Code 會在連線中斷、傳輸停滯或下載的檔案未通過總和檢查時重試下載,總共最多三次嘗試。已完成的 HTTP 錯誤(例如 404)不會重試,因為伺服器已經回應。在 v2.1.202 之前,單一連線中斷會立即導致下載失敗,並顯示裸錯誤 `aborted`,而不是重試。
2210
2211```text theme={null}
2212The connection dropped while downloading the update (attempt 3/3: aborted). Check your network — proxies sometimes cut off large downloads.
2213```
2214
2215括號中的文字命名失敗的嘗試和基礎網路錯誤。`claude update` 在 stderr 上以 `Error: Failed to install native update` 開頭該訊息。
2216
2217保持連線但未在 10 分鐘內完成的下載會失敗,並顯示 `Download timed out: exceeded the total deadline`。Claude Code 不會重試逾時的下載,因為連線太慢而無法在期限內完成,在立即重試時也不會完成。以下步驟適用於兩個訊息。
2218
2219通常的原因是代理或閘道在傳輸完成前關閉長傳輸。Claude Code 二進位檔案是大型下載,因此永遠不會影響正常 API 流量的代理連線限制仍然可能中斷它。
2220
2221**該怎麼做:**
2222
2223* 再次執行 `claude update`。在網路狀況良好的情況下,下載通常在下次執行時成功。對於逾時訊息,請從更快或限制較少的網路重新執行。
2224* 如果您的網路需要代理,請在執行安裝程式或 `claude update` 之前設定 `HTTPS_PROXY`。請參閱 [檢查網路連線](/docs/zh-TW/troubleshoot-install#check-network-connectivity)。
2225* 如果公司代理持續關閉傳輸,請要求您的網路團隊允許從 `downloads.claude.ai` 進行完整下載。請參閱 [網路存取需求](/docs/zh-TW/network-config#network-access-requirements)。
2226* 從您的 shell 執行 `claude doctor` 以進行安裝診斷
2227
2228<h2 id="command-line-errors">
2229 命令列錯誤
2230</h2>
2231
2232這些錯誤來自 `claude` 命令列及其子命令、您在提示符處提交的命令名稱,以及 `/security-review` 等命令,這些命令在執行其提示之前透過執行 shell 命令來收集上下文。`/tui` 也會產生錯誤,它會重新啟動 CLI。
2233
2234<h3 id="conflict-between-bg-and-print">
2235 \--bg 和 --print 之間的衝突
2236</h3>
2237
2238此訊息需要 Claude Code v2.1.198 或更新版本。您在同一個 `claude` 呼叫中結合了 `--bg` 與 `-p` 或 `--print`。`--bg` 啟動一個[背景工作階段](/docs/zh-TW/agent-view#from-your-shell),您稍後可以使用 `claude agents` 附加到該工作階段,而 `--print` 以[非互動模式](/docs/zh-TW/headless)執行,永遠不會啟動 `claude agents` 附加到的互動工作階段。在 v2.1.198 之前,此組合會無聲地建立一個永遠無法附加的背景工作。
2239
2240```text theme={null}
2241--bg 和 --print 衝突:--print 永遠不會啟動 `claude agents` 附加到的互動工作階段,所以該工作將無法附加。提示是位置引數 — 移除 --print:`claude --bg '<task>'`。
2242```
2243
2244**該怎麼做:**
2245
2246* 移除 `-p` 或 `--print`。`--bg` 將提示作為其位置引數,所以 `claude --bg "<task>"` 是完整命令。請參閱[從您的 shell 分派新代理](/docs/zh-TW/agent-view#from-your-shell)。
2247* 若要以非互動模式執行提示並列印結果而不是建立背景工作階段,請移除 `--bg` 並執行 `claude -p "<task>"`
2248
2249<h3 id="invalid-agents-configuration">
2250 無效的 --agents 設定
2251</h3>
2252
2253您傳遞給 `--agents` 的值無效,所以 `claude` 以代碼 1 結束而不是啟動工作階段。當您傳遞 `--safe-mode`、`--resume` 或 `--continue`,或設定 [`CLAUDE_CODE_SAFE_MODE`](/docs/zh-TW/env-vars#variables) 時,Claude Code 不會檢查該值並啟動工作階段。在 v2.1.242 之前,Claude Code 無論如何都會啟動工作階段,並遺漏它無法載入的定義。
2254
2255```text theme={null}
2256Error: Invalid --agents configuration:
2257<what failed>
2258```
2259
2260第一行之後的內容取決於該值如何失敗。Claude Code 按順序執行這些檢查,並在第一個失敗的檢查處停止。如果您的值有兩種問題,您只會在修復第一個問題後看到第二個:
2261
22621. 當該值無法解析為 JSON 時,Claude Code 會列印一行 `invalid JSON:` 行,其中包含 JSON 解析器自己的訊息
22632. 當它解析但代理定義與 [CLI 定義的子代理](/docs/zh-TW/sub-agents#choose-the-subagent-scope)的架構不符時,Claude Code 會為每個問題列印一行
22643. 當代理名稱以 `-` 開頭時,Claude Code 會列印 `<name>: agent names must not start with '-'`
2265
2266當有超過 20 行問題時,Claude Code 會列印前 20 行,並用 `…and N more` 取代其餘部分。
2267
2268**該怎麼做:**
2269
2270* 修復訊息列出的每個問題,然後再次執行命令。請參閱 [CLI 定義的子代理採用的欄位](/docs/zh-TW/sub-agents#choose-the-subagent-scope)。
2271
2272<h3 id="cloud-sessions-cannot-be-created-from-a-restricted-session">
2273 無法從 --restricted 工作階段建立雲端工作階段
2274</h3>
2275
2276當您使用 [`--restricted`](/docs/zh-TW/cli-reference#cli-flags) 啟動工作階段時,Claude Code 拒絕從中建立[雲端工作階段](/docs/zh-TW/claude-code-on-the-web#from-terminal-to-web),因為新工作階段將在受限程序之外執行,不會強制執行受限模式。Claude Code 在用戶端拒絕,在聯絡伺服器之前,所以不會建立任何雲端工作階段:
2277
2278```text theme={null}
2279Cloud sessions cannot be created from a --restricted session: they would not enforce it.
2280```
2281
2282**該怎麼做:**
2283
2284* 在受限工作階段中本地執行任務
2285* 如果您控制工作階段的啟動方式,請啟動新的 `claude` 工作階段而不使用 `--restricted`,並從那裡建立雲端工作階段
2286
2287在 v2.1.248 之前,Claude Code 沒有 `--restricted` 旗標;較早的版本會以未知選項錯誤拒絕該旗標。
2288
2289<h3 id="the-json-schema-value-is-not-a-valid-json-schema">
2290 \--json-schema 值不是有效的 JSON Schema
2291</h3>
2292
2293您傳遞給 [`--json-schema`](/docs/zh-TW/cli-reference#cli-flags) 的架構在[非互動模式](/docs/zh-TW/headless#get-structured-output)中未能通過 JSON Schema 編譯,所以 `claude` 以代碼 1 結束而不是執行提示。在 v2.1.205 之前,無效的架構會產生無結構的輸出而沒有錯誤,任何使用 `format` 關鍵字的架構都被視為無效。
2294
2295```text theme={null}
2296Error: --json-schema is not a valid JSON Schema: data/type must be equal to one of the allowed values
2297```
2298
2299第二個冒號之後的文字是驗證器的診斷,並命名失敗的關鍵字或位置。使用 `format` 關鍵字的架構,例如 `"format": "email"`,是有效的:Claude Code 接受 `format` 作為註釋,不強制執行它。
2300
2301Claude Code 在架構編譯之前執行兩項檢查:它拒絕無法解析為 JSON 的值,並顯示 `Error: --json-schema is not valid JSON`,以及有效但不是物件的 JSON,並顯示 `Error: --json-schema must be a JSON object`。
2302
2303**該怎麼做:**
2304
2305* 修復診斷命名的架構部分,然後重新執行命令
2306* 如果診斷是 `schema too large`,請減少架構的巢狀和 `$ref` 重複使用
2307* 請參閱[取得結構化輸出](/docs/zh-TW/headless#get-structured-output)以取得有效的架構和命令
2308
2309<h3 id="settings-file-exceeds-the-2mib-limit">
2310 設定檔超過 2MiB 限制
2311</h3>
2312
2313您傳遞給 [`--settings`](/docs/zh-TW/cli-reference#cli-flags) 的檔案大於 2 MiB,所以 `claude` 在啟動時以代碼 1 結束,而不是載入它。設定檔是一個小型 JSON 文件,所以這麼大的檔案通常意味著路徑指向錯誤的檔案。在 v2.1.214 之前,Claude Code 讀取檔案時沒有大小檢查,多 GB 的檔案或 `/dev/zero` 等裝置檔案會無限制地增加記憶體。
2314
2315```text theme={null}
2316Error: Settings file exceeds the 2MiB limit: /path/to/settings.json
2317```
2318
2319Claude Code 以相同方式拒絕不是常規檔案的 `--settings` 路徑:裝置、FIFO 或 socket 會報告 `Error: Cannot use settings file (Not a regular file (device, FIFO, or socket))`,後面跟著路徑,目錄會報告 `EISDIR` 原因。
2320
2321**該怎麼做:**
2322
2323* 將 `--settings` 指向 2 MiB 以下的常規 JSON 設定檔。請參閱[設定](/docs/zh-TW/settings)以了解格式。
2324
2325<h3 id="the-current-directory-no-longer-exists">
2326 目前目錄不再存在
2327</h3>
2328
2329您從一個在您的 shell 進入後被刪除或移動的目錄啟動 `claude`,例如另一個 shell 移除的 worktree 或臨時目錄。Claude Code 無法讀取其工作目錄,所以它在啟動工作階段之前以代碼 1 結束,在互動和[非互動](/docs/zh-TW/headless)模式中都是如此。在 v2.1.239 之前,Claude Code 會因縮小的套件來源和原始 `ENOENT ... uv_cwd` 堆疊而在 stderr 上崩潰,而不是顯示此訊息。
2330
2331```text theme={null}
2332The current directory no longer exists (it was deleted or moved). Start Claude Code from an existing directory.
2333error: The current working directory was deleted, so that command didn't work. Please cd into a different directory and try again.
2334```
2335
2336原因和修復對兩種形式都是相同的。
2337
2338當 Claude Code 因其他原因(例如權限變更)無法讀取工作目錄時,訊息會命名錯誤代碼:`Can't read the current directory (EACCES). Start Claude Code from a different directory.`
2339
2340在 macOS 上,`~/Desktop`、`~/Documents`、`~/Downloads` 或 iCloud Drive 中目錄的 `EPERM` 通常意味著 macOS 阻止您的終端應用程式存取該資料夾。讀取該資料夾的其他命令也會以相同方式失敗:即使使用 `sudo`,那裡的 `ls` 也會報告 `Operation not permitted`。
2341
2342**該怎麼做:**
2343
2344* 變更到存在的目錄,例如您的主目錄或專案目錄,然後再次執行 `claude`
2345* 如果目錄在相同路徑上被重新建立,您的 shell 仍然持有已刪除的目錄。執行 `cd "$PWD"` 或離開並重新進入目錄,然後再次執行 `claude`
2346* 對於 macOS 上的 `EPERM`,使用 Cmd+Q 結束您的終端應用程式,重新開啟它,返回該資料夾,然後執行 `claude`。如果該資料夾中的 `ls` 仍然失敗,請開啟**系統設定 > 隱私與安全 > 檔案和資料夾**,為您的終端應用程式開啟該資料夾,然後重新開啟終端
2347
2348<h3 id="directory-couldnt-be-resolved-to-a-real-location">
2349 目錄無法解析為實際位置
2350</h3>
2351
2352您為工作目錄的子目錄執行了 `/add-dir`,Claude Code 無法將目錄解析為其實際位置。
2353
2354您已經可以存取工作目錄的子目錄,所以 `/add-dir` 只會載入其技能、命令和代理。在載入它們之前,Claude Code 會檢查目錄的實際位置(解析任何符號連結)是否在工作目錄內。當 Claude Code 無法解析該位置時,它不會載入任何內容並顯示此訊息:
2355
2356```text theme={null}
2357packages/app couldn't be resolved to a real location, so its skills, commands, and agents weren't loaded. Check that it is a directory inside the working directory and try again.
2358```
2359
2360**該怎麼做:**
2361
2362* 檢查路徑是否命名工作目錄內的真實目錄,然後再次執行 `/add-dir`
2363* 訊息不會改變您的檔案存取;它只報告目錄的 `.claude/` 內容未被載入
2364
2365在 v2.1.261 之前,當工作目錄在 `/net/<host>` 自動掛載上時,此訊息也會為每個 `/add-dir <subdirectory>` 出現,Claude Code 根據設計拒絕解析路徑;目錄很好,重試無法幫助。
2366
2367<h3 id="workspace-not-trusted-when-starting-remote-control">
2368 啟動遠端控制時工作區未受信任
2369</h3>
2370
2371您在未信任的目錄中使用 `claude remote-control` 或其 `claude rc` 別名啟動[遠端控制](/docs/zh-TW/remote-control)伺服器模式。該命令本身不會顯示工作區信任對話框,所以它以代碼 1 結束並命名修復:
2372
2373```text theme={null}
2374Error: Workspace not trusted. Please run `claude` in /Users/you/project first to review and accept the workspace trust dialog.
2375```
2376
2377在您的主目錄中,訊息是不同的,因為工作區信任對話框永遠不會為主目錄儲存信任,所以在那裡接受它無法滿足此檢查。在 v2.1.214 之前,主目錄顯示上述訊息,其建議在那裡無法成功。
2378
2379```text theme={null}
2380Error: Workspace not trusted. /Users/you is your home directory, and for security home-directory trust is never saved, so running `claude` here first won't help. Run `claude rc` from a project directory instead (run `claude` there once to accept the trust dialog).
2381```
2382
2383**該怎麼做:**
2384
2385* 在目錄中執行 `claude`,接受[工作區信任對話框](/docs/zh-TW/permissions#project-allow-rules-and-workspace-trust),然後再次執行 `claude remote-control`
2386* 在您的主目錄中,變更到專案目錄並在那裡啟動遠端控制
2387
2388<h3 id="not-carried-over-to-the-sessions-remote-control-starts">
2389 未帶到遠端控制啟動的工作階段
2390</h3>
2391
2392您使用全域 `claude` 旗標在 `remote-control` 動詞之前啟動[遠端控制](/docs/zh-TW/remote-control),該旗標會限制或設定遠端控制啟動的工作階段,例如 `--settings`、`--setting-sources`、`--permission-mode`、`--disallowed-tools` 或 `--mcp-config`。放在動詞之前的旗標永遠不會到達這些工作階段。Claude Code 拒絕啟動,並命名該旗標:
2393
2394```text theme={null}
2395Error: `--settings` before `remote-control` is not carried over to the sessions Remote Control starts, so Remote Control refuses to start rather than drop it — remove it, and give Remote Control's own options after the verb (see `claude remote-control --help`).
2396```
2397
2398Claude Code 不拒絕無害的全域旗標,例如 `--verbose`、`--model` 或包裝器注入的 `--session-id` 或 `--plugin-dir`:它會忽略它們,遠端控制會啟動。
2399
2400Claude Code 也拒絕為它尚未識別為無害的全域旗標啟動,所以在較新版本中新增的旗標可能會在此訊息中出現,直到稍後的版本將其標記為無害。
2401
2402**該怎麼做:**
2403
2404* 從動詞之前移除旗標,並在其後傳遞[遠端控制自己的選項](/docs/zh-TW/remote-control#start-a-remote-control-session);`claude remote-control --help` 列出它們
2405* 當被拒絕的旗標是 `--permission-mode` 時,執行 `claude remote-control --permission-mode <mode>` 來設定遠端控制啟動的工作階段的權限模式
2406
2407在 v2.1.248 之前,當全域旗標首先出現時,`claude remote-control` 不接受自己的旗標,命令失敗並出現 `unknown option` 錯誤。
2408
2409<h3 id="claude-import-is-not-yet-available-in-this-build">
2410 claude import 在此組建中尚不可用
2411</h3>
2412
2413您執行了 [`claude import`](/docs/zh-TW/cli-reference#cli-commands),Claude Code 發現匯入流程已關閉,所以命令以代碼 1 結束而不是啟動匯入。在 v2.1.222 之前,關閉匯入流程的組建會將 `import` 視為提示並啟動互動工作階段,而不是列印此訊息。
2414
2415```text theme={null}
2416`claude import` is not yet available in this build. Run `claude` and use /mcp or edit ~/.claude/settings.json directly.
2417```
2418
2419Claude Code 透過從 Anthropic 取得並在磁碟上快取的功能旗標開啟 `claude import`。此訊息意味著快取的值已關閉。原因通常是以下之一:
2420
2421* 您在安裝後尚未啟動工作階段,所以 Claude Code 尚未取得旗標。第一個 `claude import` 即使功能對您可用,也可能列印此訊息。
2422* 您透過 Amazon Bedrock、Google Cloud 的 Agent Platform、Microsoft Foundry 或 AWS 上的 Claude Platform,或透過 [Claude 應用程式閘道](/docs/zh-TW/claude-apps-gateway#availability-and-limitations)使用 Claude Code。Claude Code 在這些工作階段中不取得功能旗標,所以 `claude import` 保持不可用。
2423* 您設定了 `DISABLE_TELEMETRY`、`DO_NOT_TRACK`、`DISABLE_GROWTHBOOK` 或 [`CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC`](/docs/zh-TW/env-vars),這會關閉功能旗標取得,所以 `claude import` 保持不可用。
2424
2425**該怎麼做:**
2426
2427* 在全新安裝上,啟動 `claude`,等待工作階段載入,結束,然後再次執行 `claude import`
2428* 功能旗標取得保持關閉的地方,自己設定設定:使用 [`claude mcp add`](/docs/zh-TW/mcp#installing-mcp-servers) 新增 MCP 伺服器,並建立您想要帶過來的 [`CLAUDE.md` 檔案](/docs/zh-TW/memory#how-claude-md-files-load)、[技能和命令](/docs/zh-TW/skills#where-skills-live)和[子代理](/docs/zh-TW/sub-agents#choose-the-subagent-scope)。訊息也命名 `~/.claude/settings.json`。在 `claude import` 帶來的設定中,該檔案只保存[權限模式](/docs/zh-TW/settings-reference#permission-settings);Claude Code 不從中讀取 MCP 伺服器。
2429
2430<h3 id="could-not-read-claude-code-config">
2431 無法讀取 Claude Code 設定
2432</h3>
2433
2434您在 Claude Code 無法解析 `~/.claude.json` 時執行了 [`claude import`](/docs/zh-TW/cli-reference#cli-commands),該檔案是它儲存您的登入和每個專案狀態的地方。子命令讀取該檔案以檢查可用性,但不會顯示互動工作階段顯示的恢復對話框,所以它以代碼 1 結束。在 v2.1.222 之前,具有無法讀取的設定檔的 `claude import` 啟動了互動工作階段,其恢復對話框處理了該檔案。
2435
2436```text theme={null}
2437Could not read Claude Code config — run `claude` with no arguments to recover it.
2438```
2439
2440**該怎麼做:**
2441
2442* 執行 `claude` 而不帶引數。Claude Code 偵測無效檔案並提供重設它。然後再次執行 `claude import`。
2443* 若要保留您所做的手動編輯,請在編輯器中修復 `~/.claude.json` 中的 JSON 語法,然後重新執行 `claude import`
2444
2445<h3 id="could-not-import-a-server-from-claude-desktop">
2446 無法從 Claude Desktop 匯入伺服器
2447</h3>
2448
2449Claude Code 無法新增您在 `claude mcp add-from-claude-desktop` 中選擇的其中一個伺服器。該命令仍會匯入其他選定的伺服器,並為每個無法新增的伺服器列印一行。在 v2.1.205 之前,第一個失敗的伺服器停止了匯入,所有選定的伺服器都未被新增。
2450
2451```text theme={null}
2452Could not import my server: Invalid name my server. Names can only contain letters, numbers, hyphens, and underscores.
2453```
2454
2455伺服器名稱之後的文字是原因。最常見的是名稱檢查:Claude Desktop 允許伺服器名稱中的字元,例如空格和句號,而 `claude mcp` 限制為字母、數字、連字號和底線。其他原因包括無法通過驗證的伺服器設定和被您組織的 [MCP 原則](/docs/zh-TW/managed-mcp)阻止的伺服器。
2456
2457**該怎麼做:**
2458
2459* 在 `claude_desktop_config.json` 中重新命名伺服器以僅使用字母、數字、連字號和底線,然後再次執行 `claude mcp add-from-claude-desktop`
2460* 使用有效名稱直接使用 `claude mcp add` 或 `claude mcp add-json` 新增該伺服器。請參閱[從 Claude Desktop 匯入 MCP 伺服器](/docs/zh-TW/mcp#import-mcp-servers-from-claude-desktop)。
2461
2462<h3 id="cannot-add-mcp-server-to-the-managed-scope">
2463 無法將 MCP 伺服器新增到受管範圍
2464</h3>
2465
2466您使用 `--scope managed` 執行了 `claude mcp add` 或 `claude mcp add-json`。該範圍保存您的組織透過 [`managedMcpServers`](/docs/zh-TW/settings-reference#managedmcpservers) 受管設定提供的伺服器。Claude Code 只從受管設定讀取它們,所以命令無法將伺服器寫入該範圍。
2467
2468```text theme={null}
2469Cannot add MCP server to scope: managed
2470```
2471
2472**該怎麼做:**
2473
2474* 將伺服器新增到您可以寫入的範圍:`local`、`user` 或 `project`。不使用 `--scope` 時,命令使用 `local`。請參閱 [MCP 安裝範圍](/docs/zh-TW/mcp#mcp-installation-scopes)
2475* 若要為組織中的每個使用者提供伺服器,請將其新增到您部署的受管設定中的 [`managedMcpServers`](/docs/zh-TW/settings-reference#managedmcpservers)
2476
2477<h3 id="cant-read-mcp-json">
2478 無法讀取 .mcp.json
2479</h3>
2480
2481讀取專案 [`.mcp.json`](/docs/zh-TW/mcp#project-scope) 的命令,例如 `claude mcp add` 或 `claude mcp add-json` 搭配 `--scope project`,或 `claude mcp remove`,發現您目前目錄中的檔案不是常規檔案或大於 2 MiB,所以它以此錯誤結束而不是讀取檔案。
2482
2483```text theme={null}
2484Can't read .mcp.json: it isn't a regular file or is larger than 2097152 bytes. Fix or remove it, then run the command again.
2485```
2486
2487在 v2.1.257 之前,`.mcp.json` 處的 FIFO 會讓命令無限期等待而沒有輸出,到裝置檔案(例如 `/dev/zero`)的符號連結會增加記憶體直到程序被殺死。
2488
2489**該怎麼做:**
2490
2491* 檢查您目前目錄中 `.mcp.json` 處的內容。將其替換為[專案範圍格式](/docs/zh-TW/mcp#project-scope)中的普通 JSON 檔案,或刪除它,然後再次執行命令。
2492
2493<h3 id="anthropic-hosted-and-doesnt-support-local-oauth">
2494 伺服器是 Anthropic 託管的,不支援本地 OAuth
2495</h3>
2496
2497您為 URL 指向透過第三方身份提供者進行驗證的 Anthropic 託管連接器主機的 MCP 伺服器啟動了登入。這些主機包括 `microsoft365.mcp.claude.com`、`gmail.mcp.claude.com` 和 `gcal.mcp.claude.com`。Claude Code 拒絕為這些主機從 `/mcp` 面板和 `claude mcp login` 啟動其本地 OAuth 流程,因為[它們的登入僅透過 claude.ai 工作](/docs/zh-TW/mcp#use-mcp-servers-from-claude-ai)。
2498
2499```text theme={null}
2500"gmail" is Anthropic-hosted and doesn't support local OAuth. Connect it via Settings → Connectors on claude.ai (requires `claude login`), then it'll be available here automatically.
2501```
2502
2503Claude Code 按 URL 匹配這些主機,所以當您使用 `claude mcp add` 或在 `.mcp.json` 中新增的伺服器指向其中之一時,訊息會出現。
2504
2505**該怎麼做:**
2506
2507* 使用 `claude mcp remove <name>` 移除您的項目,以便它無法隱藏相同 URL 處的 claude.ai 連接器
2508* 移除後,在[claude.ai/customize/connectors](https://claude.ai/customize/connectors)連接服務,同時登入您在 Claude Code 中使用的帳戶。連接後,如果您的活躍驗證方法是 claude.ai 訂閱登入,[連接器會自動出現在 Claude Code 中](/docs/zh-TW/mcp#use-mcp-servers-from-claude-ai)
2509
2510<h3 id="server-rejected-the-authorization-header-minted-by-the-configured-headershelper">
2511 伺服器拒絕了由設定的 headersHelper 鑄造的授權標頭
2512</h3>
2513
2514其 [`headersHelper`](/docs/zh-TW/mcp#use-dynamic-headers-for-custom-authentication) 提供 `Authorization` 標頭的 MCP 伺服器以 HTTP 401 或 403 回答連接,所以 Claude Code 將連接報告為失敗。因為幫助程式提供 `Authorization` 標頭,Claude Code [不會回退到 OAuth](/docs/zh-TW/mcp#authenticate-with-remote-mcp-servers) 用於伺服器:
2515
2516```text theme={null}
2517Server rejected the Authorization header minted by the configured headersHelper (HTTP 401). Check that the helper command returns a valid credential for this MCP endpoint — OAuth fallback is disabled when the helper supplies Authorization.
2518```
2519
2520Claude Code 在每次連接嘗試時重新執行幫助程式,所以在暫時拒絕後重試(例如權杖輪換競爭)可以使用新認證成功。
2521
2522**該怎麼做:**
2523
2524* 按照 Claude Code 執行它的方式執行 `headersHelper` 命令:從 [Claude Code 執行它的目錄](/docs/zh-TW/mcp#where-the-helper-runs),使用 [Claude Code 為其設定的環境變數](/docs/zh-TW/mcp#use-dynamic-headers-for-custom-authentication),以及不使用 [Claude Code 為來自專案 `.mcp.json`、外掛程式或專案代理檔案的伺服器移除的認證變數](/docs/zh-TW/mcp#which-variables-a-helper-can-read)。檢查它列印的 `Authorization` 值伺服器的端點接受
2525* 修復幫助程式或其認證來源後,在 `/mcp` 中選擇伺服器並選擇**重新連接**
2526
2527在 v2.1.248 之前,Claude Code 為其幫助程式提供 `Authorization` 標頭的伺服器執行了 OAuth 發現。該發現可能失敗並出現 `Incompatible auth server: does not support dynamic client registration` 而不是報告被拒絕的認證。
2528
2529<h3 id="mcp-permission-prompt-tool-not-found">
2530 找不到 MCP 權限提示工具
2531</h3>
2532
2533您傳遞給 [`--permission-prompt-tool`](/docs/zh-TW/cli-reference#cli-flags) 的工具在執行首次需要權限決定時不在連接的 MCP 工具中,可能是因為其伺服器從未連接,或因為沒有連接的伺服器公開該名稱的工具。Claude Code 仍會傳送您的提示:[非互動](/docs/zh-TW/headless)執行在第一個需要批准的工具呼叫時以此錯誤和結束代碼 1 結束,所以即使提出了請求,它也不會產生答案。在第一個提示之前,Claude Code 等待最多由 [`MCP_TIMEOUT`](/docs/zh-TW/env-vars) 設定的每個伺服器連接逾時 30 秒,以便該伺服器連接。在 v2.1.206 之前,啟動不會等待伺服器完成連接,所以啟動緩慢但健康的伺服器也會產生此錯誤。
2534
2535```text theme={null}
2536Error: MCP tool mcp__permissions__approve (passed via --permission-prompt-tool) not found. Available MCP tools: none
2537```
2538
2539`Available MCP tools:` 之後的清單命名等待結束時連接的 MCP 工具。
2540
2541**該怎麼做:**
2542
2543* 檢查伺服器啟動並保持連接:在同一目錄中執行 `claude mcp list` 並確認伺服器列為已連接
2544* 確認工具名稱與伺服器公開的 `mcp__<server>__<tool>` 名稱相符
2545* 如果伺服器需要超過 30 秒才能啟動,請提高 [`MCP_TIMEOUT`](/docs/zh-TW/env-vars)
2546
2547<h3 id="oauth-callback-port-is-already-in-use">
2548 OAuth 回呼連接埠已在使用中
2549</h3>
2550
2551當您使用 OAuth 登入遠端 MCP 伺服器時,Claude Code 啟動本地接聽程式以接收登入回呼。如果該接聽程式需要的連接埠被另一個程序持有,登入會失敗並出現此訊息。這主要發生在透過 [`MCP_OAUTH_CALLBACK_PORT`](/docs/zh-TW/env-vars) 變數或 `--callback-port` 設定的[固定回呼連接埠](/docs/zh-TW/mcp#use-a-fixed-oauth-callback-port)上,因為沒有一個 Claude Code 會選擇可用的連接埠。
2552
2553```text theme={null}
2554OAuth callback port <port> is already in use — another process may be holding it. Run `lsof -ti:<port> -sTCP:LISTEN` to find it.
2555```
2556
2557在 Windows 上,建議的命令是 `netstat -ano | findstr :<port>`。
2558
2559**該怎麼做:**
2560
2561* 執行訊息中的命令以找到持有連接埠的程序,並停止它或等待它完成
2562* 如果另一個程式永久需要該連接埠,請向伺服器註冊不同的重定向 URI,並使用 `MCP_OAUTH_CALLBACK_PORT` 或 `--callback-port` 設定其連接埠,以及您使用的任何一個
2563* 然後再次啟動登入,例如在 `/mcp` 中選擇伺服器
2564
2565<h3 id="security-review-fails-without-origin-head">
2566 /security-review 在沒有 origin/HEAD 的情況下失敗
2567</h3>
2568
2569[`/security-review`](/docs/zh-TW/commands#all-commands) 透過針對 `origin/HEAD` 進行差異來建立其審查上下文,該本地參考記錄您的 `origin` 遠端上的預設分支。當該參考不存在時,收集差異的 git 命令失敗,審查在啟動前停止。
2570
2571```text theme={null}
2572Error: Shell command failed for pattern "!`git diff --name-only origin/HEAD...`": [stderr]
2573fatal: ambiguous argument 'origin/HEAD...': unknown revision or path not in the working tree.
2574Use '--' to separate paths from revisions, like this:
2575'git <command> [<revision>...] -- [<file>...]'
2576```
2577
2578引用的命令在執行之間變化:審查同時針對 `origin/HEAD` 啟動多個 `git` 命令,並報告首先失敗的命令,所以您可能會在其位置看到 `git log` 或不同的 `git diff`。Git 只在遠端的預設分支被遠端公告且被您的取得 refspec 涵蓋時建立參考。遠端的完整 `git clone` 滿足兩個條件。單分支和 CI 檢查取得太窄的 refspec,伺服器端 HEAD 指向沒有人推送的分支不公告預設值,沒有 `origin` 遠端的儲存庫或您從未取得的儲存庫提供兩者都不提供。
2579
2580Claude Code 為任何[注入動態上下文](/docs/zh-TW/skills#when-an-injected-command-fails)的技能顯示相同的錯誤。失敗的注入命令會中止該技能的呼叫。兩個同級字串在命令執行之前就會觸發:
2581
2582* `Shell command permission check failed for pattern "..."`:命令的權限檢查返回了允許以外的內容。注入的命令永遠不會提示,所以呼叫會中止而不詢問您。使用 [`allowed-tools`](/docs/zh-TW/skills#pre-approve-tools-for-a-skill) 預先批准沒有規則符合的命令。符合的詢問或拒絕規則仍會中止呼叫,無論 `allowed-tools` 如何
2583* ``Skill <name> requires bash (`shell: bash` in frontmatter) but Git Bash was not found``:技能的 frontmatter 在沒有它的機器上要求 bash。安裝 Git for Windows 或將 frontmatter 變更為 `shell: powershell`。請參閱[注入命令如何執行](/docs/zh-TW/skills#how-injected-commands-run)
2584
2585**該怎麼做:**
2586
2587* 透過命名您的遠端預設分支建立參考:`git remote set-head origin <default-branch>`。只要本地追蹤參考 `origin/<default-branch>` 存在,這就有效。如果它不存在,如在單分支複製中,首先取得分支:執行 `git remote set-branches --add origin <branch>`,然後 `git fetch origin`,然後重新執行 set-head 命令。重新執行 `/security-review`。
2588* 如果您寧願不命名分支,執行 `git fetch origin` 然後 `git remote set-head origin --auto`,它詢問遠端其預設分支是什麼。當遠端不公告預設分支時它失敗並出現 `error: Cannot determine remote HEAD`,因為它是空的或其 HEAD 指向沒有人推送的分支;改為明確命名分支。當您的複製不取得該分支時它失敗並出現 `error: Not a valid ref`;首先如上所述擴大 refspec。
2589* 如果儲存庫沒有遠端,使用 `git remote add origin <url>` 新增一個並在建立參考之前取得。如果遠端是空的,首先使用 `git push -u origin HEAD` 推送您的分支,並在 set-head 命令中命名該分支;`origin/HEAD` 然後指向您剛推送的分支,所以 `/security-review` 看到空差異直到分支與它分歧。
2590
2591<h3 id="input-must-be-provided-when-using-print">
2592 使用 --print 時必須提供輸入
2593</h3>
2594
2595裸 `claude` 需要 stdout 是終端才能啟動互動 UI。當 stdout 被重定向或控制台不是真實終端時,例如 PowerShell ISE 和某些 IDE 輸出窗格,`claude` 改為以[非互動](/docs/zh-TW/headless)模式執行。這與 `claude -p` 相同,它需要提示,所以訊息命名 `--print` 即使您沒有傳遞旗標。在任何地方傳遞 `-p`/`--print` 而沒有提示且 stdin 上沒有任何內容會產生相同的錯誤。
2596
2597```text theme={null}
2598Error: Input must be provided either through stdin or as a prompt argument when using --print
2599```
2600
2601**該怎麼做:**
2602
2603* 為了互動使用,在真實終端中執行 `claude`:Windows Terminal 或 PowerShell 控制台而不是 ISE,以及您的 IDE 整合終端而不是輸出窗格
2604* 為了一次性使用,傳遞提示:`claude -p "your question"`,或使用 `echo "your question" | claude -p` 管道它
2605
2606<h3 id="input-contained-only-whitespace">
2607 輸入僅包含空白
2608</h3>
2609
2610在[非互動模式](/docs/zh-TW/headless)中,Claude Code 拒絕完全由空格、製表符或換行符組成的提示,而不是傳送它,因為 API 拒絕沒有可見文字的訊息。您看到的訊息取決於空白提示來自何處:
2611
2612* **`claude -p` 的提示引數或管道 stdin**:`claude` 以 `Error: Input contained only whitespace. Provide a prompt with text through stdin or as a prompt argument when using --print` 結束
2613* **提交到執行中的 `--input-format stream-json` 或 [Agent SDK](/docs/zh-TW/agent-sdk/overview) 工作階段的訊息**:Claude Code 在沒有呼叫模型的情況下結束轉身,工作階段保持可用。拒絕作為資訊訊息和轉身的結果文字到達:`Blank prompt — the message was only whitespace, so nothing was sent to the model.`
2614
2615在 v2.1.229 之前,Claude Code 將僅空白訊息傳送到 API,API 以 400 錯誤拒絕了請求。
2616
2617**該怎麼做:**
2618
2619* 在提示中包含可見文字。如果指令碼從變數或檔案建立提示,請在呼叫 Claude Code 之前檢查來源是否不為空。
2620
2621<h3 id="stream-json-input-carried-over-256m-characters-with-no-newline">
2622 stream-json 輸入在沒有換行符的情況下超過 256M 個字元
2623</h3>
2624
2625您的程式在沒有換行符的情況下在 stdin 上傳送了超過 268,435,456 個字元到 `claude -p --input-format stream-json` 執行,所以 Claude Code 將此錯誤列印到 stderr 並以代碼 1 結束,而不是緩衝更多輸入。訊息將該預算陳述為 `256M`。在 v2.1.257 之前,Claude Code 無限制地緩衝此類輸入,增加記憶體直到程序崩潰或被殺死。
2626
2627```text theme={null}
2628Error: stream-json input carried over 256M characters with no newline. Each stream-json message must be a single newline-terminated JSON line: either the producer is not newline-terminating its messages, or one message exceeded this budget.
2629```
2630
2631沒有換行符的這麼長的輸入通常意味著生產者根本不是 stream-json 生產者,例如二進位檔案或意外管道的純日誌輸出。超過預算的單個訊息失敗相同的檢查。
2632
2633**該怎麼做:**
2634
2635* 檢查什麼被管道到 stdin。使用 [`--input-format stream-json`](/docs/zh-TW/cli-reference#cli-flags),每個訊息必須是一個換行符終止的 JSON 行
2636* 若要改為傳送純文字,請放棄 `--input-format stream-json`;`claude -p` 預設從 stdin 讀取純文字提示
2637
2638<h3 id="unknown-command">
2639 未知命令
2640</h3>
2641
2642您提交了一個 `/` 名稱,它與此工作階段中的任何命令都不符,所以 Claude Code 報告該名稱而不是執行任何操作:
2643
2644```text theme={null}
2645Unknown command: /hepl. Did you mean /help?
2646```
2647
2648Claude Code 建議此工作階段中功能表列出的最接近的命令名稱或別名。當沒有接近的時,訊息在名稱後結束。原因通常是以下之一:
2649
2650* 打字錯誤,例如 `/hepl` 代替 `/help`。[命令功能表如何符合您輸入的內容](/docs/zh-TW/commands#how-the-command-menu-matches-what-you-type)涵蓋在您提交之前選擇接近的符合。
2651* 存在但在此工作階段中不可用的命令,因為不符合要求,例如您的平台、計畫或驗證方法。[`/web-setup`](/docs/zh-TW/web-quickstart#web-setup-shows-no-commands-match-or-unknown-command) 和 [`/schedule`](/docs/zh-TW/routines#schedule-returns-unknown-command) 的疑難排解項目演練兩個常見情況。某些命令在您的組織原則禁用它們時以自己的訊息回答
2652* 來自此工作階段中未安裝或連接的[外掛程式](/docs/zh-TW/plugins)或 [MCP 伺服器](/docs/zh-TW/mcp#use-mcp-prompts-as-commands)的命令
2653
2654Claude Code 不會將每個以 `/` 開頭的提示視為命令。當 `/` 之後的第一個單詞以標點符號開頭時,它會將提示傳送給 Claude 作為普通訊息,例如開啟 Lean 文件註釋的 `/--`,或是路徑,例如 `/var/log/syslog`。
2655
2656在 v2.1.236 之前,如果您在命令功能表列出您輸入的名稱的接近符合時按下 `Enter`,Claude Code 會執行該符合,所以 `/hepl` 之類的打字錯誤會執行 `/help` 而不是產生此訊息。
2657
2658**該怎麼做:**
2659
2660* 執行建議的名稱,或輸入 `/` 後跟名稱的一部分以查看此工作階段中可用的內容
2661* 如果 Claude Code 將記錄的命令報告為未知,請檢查[命令參考](/docs/zh-TW/commands)中的其行以了解它命名的要求
2662
2663<h3 id="diff-is-too-large-for-ultrareview">
2664 差異對於 ultrareview 來說太大
2665</h3>
2666
2667您的分支與基礎分支之間的差異,包括未提交和暫存的變更,超過了 [ultrareview](/docs/zh-TW/ultrareview) 的大小限制,所以 `/code-review ultra` 和 `claude ultrareview` 子命令在雲端工作階段啟動之前拒絕審查。被拒絕的審查不使用免費執行,也不計費使用額度。訊息命名有效的限制、您的差異大小以及貢獻最多變更行的檔案。在 v2.1.216 之前,訊息只顯示原始差異統計。
2668
2669```text theme={null}
2670Diff is too large for ultrareview: 812 files, 96,410 lines changed (limits: 500 files, 8,000 lines). Largest files: package-lock.json (41,904 lines), dist/bundle.js (18,210 lines), src/generated/api.ts (9,876 lines). Pass a closer base branch (`/code-review ultra <branch>`) to narrow the scope, or split the change.
2671```
2672
2673審查拉取請求應用相同的限制;該形式的訊息以 `PR #<N> is too large for ultrareview` 開頭,並命名 PR 的檔案和行計數。
2674
2675**該怎麼做:**
2676
2677* 傳遞更接近您工作的基礎分支,例如 `/code-review ultra develop`,以便審查僅涵蓋針對該分支的差異
2678* 將變更分成較小的分支並審查每一個。訊息命名的檔案貢獻最多變更行,所以首先開始將這些移到自己的分支。
2679
2680<h3 id="could-not-find-merge-base-with-the-base-branch">
2681 找不到與基礎分支的合併基礎
2682</h3>
2683
2684`/code-review ultra` 和 `claude ultrareview` 子命令審查您的分支與基礎分支之間的差異,這需要兩者共享的提交。當 `git merge-base` 找不到時,Claude Code 在雲端工作階段啟動之前拒絕審查。在 Claude Code 可以驗證完整的複製上,至少有一個分支,它改為[審查每個追蹤的檔案](/docs/zh-TW/ultrareview#diff-limits-and-fallbacks)而不是拒絕。當基礎分支根本找不到時,當 Claude Code 無法驗證您的複製完整時,或在罕見的儲存庫中(例如 SHA-256 物件格式),您會看到此拒絕。
2685
2686```text theme={null}
2687Could not find merge-base with main. Pass the base branch explicitly (e.g. `/code-review ultra develop`) or make sure you're in a git repo with a main branch.
2688```
2689
2690第一句之後的提示取決於 Claude Code 觀察到的內容:
2691
2692* **您沒有傳遞基礎分支**:Claude Code 與儲存庫的預設分支進行了比較,並建議明確傳遞您的基礎,如上例所示
2693* **您傳遞的基礎分支已在您的複製中**:提示讀取 ``Make sure <branch> exists locally or on origin (try `git fetch origin <branch>`)``
2694* **您傳遞的基礎分支不在您的複製中**:Claude Code 在比較之前從 origin 取得了它。提示讀取 ``<branch> was fetched from origin but shares no history with HEAD. If another branch is your real base, pass it explicitly (`/code-review ultra <branch>`)``;當 Claude Code 無法判斷您的複製是否淺時,它改為建議 `git fetch --unshallow origin`。在 v2.1.221 之前,提示為每個取得的基礎分支建議 `git fetch --unshallow origin`,在完整複製上該命令失敗並出現 `fatal: --unshallow on a complete repository does not make sense`。
2695
2696**該怎麼做:**
2697
2698* 如果另一個分支是您的真實基礎,明確傳遞它:`/code-review ultra <branch>`
2699* 如果您的複製可能沒有完整歷史,執行 `git fetch --unshallow origin` 並重新執行審查
2700
2701<h3 id="your-checkout-has-no-branches">
2702 您的檢查沒有分支
2703</h3>
2704
2705檢查可以有提交但沒有分支:如果您執行 `git init` 後跟 `git fetch <url>` 和 `git checkout FETCH_HEAD`,您會得到一個分離的 HEAD 而沒有參考。Claude Code 將您的儲存庫打包為 git 套件以上傳以進行 [ultrareview](/docs/zh-TW/ultrareview),它無法捆綁沒有分支或其他參考的儲存庫,所以 `/code-review ultra` 和 `claude ultrareview` 子命令在雲端工作階段啟動之前拒絕審查。
2706
2707```text theme={null}
2708Your checkout has no branches (detached HEAD only), which cloud review can't bundle. Create one first — `git checkout -b <name>` — then rerun /code-review ultra.
2709```
2710
2711在 v2.1.221 之前,Claude Code 嘗試審查此檢查中的每個追蹤檔案,上傳失敗。
2712
2713**該怎麼做:**
2714
2715* 使用 `git checkout -b <name>` 在您目前的提交處建立分支,然後重新執行審查
2716
2717<h3 id="no-github-account-is-connected-to-your-claude-account">
2718 沒有 GitHub 帳戶連接到您的 Claude 帳戶
2719</h3>
2720
2721您執行了 `/code-review ultra <PR#>` 或 `claude ultrareview <PR#>`,在建立雲端工作階段之前,Claude Code 詢問伺服器[連接到您的 Claude 帳戶的 GitHub 帳戶](/docs/zh-TW/ultrareview#review-a-pull-request)是否可以到達 PR 的儲存庫。沒有帳戶連接,或連接已過期,所以雲端複製會失敗,Claude Code 拒絕啟動。Claude Code 不會為被拒絕的啟動花費免費執行或計費使用額度。
2722
2723```text theme={null}
2724Ultrareview clones <owner>/<repo> in the cloud with the GitHub account connected to your Claude account, and none is connected (or the connection expired). To fix: run /web-setup to reuse your GitHub CLI login, or connect an account at https://claude.ai/connect-github — then re-run /code-review ultra 1234 (allow a minute after connecting).
2725```
2726
2727當 [`/web-setup`](/docs/zh-TW/web-quickstart#connect-from-your-terminal) 在您的工作階段中不可用時,訊息只命名 claude.ai 連結。
2728
2729**該怎麼做:**
2730
2731* 執行 `/web-setup` 以將您的 GitHub CLI 登入連接到您的 Claude 帳戶,或在 [claude.ai/connect-github](https://claude.ai/connect-github) 連接帳戶
2732* 連接後一分鐘重新執行審查
2733
2734在 v2.1.248 之前,Claude Code 在啟動前不檢查此項。
2735
2736<h3 id="your-connected-github-account-cant-see-the-repository">
2737 您連接的 GitHub 帳戶看不到儲存庫
2738</h3>
2739
2740您執行了 `/code-review ultra <PR#>` 或 `claude ultrareview <PR#>`,[連接到您的 Claude 帳戶的 GitHub 帳戶](/docs/zh-TW/ultrareview#review-a-pull-request)無法讀取 PR 的儲存庫,所以雲端複製會失敗,Claude Code 拒絕啟動。Claude Code 不會為被拒絕的啟動花費免費執行或計費使用額度。
2741
2742```text theme={null}
2743Your connected GitHub account can't see <owner>/<repo> — usually the Claude GitHub app isn't installed on <owner> or wasn't granted this repo (web-connected accounts need it for private repos), or a different GitHub account is connected. To fix: run /web-setup to reuse your GitHub CLI login, or install the app at https://github.com/apps/claude/installations/new — then re-run /code-review ultra 1234.
2744```
2745
2746當 [`/web-setup`](/docs/zh-TW/web-quickstart#connect-from-your-terminal) 在您的工作階段中不可用時,訊息只命名應用程式安裝。
2747
2748**該怎麼做:**
2749
2750* 如果您的本地 `gh` CLI 可以讀取儲存庫,執行 `/web-setup` 以將該登入連接到您的 Claude 帳戶
2751* 變更後重新執行審查
2752
2753在 v2.1.248 之前,Claude Code 在啟動前不檢查此項。
2754
2755<h3 id="the-github-app-preflight-failed-transiently">
2756 GitHub App 預檢暫時失敗
2757</h3>
2758
2759您從本地儲存庫啟動了[雲端工作階段](/docs/zh-TW/claude-code-on-the-web),兩個步驟一起失敗。Claude Code 無法建立或上傳您的儲存庫套件。在上傳之前,它檢查了雲端服務是否可以從 GitHub 複製儲存庫,而不是明確的答案,該檢查以重試可以清除的錯誤結束,例如網路錯誤、逾時或暫時伺服器錯誤。完整訊息以停止套件的內容開頭,例如 `Could not upload repo bundle (<error>)`,並以預檢句子結尾:
2760
2761```text theme={null}
2762Could not upload repo bundle (<error>). The GitHub App preflight failed transiently (network or service hiccup) — retry in a moment to start from GitHub instead
2763```
2764
2765**該怎麼做:**
2766
2767* 片刻後重新執行命令。當 GitHub 檢查通過時,Claude Code 可以從 GitHub 複製啟動工作階段,所以失敗的上傳不再阻止啟動
2768* 如果重試持續失敗,訊息的開頭命名停止上傳的內容。當該原因是您可以修復的內容時,修復它以便工作階段可以改為從您的本地儲存庫啟動
2769
2770在 v2.1.251 之前,Claude Code 以 `Please set up GitHub on https://claude.ai/code` 結束訊息,即使 GitHub 檢查只是暫時失敗,設定建議無法清除暫時失敗。
2771
2772<h3 id="failed-to-resume-the-conversation">
2773 無法恢復對話
2774</h3>
2775
2776Claude Code 無法讀取或處理您從 [`claude --resume` 選擇器](/docs/zh-TW/sessions#use-the-session-picker)選擇的工作階段的已儲存文字記錄,所以它結束程序而不是在部分載入狀態下繼續。訊息包括重試的命令:
2777
2778```text theme={null}
2779Failed to resume the conversation.
2780Run claude --resume <session-id> to retry, or claude to start a new session.
2781```
2782
2783Claude Code 在顯示訊息後以代碼 1 結束。執行中工作階段內的 `/resume` 選擇器報告對話中的 `Failed to resume conversation`,您目前的工作階段保持執行。在 v2.1.216 之前,來自 `claude --resume` 選擇器的失敗恢復在 `Resuming conversation…` 微調器上無限期停留,而不是顯示此訊息。
2784
2785**該怎麼做:**
2786
2787* 執行 `claude --resume <session-id>` 搭配訊息中的工作階段 ID 以重試
2788* 如果重試再次失敗,執行 `claude` 以啟動新工作階段
2789
2790<h3 id="no-conversation-found-with-the-session-id">
2791 找不到具有工作階段 ID 的對話
2792</h3>
2793
2794您傳遞了工作階段 ID 給 `claude --resume <session-id>`,沒有儲存的文字記錄符合它:
2795
2796```text theme={null}
2797No conversation found with session ID: <session-id>
2798```
2799
2800Claude Code 在顯示訊息後以代碼 1 結束。Claude Code [首先搜尋目前專案,然後搜尋此機器上的每個其他專案](/docs/zh-TW/sessions#resume-a-session)以尋找 ID。在 v2.1.223 之前,查詢在目前專案目錄及其 git worktrees 處停止,所以從工作階段最後工作的目錄恢復。
2801
2802常見原因:
2803
2804* **打字錯誤的 ID**:對於非互動執行,ID 是 [`--output-format json` 輸出](/docs/zh-TW/headless#get-structured-output)的 `session_id` 欄位
2805* **已刪除的文字記錄**:Claude Code 在[保留期](/docs/zh-TW/sessions#where-transcripts-are-stored)後移除文字記錄,預設為 30 天,遵循[保留掃描規則](/docs/zh-TW/claude-directory#cleaned-up-automatically)
2806* **不同的機器**:Claude Code 在本地儲存文字記錄,所以在執行工作階段的機器上恢復工作階段
2807* **重複副本**:如果您在 `~/.claude/projects` 下複製了專案目錄,所以兩個文字記錄帶有相同的 ID,Claude Code 報告此訊息而不是任意恢復一個副本
2808
2809**該怎麼做:**
2810
2811* 對於互動工作階段,使用 `claude --resume` 開啟[工作階段選擇器](/docs/zh-TW/sessions#use-the-session-picker),按 `Ctrl+A` 將其擴大到此機器上的每個專案,然後選擇工作階段
2812* 使用 `claude -p` 或 [Agent SDK](/docs/zh-TW/agent-sdk/overview) 建立的工作階段不會出現在選擇器中,所以重新檢查 ID 與您的原始執行列印的 `session_id`
2813
2814<h3 id="cannot-switch-renderers-in-this-session">
2815 無法在此工作階段中切換轉譯器
2816</h3>
2817
2818當您切換轉譯器時,Claude Code 重新啟動其程序。您在 Claude Code 拒絕重新啟動的工作階段中執行了 [`/tui`](/docs/zh-TW/fullscreen#enable-fullscreen-rendering),所以它不會切換並保存任何內容。您看到的訊息告訴您原因:
2819
2820* `Cannot switch renderers while work is running in the background`:您有在背景執行的工作,重新啟動會放棄,例如背景 shell 或子代理。等待工作完成或使用 [`/tasks`](/docs/zh-TW/commands) 停止它,然後再次執行 `/tui fullscreen` 或 `/tui default`
2821* `Cannot switch renderers in this session`:工作階段有 Claude Code 無法傳遞給重新啟動程序的限制。在 v2.1.234 之前,Claude Code 無論如何都會重新啟動,重新啟動的工作階段執行時沒有它們
2822
2823在限制訊息中,括號中的部分命名 Claude Code 發現的限制:
2824
2825```text theme={null}
2826Cannot switch renderers in this session — it has restrictions a restart can't carry over (permission rules set for this session only). Nothing was changed. Running /tui fullscreen in a session started without them switches every later session too.
2827```
2828
2829訊息可以在括號中顯示的每個原因:
2830
2831* `launch flags: a custom system prompt, a tool allowlist, or restricted settings`:您使用 Claude Code 不傳遞回重新啟動程序的旗標啟動了工作階段。這些旗標包括 [`--system-prompt`](/docs/zh-TW/cli-reference#cli-flags)、`--system-prompt-file`、`--append-system-prompt-file`、[`--tools`](/docs/zh-TW/cli-reference#cli-flags) 允許清單、[`--setting-sources`](/docs/zh-TW/cli-reference#cli-flags) 和 [`--permission-prompt-tool`](/docs/zh-TW/cli-reference#cli-flags)
2832* `permission rules set for this session only`:來自鉤子或 SDK 呼叫者的[權限更新](/docs/zh-TW/hooks#permission-update-entries)新增了具有 `session` 目的地的拒絕或詢問規則。工作階段範圍的允許規則不會觸發拒絕。重新啟動會放棄它們,Claude Code 改為再次提示
2833* `ask-before-running rules with no command-line form`:來自鉤子或 SDK 呼叫者的權限更新新增了詢問規則以及 Claude Code 作為 `--allowed-tools` 和 `--disallowed-tools` 傳遞回的規則。沒有旗標存在用於詢問規則
2834* `permission rules a command line cannot carry intact` 和 `added directories a command line cannot carry intact`:權限更新在工作階段中期新增了規則或目錄路徑。重新啟動程序的命令列無法將其文字作為相同值帶回
2835
2836**該怎麼做:**
2837
2838* 在沒有這些限制的工作階段中,執行 `/tui fullscreen` 或 `/tui default` 以切換回。Claude Code 在那裡儲存 [`tui` 設定](/docs/zh-TW/settings-reference#tui)
2839
2840<h3 id="terminal-setup-left-your-zed-keymap-unchanged">
2841 /terminal-setup 讓您的 Zed 快捷鍵保持不變
2842</h3>
2843
2844您在 Zed 中執行了 [`/terminal-setup`](/docs/zh-TW/terminal-config#enter-multiline-prompts),Claude Code 無法完成對您的 Zed `keymap.json` 的更新,所以它讓檔案保持原樣。
2845
2846每個訊息命名您的快捷鍵的路徑,並以您自己新增的快捷鍵區塊結尾:
2847
2848```text theme={null}
2849Couldn't update your Zed keymap, so it was left unchanged.
2850To add the binding yourself, add this block to the keymap array in <path to keymap.json>:
2851{ "context": "Terminal", "bindings": { "shift-enter": ["terminal::SendText", "\u001b\r"] } }
2852```
2853
2854訊息的第一行命名原因:
2855
2856* `Couldn't read your Zed keymap, so it was left unchanged.`:Claude Code 無法讀取檔案,例如因為檔案權限
2857* `Your Zed keymap isn't a readable list of keybindings, so it was left unchanged.`:檔案讀取良好,但不解析為快捷鍵區塊陣列,即使允許 `//` 註釋和尾隨逗號
2858* `Couldn't back up your Zed keymap; not modifying it.`:Claude Code 無法將檔案複製到其旁邊的 `.bak` 備份,所以它沒有變更任何內容
2859* `Couldn't update your Zed keymap, so it was left unchanged.`:合併的結果未驗證為有效的快捷鍵,帶有綁定,所以 Claude Code 改為丟棄它而不是寫入。具有重複鍵的快捷鍵區塊可能導致此情況
2860
2861**該怎麼做:**
2862
2863* 將訊息中的區塊複製到您 `keymap.json` 中訊息命名的路徑處的頂級陣列中
2864* 對於 `isn't a readable list of keybindings`,修復語法錯誤,或使檔案的頂級值成為陣列,然後再次執行 `/terminal-setup`
2865
2866在 v2.1.247 之前,`/terminal-setup` 無法解析使用 `//` 註釋或尾隨逗號的 Zed 快捷鍵,它用僅自己的綁定替換整個檔案,同時報告綁定已安裝。若要恢復較早版本替換的快捷鍵,請使用[輸入多行提示](/docs/zh-TW/terminal-config#enter-multiline-prompts)下描述的 `.bak` 備份檔案。
2867
2868<h3 id="skill-usage-reports-are-not-available-on-this-connection">
2869 此連接上不提供技能使用報告
2870</h3>
2871
2872您在[遠端控制](/docs/zh-TW/remote-control)上、從您的手機或瀏覽器執行了 [`/skill-doctor`](/docs/zh-TW/skills#find-unused-skills)。Claude Code 不會透過遠端控制傳送技能使用報告,並改為以此訊息回覆:
2873
2874```text theme={null}
2875Skill usage reports are not available on this connection.
2876```
2877
2878**該怎麼做:**
2879
2880* 在工作階段執行所在的機器上的終端中執行 `/skill-doctor`,或在那裡執行 `claude -p "/skill-doctor"`
2881
2882<h2 id="plugin-errors">
2883 Plugin 錯誤
2884</h2>
2885
2886這些錯誤來自 [plugin](/docs/zh-TW/plugins) 和 [marketplace](/docs/zh-TW/plugin-marketplaces) 設定。對於不會產生此頁面上其中一則訊息的 plugin 問題,例如無法載入的 marketplace URL 或已安裝但未出現的 plugin,請參閱 [Plugin 疑難排解](/docs/zh-TW/discover-plugins#troubleshooting)。
2887
2888<h3 id="plugin-eval-is-currently-in-early-access">
2889 plugin eval 目前處於早期存取階段
2890</h3>
2891
2892您執行了 [`claude plugin eval`](/docs/zh-TW/plugin-evals) 或 `claude plugin eval init`,它在執行任何操作之前以退出代碼 1 和以下其中一則訊息結束:
2893
2894```text theme={null}
2895`plugin eval` is currently in early access
2896```
2897
2898```text theme={null}
2899`plugin eval` is currently unavailable
2900```
2901
2902第一則訊息表示您的組建版本早於 v2.1.269,這是該命令正式推出的第一個版本。第二則訊息表示 Anthropic 已在伺服器端關閉該命令;您的機器上沒有任何設定可以將其重新開啟。
2903
2904**該怎麼做:**
2905
2906* 執行 `claude --version`,然後執行 `claude update`,並在新的工作階段中再次執行該命令。請參閱 [plugin evals 的需求](/docs/zh-TW/plugin-evals#requirements)
2907* 如果您在目前的組建版本上看到第二則訊息,請在執行另一個 `claude update` 後稍後再試一次
2908
2909<h3 id="marketplace-is-registered-from-an-untrusted-source">
2910 Marketplace 是從不受信任的來源註冊的
2911</h3>
2912
2913Marketplace 是以 [為官方 Anthropic marketplace 保留的名稱](/docs/zh-TW/plugin-marketplaces#marketplace-schema) 註冊的,但其註冊的來源不是 `anthropics` GitHub 儲存庫。Claude Code 每次載入或重新整理 marketplace 時都會重新檢查保留的名稱,因此 marketplace 及從中安裝的 plugin 會停止載入。在 v2.1.205 之前,名稱只在新增 marketplace 時檢查,因此在其名稱變成保留名稱之前註冊的項目會繼續載入。
2914
2915```text theme={null}
2916Marketplace "claude-community" is registered from an untrusted source: The name 'claude-community' is reserved for official Anthropic marketplaces. Only repositories from 'github.com/anthropics/' can use this name. To fix it, remove the marketplace and re-add it from the official source.
2917```
2918
2919對於來源不是 GitHub 儲存庫或 Git URL 的 marketplace(例如本機目錄),中間句子改為 `can only be used with GitHub sources from the 'anthropics' organization`。`claude plugin marketplace add` 執行相同的檢查,並以 `Failed to add marketplace:` 後跟相同的保留名稱句子拒絕保留的名稱。
2920
2921**該怎麼做:**
2922
2923* 如果 marketplace 已經註冊,執行 `claude plugin marketplace remove <name>`,然後從官方 `github.com/anthropics` 儲存庫重新新增它
2924* 如果您發佈了在其名稱變成保留名稱之前使用該名稱的第三方 marketplace,請重新命名它並要求使用者從您的來源重新新增它
2925* 請參閱 [Marketplace schema](/docs/zh-TW/plugin-marketplaces#marketplace-schema) 下的保留名稱清單
2926
2927<h3 id="plugin-command-references-user-config">
2928 Plugin 命令在 shell 命令中參考 user\_config
2929</h3>
2930
2931Plugin hook、[monitor](/docs/zh-TW/plugins-reference#monitors) 或 MCP [`headersHelper`](/docs/zh-TW/mcp#use-dynamic-headers-for-custom-authentication) 命令參考 `${user_config.KEY}` [plugin 選項](/docs/zh-TW/plugins-reference#user-configuration),而替換後的字串會被傳遞到 shell。設定的值包含 `$(...)` 、反引號或 `;` 會在該處作為程式碼執行,因此 Claude Code 拒絕啟動該元件而不是替換該值。檢查在命令範本上執行,因此即使尚未設定任何值,錯誤也會出現。在 v2.1.207 之前,該值被替換到 shell 命令中。
2932
2933措辭取決於哪個介面參考了該選項。Shell 形式的 hook 報告:
2934
2935```text theme={null}
2936Hook from plugin formatter@acme-tools references ${user_config.*} in a shell-form command. The substituted value would be re-parsed by the shell. Use exec form instead — {"command": "<executable>", "args": ["${user_config.KEY}", ...]} — or read $CLAUDE_PLUGIN_OPTION_<KEY> from the hook's environment. Command: ./scripts/notify.sh ${user_config.webhook_url}
2937```
2938
2939Monitor 報告:
2940
2941```text theme={null}
2942Monitor "deploy-status" from plugin deploy-tools references ${user_config.*} in its command. The substituted value would be passed to a shell. Monitor commands cannot safely reference ${user_config.*}; have the monitor script read the value from a config file or prompt instead.
2943```
2944
2945MCP `headersHelper` 報告:
2946
2947```text theme={null}
2948headersHelper for MCP server 'internal-api' references ${user_config.*}. The substituted value would be passed to a shell; read the value inside the helper script instead (e.g. from an env var set in the server's "env" block).
2949```
2950
2951**該怎麼做:**
2952
2953* 對於 hook,新增 `args` 陣列使其以 [exec 形式](/docs/zh-TW/hooks#exec-form-and-shell-form) 執行,其中每個 `${user_config.KEY}` 變成一個沒有 shell 的單一引數。或者移除參考並在指令碼內讀取 `$CLAUDE_PLUGIN_OPTION_<KEY>` 環境變數
2954* 對於 monitor,移除參考並讓 monitor 指令碼從設定檔讀取該值
2955* 對於 `headersHelper`,將 `${user_config.KEY}` 移到伺服器的 `headers` 欄位(不會進行 shell 解析),或在 helper 指令碼內讀取該值
2956
2957<h3 id="plugin-archive-integrity-check-failed">
2958 Plugin 封存完整性檢查失敗
2959</h3>
2960
2961Plugin 的 marketplace 項目使用具有 `sha256` 釘選的 [`archive` 來源](/docs/zh-TW/plugin-marketplaces#zip-archives),而下載檔案的摘要與釘選不符。Claude Code 拒絕安裝,因此 plugin 快取中沒有任何變更。不符有三個可能的原因:
2962
2963* 作者計算釘選後,URL 上的檔案已變更
2964* 作者在 marketplace 項目中輸入了錯誤的摘要
2965* URL 提供的檔案與作者釘選的檔案不同
2966
2967```text theme={null}
2968Plugin archive integrity check failed for https://artifacts.example.com/claude-plugins/my-plugin.zip: expected sha256 6bfa50e3d2e00c052b46abe51fff89346ac803e45771f76dcf6df1ab74cca5e1, got ac52220c0914ef8ca6a602e4a7362f88d30fb021110f72a6d15b68c3fe7df2b7. The archive was not installed. Verify the sha256 in the marketplace entry, or that the URL serves the intended file.
2969```
2970
2971**該怎麼做:**
2972
2973* 如果您發佈 plugin,使用 `shasum -a 256 my-plugin.zip` 或在 PowerShell 中使用 `Get-FileHash -Algorithm SHA256 my-plugin.zip` 重新計算 URL 提供的確切檔案的摘要,並更新 marketplace 項目中的 `sha256`
2974* 如果您安裝 plugin,執行 `/plugin marketplace update <name>` 以重新整理目錄以防項目已更正,然後重試安裝
2975* 如果在重新整理後摘要仍然不符,請在安裝前詢問 marketplace 擁有者他們釘選了哪個檔案
2976
2977<h3 id="path-escapes-plugin-directory">
2978 路徑逃逸 plugin 目錄
2979</h3>
2980
2981Plugin 元件路徑(在 plugin 的 `plugin.json` 或其 [marketplace 項目](/docs/zh-TW/plugin-marketplaces#plugin-entries) 中宣告)解析到 plugin 自己的目錄之外。Claude Code 捨棄該路徑並載入 plugin 的其餘部分。訊息中的元件名稱(例如 `commands` 或 `hooks`)命名了宣告路徑的欄位。
2982
2983```text theme={null}
2984commands path escapes plugin directory: ./../shared.md
2985```
2986
2987在 `claude plugin` 命令輸出中,相同的錯誤讀作 `Path escapes plugin directory: ./../shared.md (commands)`。
2988
2989Claude Code 拒絕指向 plugin 外部的路徑(如 `../shared-utils`)和導致 plugin 外部的符號連結,以及 [marketplace 符號連結規則](/docs/zh-TW/plugins-reference#share-files-within-a-marketplace-with-symlinks) 不允許的符號連結。對於符號連結,訊息也會說明路徑解析的位置:
2990
2991```text theme={null}
2992commands path escapes plugin directory: ./commands/deploy.md — it resolves to /home/user/shared/deploy.md, outside the plugin directory
2993```
2994
2995在 macOS 和 Linux 上,Claude Code 也拒絕包含反斜線的元件路徑,即使路徑保持在 plugin 內。使用 Windows 風格分隔符的元件路徑的 plugin 在 Windows 上載入並在其他平台上觸發此拒絕:
2996
2997```text theme={null}
2998commands path escapes plugin directory: ./commands\deploy.md — its path contains a backslash, which is not resolved reliably on this platform
2999```
3000
3001在 v2.1.251 之前,Claude Code 載入在 marketplace 項目中宣告的 `commands` 路徑,即使它指向 plugin 目錄外。Claude Code 已經拒絕在 `plugin.json` 中宣告的路徑和 marketplace 項目中的其他元件路徑。
3002
3003在 v2.1.257 之前,檢查只查看路徑的拼寫,而不是符號連結導向的位置。
3004
3005**該怎麼做:**
3006
3007* 將參考的檔案移到 plugin 目錄內,並使用 `./` 相對路徑指向它
3008* 如果路徑是指向 plugin 外部檔案的符號連結,請用檔案副本替換符號連結
3009* 如果訊息說路徑包含反斜線,請使用正斜線寫入路徑,例如 `./commands/deploy.md`
3010* 若要與同一 marketplace 中的其他 plugin 共享檔案,請使用 plugin 目錄內的符號連結連結它們,遵循 [符號連結規則](/docs/zh-TW/plugins-reference#share-files-within-a-marketplace-with-symlinks)
3011
3012<h3 id="path-could-not-be-checked">
3013 無法檢查路徑
3014</h3>
3015
3016Claude Code 詢問作業系統 plugin 路徑是否存在,並收到除「找不到」以外的錯誤,因此它不會載入路徑命名的內容。plugin 的多少部分載入取決於哪個路徑失敗:
3017
3018* Plugin 的其中一個 [預設元件資料夾](/docs/zh-TW/plugins-reference#file-locations-reference)(例如 `skills/` 或 `commands/`):plugin 的其他元件仍會載入
3019* Plugin 自己的目錄:該 plugin 中沒有任何內容載入
3020
3021對於根本不存在的路徑,您看不到此錯誤。在 `/plugin` 中,錯誤出現在 plugin 下方,並命名路徑和作業系統傳回的程式碼:
3022
3023```text theme={null}
3024skills path could not be checked: /home/user/my-plugin/skills (ELOOP)
3025```
3026
3027在 `claude plugin list` 中,相同的錯誤讀作 `Path not found: /home/user/my-plugin/skills (skills, ELOOP)`。
3028
3029產生此錯誤的原因包括:
3030
3031* `ELOOP`:路徑中的符號連結指向自己或形成迴圈
3032* `EIO` 或 `ESTALE`:路徑在損壞或陳舊的網路掛載上
3033* `EACCES`:路徑上方的其中一個目錄拒絕您遍歷它的權限
3034
3035**該怎麼做:**
3036
3037* 用真實資料夾替換指向自己的符號連結,或刪除它
3038* 如果路徑在網路掛載上,重新掛載共享
3039* 如果程式碼是 `EACCES`,恢復您在路徑上方目錄上的執行權限
3040* 修復路徑後執行 `/reload-plugins`,或重新啟動 Claude Code,以載入 plugin 或元件
3041
3042在 v2.1.265 之前,Claude Code 將無法檢查的預設元件資料夾視為不存在,並在沒有錯誤的情況下載入 plugin 而不包含該元件。
3043
3044<h3 id="marketplace-entry-path-does-not-stay-inside-the-marketplace-directory">
3045 Marketplace 項目路徑不保持在 marketplace 目錄內
3046</h3>
3047
3048Plugin 的 [marketplace 項目](/docs/zh-TW/plugin-marketplaces#plugin-entries) 宣告了一個來源路徑,Claude Code 無法將其解析到 marketplace 自己的目錄內的位置,因此 plugin 不會安裝或載入。拒絕涵蓋:
3049
3050* 絕對的項目路徑、使用 `..` 爬出 marketplace 或拼寫成網路路徑的項目路徑
3051* 從遠端來源(例如 git 或 URL)擷取的 marketplace 中的項目,通過解析到 marketplace 目錄外的符號連結到達其目標
3052* 相對項目在從直接 URL 新增到其 `marketplace.json` 的 marketplace 中:Claude Code 只下載該檔案,因此路徑命名的本機 plugin 檔案不存在。請參閱 [相對路徑的 Plugin 在基於 URL 的 marketplace 中失敗](/docs/zh-TW/plugin-marketplaces#plugins-with-relative-paths-fail-in-url-based-marketplaces)
3053
3054`claude plugin install` 報告拒絕如下:
3055
3056```text theme={null}
3057Cannot install my-plugin@my-marketplace: its marketplace entry path does not stay inside the marketplace directory (an absolute, climbing, network-shaped or link-traversing entry, an entry of a fetched marketplace that resolves outside its tree — or a relative entry in a url-catalog marketplace, which has no local directory)
3058```
3059
3060當已安裝的 plugin 的項目失敗相同的檢查時,`claude plugin list` 將 plugin 顯示為 `failed to load`,並顯示:
3061
3062```text theme={null}
3063Plugin source path refused: ./my-plugin does not stay inside its marketplace directory. Check that the marketplace entry has a plain relative path.
3064```
3065
3066**該怎麼做:**
3067
3068* 如果您維護 marketplace,將項目的 `source` 寫成純相對路徑(例如 `./plugins/my-plugin`),並保持它跨越的任何符號連結指向 marketplace 目錄內
3069* 如果您從直接 URL 新增了 marketplace,相對項目無法解析。要求 marketplace 作者使用 [另一個 plugin 來源](/docs/zh-TW/plugin-marketplaces#plugin-sources),或改為從其 git 儲存庫新增 marketplace
3070
3071<h3 id="failed-to-load-marketplace-configuration">
3072 無法載入 marketplace 設定
3073</h3>
3074
3075Claude Code 將您新增的 plugin marketplace 保留在 `~/.claude/plugins/known_marketplaces.json` 的登錄檔案中。當 Claude Code 無法使用該檔案時,需要登錄的 plugin 命令(例如 `claude plugin install`)會失敗,並顯示以下兩則訊息之一:
3076
3077* `Failed to load marketplace configuration`:檔案不是有效的 JSON,或無法讀取。空檔案也會以這種方式失敗。
3078* `Marketplace configuration file is corrupted`:檔案是有效的 JSON,但其內容與登錄架構不符。
3079
3080遺失的檔案不是失敗:Claude Code 將其視為沒有 marketplace 的登錄。
3081
3082使用空檔案時,`claude plugin install` 報告:
3083
3084```text theme={null}
3085✘ Failed to install plugin "my-plugin": Failed to load marketplace configuration: JSON Parse error: Unexpected EOF
3086```
3087
3088在 v2.1.246 之前,`claude plugin install` 沒有報告此失敗。
3089
3090**該怎麼做:**
3091
3092* 開啟 `~/.claude/plugins/known_marketplaces.json` 並修復 JSON,或修復訊息命名為與登錄架構不符的項目
3093* 如果您無法修復它,刪除檔案或用 `{}` 替換其內容,然後使用 `claude plugin marketplace add <source>` 重新新增每個 marketplace。Claude Code 在您下次在已信任的資料夾中啟動它時,重新註冊您的使用者或受管設定在 [`extraKnownMarketplaces`](/docs/zh-TW/settings-reference#extraknownmarketplaces) 中宣告的 marketplace。
3094
3095<h2 id="tool-errors">
3096 工具錯誤
3097</h2>
3098
3099這些錯誤來自 Claude 的內建工具。Claude 會自動修正大多數工具錯誤。當需要您進行變更時,該錯誤的**應該怎麼做**清單會說明要變更的內容。
3100
3101<h3 id="agent-would-be-spawned-with-zero-tools">
3102 Agent would be spawned with zero tools
3103</h3>
3104
3105子代理的 [`tools` 清單](/docs/zh-TW/sub-agents#supported-frontmatter-fields)中的每個項目都無法符合可用的工具,因此 Claude Code 拒絕啟動子代理:沒有工具,它就無法行動。該訊息會按出錯原因將您的項目分組:
3106
3107* **Unrecognized**:該項目不符合任何工具名稱,通常是打字錯誤,例如 `Grpe` 而非 `Grep`。
3108* **Not available to subagents**:該項目命名了一個真實工具,但[子代理無法使用](/docs/zh-TW/sub-agents#available-tools)。背景子代理保持較小的內建工具集,因此當子代理在背景中執行時(這是預設行為),只有前景子代理才能使用的項目會出現在此處。如果您列出 `Agent`,該訊息會改為在下一個群組下報告它。
3109* **Matched no tools in this session**:該項目有效,但目前工作階段中沒有工具符合它,例如沒有連接 GitHub MCP 伺服器的 `mcp__github__*`,或位於[深度限制](/docs/zh-TW/sub-agents#let-subagents-spawn-their-own-subagents)的子代理的 `Agent`。
3110
3111省略 `tools` 欄位永遠不會觸發此拒絕。如果您將 `tools` 清單留空,或 `disallowedTools` 移除其中的每個項目,Claude Code 也會跳過拒絕並啟動沒有工具的子代理。
3112
3113在 v2.1.208 之前,子代理啟動時沒有工具,可能會傳回空的或令人困惑的結果。
3114
3115```text theme={null}
3116Agent 'code-reviewer' would be spawned with zero tools — refusing. Its tools list resolved to nothing: unrecognized [Grpe]. Fix the agent's tools frontmatter or pass a different subagent_type.
3117```
3118
3119**應該怎麼做:**
3120
3121* 根據[子代理可用的工具](/docs/zh-TW/sub-agents#available-tools)修正錯誤命名的每個項目
3122* 移除工作階段沒有的工具項目,例如來自未連接伺服器的 MCP 工具
3123* 對於[背景子代理會捨棄](/docs/zh-TW/sub-agents#available-tools)的工具(例如 `LSP`),移除該項目。若要保留工具,請[關閉 fork 模式](/docs/zh-TW/sub-agents#turn-fork-mode-on-or-off)並要求 Claude 在前景中執行子代理
3124* 刪除 `tools` 欄位而不是列出工具,以給予子代理[子代理可用的每個工具](/docs/zh-TW/sub-agents#available-tools)
3125* 對於只包含 `Agent` 的 `tools` 清單,提高[深度限制](/docs/zh-TW/sub-agents#let-subagents-spawn-their-own-subagents)或給予代理至少一個其他工具:Claude Code 在該限制處保留 `Agent`,因此只有其他內容的清單會解析為沒有工具
3126
3127<h3 id="file-is-covered-by-a-read-deny-rule">
3128 File is covered by a Read deny rule
3129</h3>
3130
3131Edit 或 Write 工具在由 [`Read` 拒絕規則](/docs/zh-TW/permissions#read-and-edit)符合的路徑上被呼叫,包括在該路徑建立新檔案。兩個工具都會變更 Claude 必須能夠讀回的內容,因此 Claude Code 在任何檔案存取之前拒絕呼叫。NotebookEdit 不受 `Read` 拒絕規則涵蓋。在 v2.1.228 之前,該規則僅阻止 Edit 工具,在 v2.1.208 之前,只有 `Edit` 拒絕規則阻止編輯。
3132
3133```text theme={null}
3134File is covered by a Read deny rule in your permission settings and cannot be edited.
3135```
3136
3137當 Claude Code 拒絕 Write 工具時,訊息結尾改為 `and cannot be written`。
3138
3139**應該怎麼做:**
3140
3141* 如果 Claude 應該能夠變更檔案,請在 `/permissions` 或[設定](/docs/zh-TW/settings-reference#permission-settings)中移除或縮小 `Read` 拒絕規則
3142* 如果檔案必須保持未觸及,請保留規則並為相同路徑新增 `Edit` 拒絕規則以同時阻止 NotebookEdit 工具
3143
3144<h3 id="subagent-type-is-required">
3145 subagent\_type is required
3146</h3>
3147
3148```text theme={null}
3149subagent_type is required: the general-purpose agent is not available in this session. Available agents: ...
3150```
3151
3152Claude 呼叫了 [Agent 工具](/docs/zh-TW/tools-reference#agent-tool-behavior)但沒有 `subagent_type`,而此工作階段沒有[通用子代理](/docs/zh-TW/sub-agents#built-in-subagents)可作為備用。這在兩種設定中是這樣的情況:
3153
3154* [`CLAUDE_AGENT_SDK_DISABLE_BUILTIN_AGENTS=1`](/docs/zh-TW/env-vars) 在非互動模式中設定,這會移除每個內建子代理
3155* 工作階段的主執行緒代理有一個 [`tools: Agent(...)` 允許清單](/docs/zh-TW/sub-agents#restrict-which-subagents-can-be-spawned),其中不包括 `general-purpose`
3156
3157**應該怎麼做:**
3158
3159* 通常不需要做任何事:該訊息列出工作階段確實擁有的子代理,因此 Claude 可以使用其中一個重試
3160* 如果 Claude 持續失敗,請將 `general-purpose` 新增到 `tools: Agent(...)` 允許清單,或取消設定 `CLAUDE_AGENT_SDK_DISABLE_BUILTIN_AGENTS`
3161
3162在 v2.1.235 之前,相同的呼叫失敗並顯示 `Agent type 'general-purpose' not found`。
3163
3164<h3 id="memory-index-is-over-its-read-limit">
3165 Memory index is over its read limit
3166</h3>
3167
3168Claude 寫入了[自動記憶](/docs/zh-TW/memory#auto-memory)索引 `MEMORY.md` 並將其留在其中一個讀取限制之上:200 行或 25KB。寫入成功,但只有前 200 行或 25KB(以先到者為準)在工作階段開始時載入,因此超過限制的所有內容在每次讀取索引時都會被捨棄。在 v2.1.210 之前,超過限制的索引在下次載入時會被無聲地截斷,沒有寫入時間訊號。
3169
3170```text theme={null}
3171Error: this write left the memory index at MEMORY.md at 214 lines, over its 200-line read limit. The write succeeded, but everything past the limit is silently dropped each time the index is loaded — entries at the end are already invisible to readers. Rewrite it to under 140 lines now: keep one line per entry, move detail into topic files, and merge or drop stale entries.
3172```
3173
3174只有載入的內容才計入限制。YAML frontmatter 和區塊級 HTML 註解在索引載入前會被移除,因此它們被排除在測量之外。在 v2.1.211 之前,Claude Code 測量原始檔案,frontmatter 或註解即使在載入的內容符合時也可能觸發此錯誤。
3175
3176Claude Code 在寫入後將錯誤傳遞給 Claude,而不是在您的終端中列印為橫幅,因此您可能只在文字記錄中注意到它。
3177
3178當 Claude 的寫入使檔案接近限制但未超過時,Claude Code 會傳回更溫和的提醒以壓縮索引,而不是此錯誤。
3179
3180**應該怎麼做:**
3181
3182* 讓 Claude 重寫 `MEMORY.md`,或要求它:每個項目保留一行,將詳細資訊移到主題檔案中,並合併或捨棄過時的項目
3183* 若要自己修剪索引,請參閱[稽核和編輯您的記憶](/docs/zh-TW/memory#audit-and-edit-your-memory)
3184
3185<h3 id="pkill-pattern-matches-the-claude-code-process">
3186 pkill pattern matches the Claude Code process
3187</h3>
3188
3189Bash 工具呼叫中的 `pkill` 命令使用了一個模式(通常使用 `-f`),該模式符合 Claude Code 程序本身,因此 Claude Code 拒絕該命令而不是讓它結束工作階段。Claude Code 在執行 `pkill` 之前使用 `pgrep` 測試模式,並在其自己的程序 ID 在結果中時拒絕。檢查僅在 Linux 上執行;在 macOS 上,`pkill` 不經修改地執行。在 v2.1.214 之前,命令執行,符合的模式在轉換中途殺死了 Claude Code 工作階段。
3190
3191```text theme={null}
3192pkill: refusing to run — this pattern matches the Claude CLI process (PID 12345). Narrow the pattern, or target your own children with `pkill -P $$ ...`.
3193```
3194
3195拒絕出現在 Bash 工具結果中,而不是作為您終端中的橫幅,Claude 通常會自行調整命令。
3196
3197**應該怎麼做:**
3198
3199* 縮小模式,使其僅符合預期的程序,例如目標二進位檔的完整路徑而不是短子字串
3200* 若要停止由目前 shell 啟動的程序,請使用 `pkill -P $$` 搭配模式,這會將符合限制為 shell 自己的子程序
3201
3202<h3 id="failed-to-write-to-a-teammate-inbox">
3203 Failed to write to a teammate's inbox
3204</h3>
3205
3206Claude Code 無法將訊息寫入 `~/.claude/teams/{team-name}/inboxes/` 下的隊友信箱檔案,因此收件人沒有收到任何內容。當 Claude Code 無法建立或更新檔案時寫入失敗,例如因為磁碟已滿、目錄不可寫,或另一個代理長時間持有收件箱鎖。在 v2.1.224 之前,Claude Code 即使寫入失敗也報告訊息已傳送。
3207
3208錯誤出現在傳送代理的工具結果中,而不是作為您終端中的橫幅,其文字告訴 Claude 重試:
3209
3210```text theme={null}
3211Failed to write to researcher's inbox — nothing was sent. Try again, or message the lead.
3212```
3213
3214結構化[代理團隊](/docs/zh-TW/agent-teams)協議訊息以相同方式失敗,錯誤命名未傳遞的訊息:當 Claude Code 無法寫入計畫核准、計畫拒絕、關閉要求或關閉拒絕時,錯誤讀作 `Failed to write the <message> to <name>'s inbox — nothing was sent`。該清單中的 `plan approval` 是領導者核准隊友計畫的決定;隊友的計畫提交是單獨的 `plan approval request` 訊息。該訊息和另外兩個協議訊息帶有自己的訊息文字和後果:
3215
3216* `Failed to write the plan approval request to the lead's inbox — plan not submitted; try again`:隊友的計畫從未到達領導者,隊友保持在計畫模式中,直到重新提交成功
3217* `The permission request could not be delivered to the team lead (mailbox write failed)`:隊友的權限要求從未到達領導者,因此沒有人核准工具呼叫
3218* `The confirmation could not be written to team-lead's inbox.`:關閉核准本身生效,隊友退出;只有對領導者的確認遺失
3219
3220當您自己訊息隊友時,在領導者工作階段中輸入 `@name` 後跟訊息,相同的失敗顯示為通知 `Couldn't write to @name's inbox — message not sent. Try again.`,Claude Code 將您的文字保留在提示框中,以便您可以再次傳送。
3221
3222**應該怎麼做:**
3223
3224* 要求傳送者重新傳送訊息;收件箱鎖的爭用是暫時的,在重試時清除
3225* 檢查可用磁碟空間,並檢查 `~/.claude/teams` 及其下的檔案是否可由您的使用者寫入
3226
3227<h3 id="message-too-large-for-cross-session-delivery">
3228 Message too large for cross-session delivery
3229</h3>
3230
3231Claude 的[跨工作階段訊息](/docs/zh-TW/cross-session-messaging)到此機器上您的另一個工作階段太長而無法傳送。Claude Code 拒絕了它,接收工作階段沒有收到任何內容。拒絕出現在傳送工作階段的工具結果中,而不是作為您終端中的橫幅。它命名了兩個大小以及如何使訊息符合:
3232
3233```text wrap theme={null}
3234Failed to send to api-worker: Message too large for cross-session delivery: the serialized message is 1,203,844 characters and the limit is 1,048,576. Shorten the message text — put bulk content in a file the recipient can read rather than in the message — or split it into smaller messages.
3235```
3236
3237重新傳送相同的文字以相同方式失敗。
3238
3239**應該怎麼做:**
3240
3241* 要求 Claude 總結訊息,或將大量內容放在收件人可以讀取的檔案中並傳送檔案的路徑
3242* 要求 Claude 將內容分割成幾個較短的訊息
3243
3244在 v2.1.235 之前,Claude Code 報告超大訊息已傳送。接收工作階段未讀就捨棄了它。
3245
3246<h3 id="too-many-messages-to-this-session-just-now">
3247 Too many messages to this session just now
3248</h3>
3249
3250Claude 向此機器上您的一個工作階段傳送了快速的[跨工作階段訊息](/docs/zh-TW/cross-session-messaging)爆發,爆發達到該工作階段的收件箱接受的內容。Claude Code 拒絕了下一個傳送,接收工作階段沒有收到任何內容。拒絕出現在傳送工作階段的工具結果中,而不是作為您終端中的橫幅:
3251
3252```text wrap theme={null}
3253Failed to send to api-worker: Too many messages to this session just now: 30 were sent recently and more would be dropped by its rate limit, so this one was not sent. Batch what remains into one message, or wait a little before sending more.
3254```
3255
3256**應該怎麼做:**
3257
3258* 通常不需要做任何事:Claude 將剩餘內容批次處理為一個訊息,或在傳送更多內容之前等待
3259* 如果您自己提示了爆發,請要求 Claude 將剩餘內容合併為單一訊息
3260
3261在 v2.1.236 之前,Claude Code 報告這些傳送已傳送。接收工作階段未讀就捨棄了它們。
3262
3263<h3 id="refusing-to-send-a-cross-session-message">
3264 Refusing to send a cross-session message
3265</h3>
3266
3267在 Claude Code 將[跨工作階段訊息](/docs/zh-TW/cross-session-messaging)寫入此機器上您的另一個工作階段之前,它會檢查目標工作階段的收件箱通訊端是否是訊息定址到的端點。當檢查失敗時,Claude Code 在傳送工作階段中拒絕傳送,目標工作階段沒有收到任何內容。對於 Claude 傳送的訊息,拒絕出現在傳送工作階段的工具結果中:
3268
3269```text theme={null}
3270Failed to send to api-worker: Refusing to send: reply target is a symlink
3271```
3272
3273`Refusing to send:` 之後的文字命名失敗的檢查:
3274
3275* `reply target is a symlink`:符號連結位於目標工作階段的通訊端路徑。Claude Code 不會透過它傳遞,因為那裡的連結可能會將訊息重新導向到目標工作階段未建立的端點。
3276* `cannot vet reply target`:Claude Code 無法檢查目標路徑,例如因為讀取失敗並出現權限錯誤。
3277* `connected endpoint is not the expected process`:持有通訊端的程序不是訊息定址到的工作階段,因此位址已過時或另一個程序取代了通訊端。
3278* `connected endpoint identity could not be read`:Claude Code 已連接但無法讀取哪個程序持有另一端,因此無法確認目標。這可能是暫時的。
3279* `connected endpoint is not owned by this user`:持有通訊端的程序以不同的使用者帳戶執行,因此它不是您的工作階段之一。
3280* `connected endpoint owner could not be read`:Claude Code 已連接但無法讀取哪個使用者帳戶擁有另一端,因此無法確認端點是您的。
3281* `connected endpoint is a different process with the expected pid`:程序 ID 符合訊息定址到的 ID,但 Claude Code 無法確認它是相同的程序。通常該工作階段已退出,作業系統重新使用了其程序 ID,因此位址已過時。
3282
3283**應該怎麼做:**
3284
3285* 通常不需要做任何事:檢查會防止訊息到達定址到的工作階段以外的端點,沒有傳送任何內容
3286* 要求 Claude 再次列出您的工作階段並重新傳送;由過時位址引起的拒絕在 Claude 傳送到目前的工作階段後清除
3287* 如果 `reply target is a symlink` 對一個工作階段重複,請檢查在該工作階段的通訊端路徑建立連結的內容,顯示在其 `/status` 下的 `Peer address`
3288* 對於 `connected endpoint identity could not be read`,重新傳送;該條件可能是暫時的
3289* 如果 `connected endpoint is not owned by this user` 出現在共用機器上,該位址的工作階段在另一個使用者帳戶下執行,因此 Claude 無法從您的帳戶訊息它
3290
3291在 v2.1.248 之前,Claude Code 沒有檢查端點的擁有使用者或程序啟動時間,因此命名這些檢查的拒絕不會出現在較早的版本上。
3292
3293<h3 id="refusing-after-a-symlink-changed">
3294 Refusing to read, write, or search a path
3295</h3>
3296
3297Claude Code 檢查檔案路徑的[權限規則](/docs/zh-TW/permissions#read-and-edit),然後在工具開啟檔案或啟動搜尋時再次確認該解析。當它無法確認路徑仍然導向檢查核准的位置時,Claude Code 拒絕操作而不是跟隨它。拒絕出現在工具結果中:
3298
3299```text theme={null}
3300Refusing to read /path/to/file: its symlink resolution changed after permission was checked. If a link in the working directory is being rewritten concurrently, stop that and retry.
3301```
3302
3303路徑之後的文字命名原因:
3304
3305* `its symlink resolution changed after permission was checked`:路徑中的符號連結,或在 Grep 或 Glob 搜尋根目錄,在權限檢查和操作之間被取代
3306* `its parent-directory symlink resolution changed after permission was checked`:寫入路徑通過的目錄不再解析到核准的位置
3307* `it is a symbolic link. Write to the link's target path instead`:符號連結位於核准的寫入位置本身
3308* `a path one of its Read deny rules is written through changed while the search was being prepared. Retry.`:`Read` 拒絕規則的搜尋命名通過符號連結的路徑,該連結在 Claude Code 準備搜尋時變更
3309* `it could not be opened (EACCES) — it is unreadable, or is being replaced concurrently.`:搜尋根目錄存在但無法開啟;括號中的代碼是作業系統錯誤
3310* `its permission check expired before it ran (too many concurrent file operations). Retry.`:Claude Code 在許多同時檔案操作下驅逐核准記錄,然後工具使用它;重試執行新的權限檢查
3311* `ripgrep was found only by name on PATH, and a search outside the working directory cannot apply your Read deny rules in that configuration`:Claude Code 無法將 `rg` 二進位檔解析為絕對路徑,因此它拒絕在工作目錄外的搜尋,而不是執行您的拒絕規則不涵蓋的搜尋
3312
3313**應該怎麼做:**
3314
3315* 通常不需要做任何事:拒絕作為工具結果到達 Claude,被拒絕的操作不執行
3316* 如果符號連結拒絕在一個路徑上重複,請找到持續重寫那裡的連結的內容,例如建置工具或檔案監視程式,或要求 Claude 使用檔案的已解析路徑而不是連結的路徑
3317* 如果此拒絕在 Claude Code 在 Windows 內的 AppContainer 或受限制權杖沙箱中執行時出現在每個檔案上,請升級到 v2.1.265 或更新版本
3318* 對於 ripgrep 拒絕,使用您的套件管理員安裝 ripgrep,以便 `rg` 在 `PATH` 上解析為絕對路徑,或將搜尋保留在工作目錄下
3319
3320在 v2.1.251 之前,Claude Code 僅對檔案寫入重新檢查路徑的解析,因此在權限檢查後取代的連結可能會將讀取或搜尋重新導向到不同位置,而沒有訊息。在這些拒絕中,只有父目錄寫入拒絕出現在較早的版本上。
3321
3322<h3 id="task-output-swap-refused">
3323 Task output swap refused
3324</h3>
3325
3326Claude Code 將每個 Bash 命令的輸出儲存到其臨時目錄下的檔案。每次它開啟其中一個檔案時,它都會檢查路徑是否仍然導向它建立的檔案,沒有符號連結、額外硬連結或移動的目錄重新導向它。此訊息表示該檢查失敗,因此 Claude Code 拒絕操作而不是透過該路徑寫入或讀取輸出。訊息出現在 Bash 工具結果中:
3327
3328```text wrap theme={null}
3329task output swap refused (tasks dir moved or linked): /private/tmp/claude-501/-Users-you-my-project/1f0e62dc-4b0a-4f5e-9c2d-8a7b6c5d4e3f/tasks/b7k2f9m3q.output. To recover: restart Claude Code with CLAUDE_CODE_TMPDIR set to a fresh directory; or, if /private/tmp/claude-501/-Users-you-my-project is a stray directory or a symbolic link that should not be there, remove that entry itself (not what it points to) and restart.
3330```
3331
3332括號中的文字命名失敗的檢查。`output symlink was re-pointed`、`output file identity changed` 和 `not a regular file` 等原因都報告相同的條件:輸出路徑上或沿著的某些內容不再是 Claude Code 建立的檔案。只有某些原因帶有 `To recover:` 句子。
3333
3334如果檢查在命令仍在執行時失敗,Claude Code 會停止命令,其結果報告:
3335
3336```text theme={null}
3337Command killed: its output file was replaced or could no longer be verified
3338```
3339
3340**應該怎麼做:**
3341
3342* 升級到 v2.1.260 或更新版本。較早的版本有時在沒有連結或移動目錄存在時顯示此訊息
3343* 使用 [`CLAUDE_CODE_TMPDIR`](/docs/zh-TW/env-vars) 設定為新目錄重新啟動 Claude Code
3344* 或檢查 Claude Code 臨時目錄下的專案目錄,範例訊息中的 `/private/tmp/claude-501/-Users-you-my-project`。如果該路徑是符號連結,或不應該存在的目錄,請移除連結或目錄本身而不是連結的目標,然後重新啟動 Claude Code
3345* 如果拒絕重複,程序在工作階段執行時替換、連結或移除 Claude Code 臨時目錄下的項目。將 [`CLAUDE_CODE_TMPDIR`](/docs/zh-TW/env-vars) 設定為沒有其他內容管理的目錄並重新啟動
3346
3347<h3 id="the-source-file-is-not-valid-utf-8-text">
3348 The source file is not valid UTF-8 text
3349</h3>
3350
3351Claude 嘗試從位元組不解碼為文字的檔案發佈[成品](/docs/zh-TW/artifacts),或其文字已包含替換字元 `U+FFFD`,因此 Claude Code 在上傳任何內容之前拒絕發佈。訊息出現在成品工具結果中並命名要修正的第一個位置:
3352
3353```text wrap theme={null}
3354file_path: the source file is not valid UTF-8 text (first invalid byte at line 12, column 40). It may be saved in another encoding or contain binary data. Rewrite it as UTF-8, then publish again. Nothing was published.
3355
3356file_path: the source file has the replacement character U+FFFD at line 12, column 40, usually left where an earlier edit or paste lost a character. Replace it with the intended text (in HTML, write an intended U+FFFD as �), then publish again. Nothing was published.
3357```
3358
3359Claude Code 將檔案解碼為 UTF-8,或當它以小端 UTF-16 位元組順序標記開頭時解碼為 UTF-16。當這樣的 UTF-16 檔案無法解碼時,第一個訊息命名 `UTF-16` 並仍然告訴您將檔案重寫為 UTF-8。當更多位置跟隨命名的位置時,訊息在位置之後新增計數,例如 `(+2 more)`。
3360
3361**應該怎麼做:**
3362
3363* 通常不需要做任何事:Claude 重寫檔案並再次發佈
3364* 如果檔案是您寫入或匯出的,請再次將其儲存為 UTF-8,並將每個 `U+FFFD` 替換為較早的編輯、貼上或轉換遺失的字元
3365* 若要在頁面上顯示有意的 `U+FFFD`,請在 HTML 中將其寫為 `�` 而不是字面字元
3366
3367在 v2.1.267 之前,Claude Code 上傳了這樣的檔案而不檢查它,伺服器改為拒絕發佈。
3368
3369<h2 id="background-session-errors">
3370 背景工作階段錯誤
3371</h2>
3372
3373[背景工作階段](/docs/zh-TW/agent-view)在沒有互動式終端的情況下執行,因此需要終端的命令在那裡的行為會有所不同。這些訊息會出現在背景工作階段的文字記錄中、附加到背景工作階段的終端中、您分派的工作階段或殼層中,或者對於下面的[worktree-guard 項目](#write-or-command-blocked-because-the-path-cannot-be-safely-resolved),會出現在任何在 worktree 中隔離或執行 worktree 隔離子代理的工作階段中;當訊息特定於某個表面時,其項目會說明。
3374
3375<h3 id="commands-refused-in-a-background-session">
3376 在背景工作階段中拒絕的命令
3377</h3>
3378
3379開啟互動式對話框的命令在沒有終端附加到背景工作階段時無法執行。`/install-github-app`、`/mcp` 設定清單和 MCP 伺服器選單中的驗證動作會回應一則訊息,工作階段會在[代理檢視](/docs/zh-TW/agent-view)中的 **Needs input** 下出現,以便您可以找到它、附加並再次執行命令。當終端附加時,這些命令正常運作。
3380
3381在 v2.1.216 之前,工作階段在其中一個拒絕後不會在 **Needs input** 下出現。在 v2.1.213 到 v2.1.215 中,命令在附加終端時仍然有效,拒絕訊息告訴您附加並再次執行命令。從 v2.1.208 到 v2.1.212,Claude Code 即使在附加終端時也拒絕它們,訊息如 `Can't open MCP settings in a background session`;在這些版本上,改為從常規 `claude` 工作階段執行命令,或升級。在 v2.1.208 之前,它們在背景工作階段內開啟其對話框。在 v2.1.208 中,Claude Code 也拒絕了背景工作階段中的 `/model` 選擇器,`/upgrade` 列印升級 URL 而不是開啟瀏覽器。
3382
3383措辭會命名該命令。`/mcp` 設定清單報告:
3384
3385```text theme={null}
3386Can't open MCP settings while no terminal is attached to this background session. This session now shows "needs input" in agent view — open it and run /mcp to manage servers, or use `/mcp enable|disable|reconnect <server>` to steer without the panel.
3387```
3388
3389**該怎麼做:**
3390
3391* 從代理檢視附加到工作階段,其中它列在 **Needs input** 下,並再次執行命令
3392* 或使用訊息命名的形式,例如 `/mcp reconnect <server>`、`/mcp enable` 或 `/mcp disable`,這些在不附加的情況下有效
3393
3394<h3 id="write-or-command-blocked-because-the-path-cannot-be-safely-resolved">
3395 寫入或命令被阻止,因為路徑無法安全解析
3396</h3>
3397
3398Claude 透過 [worktree 隔離防護](/docs/zh-TW/agent-view#how-file-edits-are-isolated)無法解析為一個可驗證位置的拼寫來定址檔案或工作目錄。防護檢查[任何在 worktree 中隔離的工作階段](/docs/zh-TW/worktrees#how-claude-code-enforces-isolation)中的寫入和命令工作目錄,互動式或背景,以及[worktree 隔離子代理](/docs/zh-TW/worktrees#isolate-subagents-with-worktrees)中的寫入和命令工作目錄。它在檢查操作不會到達共享簽出之前解析符號連結,當解析失敗時,它會阻止操作而不是讓它落在那裡。訊息命名它拒絕的路徑形式以及如何重試:
3399
3400```text theme={null}
3401This write was blocked because the path is spelled in a form that cannot be safely resolved (for example through a symlink storing a raw dot segment, a network-share or device-namespace shape, or an unreadable ancestor directory). If the file is inside the worktree /path/to/worktree, address it by its direct symlink-free path instead.
3402```
3403
3404被阻止的命令報告其工作目錄的相同原因,並以 `re-run the command from its direct symlink-free path` 結尾。在 v2.1.217 之前,防護比較路徑拼寫而不解析符號連結,因此這些拼寫未被阻止,透過符號連結路由的寫入可能會落在共享簽出中。
3405
3406**該怎麼做:**
3407
3408* 通常什麼都不做:完整訊息作為工具錯誤傳遞給 Claude,Claude 使用它命名的直接路徑重試。對於被阻止的檔案編輯,對話檢視只顯示簡短的 `Error editing file` 行;完整訊息出現在文字記錄檢視中,您可以使用 `Ctrl+O` 開啟。被阻止的命令在其命令輸出中列印它。
3409* 如果同一檔案上的阻止重複,路徑可能透過已提交的符號連結執行,其目標包含 `..`,例如 `docs/current -> ../README.md`;要求 Claude 透過其真實路徑編輯目標檔案,而不是透過連結
3410
3411<h3 id="write-or-command-blocked-because-the-path-names-a-network-location">
3412 寫入或命令被阻止,因為路徑命名網路位置
3413</h3>
3414
3415Claude 透過命名不在您機器上的磁碟機、UNC 共享(例如 `\\server\share\file`)或 `/net` 自動掛載路徑的路徑來定址檔案或工作目錄,而工作階段的簽出在本機磁碟上。相同的 [worktree 隔離防護](#write-or-command-blocked-because-the-path-cannot-be-safely-resolved)無法驗證這樣的路徑保持在共享簽出之外,因此它會阻止操作。在 worktree 中隔離工作階段不會解除阻止。訊息命名要改用的路徑形式:
3416
3417```text theme={null}
3418This write was blocked because the path is network-shaped (a UNC share or /net automount spelling) while this session's checkout is local. Isolating cannot unblock it. If the file is genuinely inside the worktree /path/to/worktree, address it by its local, plainly-spelled path instead.
3419```
3420
3421被阻止的命令報告其工作目錄的相同原因,並以 `re-run the command from its local, plainly-spelled path` 結尾。在 v2.1.217 之前,防護只比較路徑文字,因此透過 UNC 或 `/net` 路徑定址簽出內的檔案未被阻止。
3422
3423**該怎麼做:**
3424
3425* 通常什麼都不做:Claude 使用訊息要求的本機拼寫重試
3426* 如果檔案在網路共享上而不是用網路路徑拼寫的本機檔案,它在工作階段的本機工作區之外;改為從常規互動式工作階段編輯它
3427
3428<h3 id="this-session-has-no-saved-transcript">
3429 此工作階段沒有已儲存的文字記錄
3430</h3>
3431
3432您附加到已停止的[背景工作階段](/docs/zh-TW/agent-view),該工作階段使用 `←` 或 `/background` 從另一個對話背景化,並在其第一個回應完成之前停止。在該第一個回應完成之前,對話仍然只存在於背景化它的工作階段中,因此 `claude attach` 拒絕啟動已停止的工作階段,而不是在相同工作階段 ID 下開始空白對話。訊息以此工作階段的 `claude respawn` 命令結尾:
3433
3434```text theme={null}
3435This session has no saved transcript — it was stopped before its first response finished. If it was backgrounded from another conversation, that one is still intact; `claude respawn <id>` starts this one fresh.
3436```
3437
3438在[代理檢視](/docs/zh-TW/agent-view)中開啟相同工作階段的列在清單下方顯示 `Press enter again to restart this session fresh`,列上的第二個 `Enter` 使用空白對話重新啟動工作階段。在 v2.1.212 之前,開啟列顯示拒絕訊息,無法從代理檢視重新啟動。在 v2.1.211 之前,開啟已停止的工作階段無聲地啟動該空白對話,並可以重新執行工作階段的原始提示。
3439
3440**該怎麼做:**
3441
3442* 您背景化的對話完整無缺:使用 [`claude --resume`](/docs/zh-TW/sessions) 繼續它或繼續在其中工作
3443* 要無論如何啟動已停止的工作階段,請使用訊息中的 ID 執行 `claude respawn <id>`,或在代理檢視中的其列上按 `Enter` 兩次
3444* 如果工作階段確實完成了回應,您仍在 v2.1.214 之前的版本上看到此拒絕,`~/.claude/projects` 中的不可讀資料夾可能會使文字記錄掃描遺漏已儲存的對話;更新到 v2.1.214 或更新版本,其在掃描期間容許不可讀資料夾
3445
3446<h3 id="this-session-is-running-in-another-terminal">
3447 此工作階段在另一個終端中執行
3448</h3>
3449
3450您在[代理檢視](/docs/zh-TW/agent-view)中開啟了已停止工作階段的列,其已儲存的對話已在此機器上的另一個即時 Claude Code 程序中開啟,因此 Claude Code 拒絕啟動將寫入相同文字記錄的第二個程序。您看到的訊息取決於[什麼保持對話](/docs/zh-TW/agent-view#opening-a-session-says-the-conversation-is-already-open):
3451
3452```text theme={null}
3453Can't open — this session is running in another terminal
3454This conversation is already open in another running Claude session — use that one, or close it and try again
3455```
3456
3457* **`running in another terminal`**:終端保持對話,例如您使用 `claude --resume` 或 `/resume` 繼續它的終端。列也顯示 `Open in a terminal`。
3458* **`already open in another running Claude session`**:另一個非互動式 Claude Code 程序保持它,例如相同對話的[背景工作階段](/docs/zh-TW/agent-view#the-supervisor-process)程序,尚未退出。
3459
3460Claude Code 儲存您在開啟列時輸入的回覆,並在工作階段下次啟動時將其作為工作階段的下一個提示傳送。
3461
3462**該怎麼做:**
3463
3464* 在保持它開啟的程序中繼續對話,或退出該程序並再次開啟列
3465
3466在 v2.1.248 之前,只有 `already open in another running Claude session` 拒絕存在:在終端中繼續的對話不計為開啟,開啟列啟動寫入相同對話的第二個 Claude Code 程序。
3467
3468<h3 id="this-sessions-saved-conversation-is-no-longer-on-disk">
3469 此工作階段的已儲存對話不再在磁碟上
3470</h3>
3471
3472您開啟了在背景服務關閉時結束的[背景工作階段](/docs/zh-TW/agent-view),[文字記錄清理](/docs/zh-TW/settings-reference#cleanupperioddays)已移除其已儲存的對話,例如在機器關閉數週後。通常開啟這樣的列會[繼續其已儲存的對話](/docs/zh-TW/agent-view#sessions-show-as-failed-after-shutdown)。沒有什麼可繼續,Claude Code 拒絕而不是在不詢問的情況下重新執行工作階段的原始提示:
3473
3474```text theme={null}
3475This session's saved conversation is no longer on disk (it ended while the background service was off, and old transcripts are cleaned up), so there is nothing to resume. `claude rm 7c5dcf5d` deletes the row; `claude respawn 7c5dcf5d` runs its original prompt again instead.
3476```
3477
3478`claude attach <id>` 列印此文字。在代理檢視中,頁腳較短,以 `ctrl+x deletes the row` 結尾。
3479
3480**該怎麼做:**
3481
3482* 執行 `claude rm <id>` 刪除列。當其中一個[保留案例](/docs/zh-TW/agent-view#what-deleting-a-session-removes)適用時,`claude rm` 保留列和 worktree,並命名原因
3483* 要再次執行工作階段的原始提示作為新對話,請執行 `claude respawn <id>`
3484
3485在 v2.1.248 之前,開啟這樣的列會重新執行工作階段的原始提示,而不是拒絕,將數週前的任務拉回前景。
3486
3487<h3 id="worktree-has-commits-that-are-not-pushed-anywhere">
3488 Worktree 有未推送到任何地方的提交
3489</h3>
3490
3491您嘗試刪除[背景工作階段](/docs/zh-TW/agent-view#what-deleting-a-session-removes),其 worktree 保持 Claude Code 無法確認在其他地方儲存的提交。Claude Code 保留 worktree 和工作階段列,而不是銷毀提交。`claude rm` 命名分支和未推送的提交,並說明如何進行:
3492
3493```text theme={null}
3494kept 7c5dcf5d — 2 unpushed commits on claude/fix-login (a1b2c3d Fix login flow, … and 1 more)
3495 worktree: /home/you/project/.claude/worktrees/fix-login
3496 push them, or discard the worktree and its commits: claude rm 7c5dcf5d --discard-unpushed a1b2c3d000000000000000000000000000000000@0123456789abcdef0123456789abcdef
3497```
3498
3499當 Claude Code 無法總結提交時,訊息改為讀取 `worktree has commits that are not pushed anywhere`。在[代理檢視](/docs/zh-TW/agent-view)中,工作階段的列顯示 `not deleted`,原因相同。
3500
3501遠端上的提交不會阻止刪除。本機複製您的 `origin` 遠端預設分支上的提交也不會,只要該分支在您的主簽出中簽出,即儲存庫目錄本身而不是 worktree。
3502
3503**該怎麼做:**
3504
3505* 要保留提交,推送 worktree 的分支,或將其合併到在主簽出中簽出的預設分支,然後再次刪除工作階段
3506* 要捨棄提交,執行訊息列印的 `claude rm <id> --discard-unpushed` 命令,或在代理檢視中的工作階段列上再次按 `Ctrl+X` 兩次。這會移除工作階段和 worktree 以及其分支、未推送的提交和任何未提交的變更。如果 worktree 自拒絕以來獲得了提交,Claude Code 再次保留它並顯示更新的狀態
3507* 當訊息說 worktree 也由另一個已完成的工作階段記錄時,再次刪除不會捨棄它:推送提交,然後再次刪除工作階段
3508
3509在 v2.1.260 之前,訊息未命名分支或提交,再次刪除被拒絕的方式相同:刪除工作階段而不推送意味著使用 `git worktree remove --force <path>` 自己移除 worktree,然後再次執行 `claude rm <id>`。
3510
3511在 v2.1.248 之前,在主簽出中簽出的預設分支不計算:您已經合併到那裡的分支仍然觸發此拒絕,直到其提交到達遠端。
3512
3513<h3 id="terminal-host-process-died">
3514 終端主機程序已死亡
3515</h3>
3516
3517每個[背景工作階段的](/docs/zh-TW/agent-view)終端在背景服務下的主機程序中執行,該程序在服務仍保持其連線時死亡,因此無法到達工作階段。
3518
3519在 Linux 和 WSL 上,背景服務每隔幾秒檢查每個主機程序,當程序已退出但其與服務的連線從未關閉時標記工作階段失敗,並在[代理檢視](/docs/zh-TW/agent-view#read-session-state)中的其列上顯示原因:
3520
3521```text theme={null}
3522terminal host process died — press Enter to restart
3523```
3524
3525如果您在檢查執行之前開啟列,頁腳顯示 `This session's terminal host process died (the conversation is saved) — press Enter to restart it`,列變為失敗。
3526
3527從殼層,`claude attach <id>` 重新啟動已標記為死主機失敗的工作階段,否則列印原因並退出:
3528
3529```text theme={null}
3530Couldn't attach to <id> — This session's terminal host process died (the conversation is saved) — run `claude attach <id>` again to restart it on a fresh host.
3531```
3532
3533無論如何對話都會儲存。
3534
3535執行[殼層命令](/docs/zh-TW/agent-view#run-a-shell-command)的列改為顯示 `terminal host process died — its output is gone; the command was not run again`,`claude attach` 列印 `This command's terminal host process died — its output is gone and the command was not run again`。Claude Code 永遠不會為您重新執行命令。
3536
3537**該怎麼做:**
3538
3539* 在代理檢視中,在失敗的列上按 `Enter`;工作階段在新主機程序上重新啟動,對話繼續
3540* 從殼層,再次執行 `claude attach <id>`。Claude Code 列印 `Session <id>'s terminal host died — restarting it on a fresh one…` 並重新開啟工作階段
3541* 您無法以這種方式重新啟動殼層命令列;再次分派命令以重新執行它
3542
3543在 v2.1.247 之前,死主機程序可能通過背景服務執行的每個活躍性檢查,因此開啟工作階段無限期地顯示 `opening… · esc to cancel`,`claude attach <id>` 等待而不報告錯誤。
3544
3545<h3 id="session-isnt-responding">
3546 工作階段沒有回應
3547</h3>
3548
3549您開啟了[背景工作階段](/docs/zh-TW/agent-view),背景服務接受了開啟,但約十秒內沒有輸出到達,因此 Claude Code 得出結論,中繼工作階段終端的程序無法傳遞輸出,並結束嘗試而不是等待。
3550
3551在代理檢視中,Claude Code 在頁腳中提供重新啟動:
931 3552
932```text theme={null}3553```text theme={null}
933API Error: 400 ... Extra inputs are not permitted ... context_management3554Press enter again to restart this session — it isn't responding (its conversation is saved and resumes).
934API Error: 400 ... Extra inputs are not permitted ... tools.0.custom.input_examples
935API Error: 400 ... Unexpected value(s) for the `anthropic-beta` header
936```3555```
937 3556
938Claude Code 發送測試版專用欄位,例如 `context_management`、`effort` 和工具 `input_examples`,以及啟用它們的 `anthropic-beta` 標頭。當閘道轉發主體但移除標頭時,API 會看到它不認識的欄位。3557從殼層,`claude attach <id>` 列印原因並退出:
3558
3559```text theme={null}
3560Couldn't attach to <id> — Session isn't responding — `claude stop <id>`, then `claude attach <id>` restarts it (the conversation is saved).
3561```
3562
3563Claude Code 永遠不會為您重新啟動執行[殼層命令](/docs/zh-TW/agent-view#run-a-shell-command)的列,因為重新啟動會再次執行命令。
939 3564
940**該怎麼做:**3565**該怎麼做:**
941 3566
942* 配置您的閘道以轉發 `anthropic-beta` 標頭。請參閱[功能傳遞](/docs/zh-TW/llm-gateway-protocol#feature-pass-through)以了解閘道必須轉發的內容。3567* 在代理檢視中,在相同列上再次按 `Enter`。Claude Code 停止無回應的程序並重新啟動工作階段,對話繼續。沒有第二次按下,什麼都不會停止
943* 作為備選方案,在啟動前設定 [`CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1`](/docs/zh-TW/env-vars)。這會停用需要測試版標頭的功能,以便請求通過無法轉發它的閘道成功。3568* 從殼層,執行 `claude stop <id>`,然後 `claude attach <id>`
3569* 對於殼層命令列,在代理檢視中按 `Ctrl+X` 或執行 `claude stop <id>` 停止它;再次分派命令以重新執行它
944 3570
945<h3 id="theres-an-issue-with-the-selected-model">3571<h3 id="session-was-stopped-while-the-respawn-was-in-flight">
946 選定的模型有問題3572 工作階段在重新生成進行中時被停止
947</h3>3573</h3>
948 3574
949配置的模型名稱未被識別,或您的帳戶缺乏對其的存取權限。從 v2.1.160 開始,尾部提示(此處以其互動形式顯示)因表面而異。3575您開啟了[背景工作階段](/docs/zh-TW/agent-view),其程序未執行,當 Claude Code 重新啟動它時,另一個 Claude Code 程序停止了它,例如在另一個終端中的 `claude stop`。Claude Code 保持工作階段停止:
950 3576
951```text theme={null}3577```text theme={null}
952There's an issue with the selected model (claude-...). It may not exist or you may not have access to it. Run /model to pick a different model.3578Session <id> was stopped while the respawn was in flight
953```3579```
954 3580
3581開啟您剛分派的工作階段,當其程序仍在啟動時,等待程序。在 v2.1.246 之前,在那一刻開啟它可能會停止它並顯示此訊息。
3582
955**該怎麼做:**3583**該怎麼做:**
956 3584
957* **互動式 CLI**:執行 `/model` 以從您帳戶可用的模型中選擇。3585* 如果您沒有停止工作階段,在代理檢視中再次開啟其列或執行 `claude respawn <id>` 重新啟動它
958* **非互動模式 (`-p`)**:使用有效的別名或 ID 傳遞 `--model`,或設定 [`ANTHROPIC_MODEL`](/docs/zh-TW/env-vars)。錯誤文字在此表面上顯示 `Run --model`。3586* 如果您自己停止了它,沒有什麼剩下要做的:工作階段保持停止
959* **Agent SDK**:錯誤文字省略提示,因為模型是以程式設計方式設定的。在 TypeScript 中設定 [`Options` 上的 `model`](/docs/zh-TW/agent-sdk/typescript#options),或在 Python 中設定 [`ClaudeAgentOptions(model=...)`](/docs/zh-TW/agent-sdk/python#claudeagentoptions),並處理結構化的 `model_not_found` 錯誤以呈現您自己的重試或模型選擇器。
960* 使用別名(例如 `sonnet` 或 `opus`)而不是完整的版本化 ID。別名解析為維護的預設值,因此不會過時。請參閱[模型配置](/docs/zh-TW/model-config)。
961* 如果 CLI 中一直出現錯誤的模型,則某處設定了過時的 ID。按[優先順序](/docs/zh-TW/model-config#setting-your-model)檢查:`--model` 標誌、`ANTHROPIC_MODEL` 環境變數,然後是 `.claude/settings.local.json` 中的 `model` 欄位、您專案的 `.claude/settings.json` 和 `~/.claude/settings.json`。移除過時的值,Claude Code 會回退到您的帳戶預設值。
962* Claude Code 將過期的 claude.ai 登入報告為[登入已過期](#login-expired),而不是此錯誤。在 v2.1.206 之前,無法再刷新的過期登入在每個模型上都失敗,出現此錯誤;如果您在較舊版本上看到此情況,請執行 `/login`。
963* 對於 Google Cloud 的 Agent Platform 部署,請參閱 [Google Cloud 的 Agent Platform 故障排除](/docs/zh-TW/google-vertex-ai#troubleshooting)。
964 3587
965<h3 id="model-is-not-a-recognized-model-id">3588<h3 id="session-agent-no-longer-available">
966 模型不是公認的模型 ID3589 工作階段代理不再可用
967</h3>3590</h3>
968 3591
969您傳遞給模型切換的模型字串不是模型別名、此 Claude Code 版本知道的模型 ID,也不是以 `claude-` 開頭的 ID。常見原因是 ID 中的拼寫錯誤、顯示名稱(例如 `Sonnet 5`,其中需要 ID `claude-sonnet-5`),或只有較新 Claude Code 版本識別的別名。Claude Code 立即拒絕切換。在 v2.1.200 之前,Claude Code 會儲存字串並在下一個請求時失敗,出現[選定的模型有問題](#theres-an-issue-with-the-selected-model)。3592您繼續了執行[自訂代理](/docs/zh-TW/sub-agents#invoke-subagents-explicitly)的工作階段,使用 `--agent` 或 `agent` 設定啟動,Claude Code 未找到該名稱的代理。它首先搜索工作階段的原始目錄,當您[信任該工作區](/docs/zh-TW/permissions#project-allow-rules-and-workspace-trust)時,然後搜索您繼續的目錄。工作階段仍然繼續,但使用預設工具,因此代理的工具限制不再適用:
970 3593
971```text theme={null}3594```text theme={null}
972Model "claud-sonnet-5" is not a recognized model id. Did you mean 'claude-sonnet-5'?3595This session was running agent 'code-reviewer', which is no longer available (no agent by that name in /home/you/project). Continuing with the default tools and system prompt — the agent's tool restrictions no longer apply. To restore it, re-create the agent, or resume with an explicit --agent <name>.
973```3596```
974 3597
975尾部提示命名最接近的匹配別名或模型 ID。當沒有足夠接近的內容時,它會改為讀取 `Run /model to see available models.`。3598訊息只命名 Claude Code 搜索的目錄,無論您喚醒[背景工作階段](/docs/zh-TW/agent-view)、執行 `/resume` 或 `claude --resume`,還是在[非互動模式](/docs/zh-TW/headless)中繼續,它都會出現在繼續的對話中,它也會進入 stderr。使用 `--input-format stream-json` 的工作階段不顯示它,因為 Agent SDK 在啟動後提供代理。
976 3599
977Claude Code 在請求切換時在本地產生此錯誤,在發出任何 API 請求之前。它適用於通過 [Agent SDK](/docs/zh-TW/agent-sdk/typescript) `setModel()` 方法或為您執行 Claude Code CLI 的應用程式(例如 [Desktop 應用程式](/docs/zh-TW/desktop))設定模型的情況。3600Claude Code 不會將回退儲存到工作階段,因此警告在每次繼續時重複,直到您採取行動。內建 `claude` 代理不觸發警告,因為回退到預設工具集對它沒有變化。在 v2.1.216 之前,Claude Code 無聲地繼續作為預設代理,查詢僅涵蓋您繼續的目錄,因此專案範圍的代理在從另一個目錄繼續時丟失。
978 3601
979**該怎麼做:**3602**該怎麼做:**
980 3603
981* 執行不帶引數的 `/model` 以開啟選擇器並從您帳戶可用的模型中選擇,然後傳遞那裡顯示的別名或 ID3604* 在工作階段的專案中的 `.claude/agents/<name>.md` 或個人代理的 `~/.claude/agents/<name>.md` 重新建立代理檔案,然後再次繼續
982* 如果您使用了較新 Claude Code 版本支援的別名,請執行 `claude update`。以 `claude-` 開頭的完整 ID 即使模型比您的 Claude Code 版本更新,也會通過此檢查,因此不需要升級。3605* 或使用 `--agent <name>` 繼續,命名確實存在的代理,以改為作為該代理執行工作階段
983* v2.1.200 之前儲存的模型不會被此檢查修復。如果過時的值一直出現,請從[選定的模型有問題](#theres-an-issue-with-the-selected-model)下列出的位置移除它。3606* 如果代理是專案範圍的,您尚未信任工作階段的原始目錄,請在那裡執行 Claude Code 一次,接受信任對話,然後再次繼續
984* 檢查僅在 Anthropic API 上執行。在 Amazon Bedrock、Google Cloud 的 Agent Platform、Microsoft Foundry、[AWS 上的 Claude Platform](/docs/zh-TW/claude-platform-on-aws) 和 [LLM 閘道](/docs/zh-TW/llm-gateway)後面或自訂 `ANTHROPIC_BASE_URL`,您的提供者或閘道定義模型名稱,因此 Claude Code 接受任何字串並將其傳遞。
985 3607
986<h3 id="claude-opus-is-not-available-with-the-claude-pro-plan">3608<h3 id="claude_code_process_wrapper-launcher-errors">
987 Claude Opus 不適用於 Claude Pro 方案3609 CLAUDE\_CODE\_PROCESS\_WRAPPER 啟動器錯誤
988</h3>3610</h3>
989 3611
990您的有效訂閱方案不包括您選擇的模型。3612[`CLAUDE_CODE_PROCESS_WRAPPER`](/docs/zh-TW/corporate-launcher)已設定,其值無法使用,因此 Claude Code 拒絕啟動受影響的程序,而不是在沒有啟動器的情況下執行它。配置問題報告為以變數名稱開頭並說明原因的訊息,例如:
991 3613
992```text theme={null}3614```text theme={null}
993Claude Opus is not available with the Claude Pro plan · Select a different model in /model3615CLAUDE_CODE_PROCESS_WRAPPER: launcher `/opt/corp/launcher` is not an executable regular file
994```3616```
995 3617
3618啟動但在不用 Claude Code 替換自己的情況下退出的啟動器會使其啟動的工作階段失敗,工作階段在代理檢視中的列報告啟動器 `must exec, not daemonize`,後跟啟動器列印的任何內容。無法啟動或到達背景服務的工作階段因啟動器報告啟動器問題作為 `Couldn't reach the background service (...)` 內的原因。
3619
996**該怎麼做:**3620**該怎麼做:**
997 3621
998* 執行 `/model` 並選擇您的方案包括的模型3622* 將變數設定為以呼叫 `exec "$@"` 結尾的可執行檔的絕對路徑。有關完整合約,請參閱[啟動器合約](/docs/zh-TW/corporate-launcher#the-launcher-contract)
999* 如果您最近升級了方案但仍然看到此訊息,請執行 `/logout` 然後 `/login`。儲存的令牌反映您登入時的方案,因此在現有工作階段中在網路上升級不會生效,直到您重新驗證。3623* 檢查 `/status`,其在 Self-exec 項中顯示已解析的啟動命令,並在執行中的背景服務不符合時警告,或從殼層執行 `claude daemon status`
1000* 請參閱 [claude.com/pricing](https://claude.com/pricing) 以了解每個方案包括哪些模型3624* 在[設定](/docs/zh-TW/corporate-launcher#set-up-the-launcher)的 `env` 區塊中修復值後,使用 `claude daemon stop --any` 重新啟動背景服務,以便下次分派啟動包裝的服務
1001 3625
1002<h3 id="model-is-restricted-by-your-organizations-settings">3626<h3 id="eunknown-when-starting-a-background-session">
1003 模型受您組織的設定限制3627 啟動背景工作階段時 EUNKNOWN
1004</h3>3628</h3>
1005 3629
1006您的組織管理員已在 claude.ai 管理控制台中停用此模型,或它被託管設定中的 [`availableModels`](/docs/zh-TW/model-config#restrict-model-selection) 允許清單排除。當使用 `--model`、`ANTHROPIC_MODEL` 或 `model` 設定設定受限制的模型時,Claude Code 會替換為允許的模型並繼續。為受限制的模型鍵入 `/model <name>` 會被拒絕,顯示 `Run /model to choose a different model.`,工作階段保持其目前模型。3630Windows 拒絕使用沒有標準名稱的錯誤代碼啟動程式,因此失敗表現為 `EUNKNOWN`。通常的觸發器是軟體限制原則,例如群組原則或 AppLocker,阻止正在啟動的程式。當您使用 `/background` 或 `claude --bg` 啟動[背景工作階段](/docs/zh-TW/agent-view)時,錯誤出現:
1007 3631
1008```text theme={null}3632```text theme={null}
1009Model "claude-opus-4-8" is restricted by your organization's settings. Using claude-sonnet-4-6 instead.3633Couldn't reach the background service (spawn background service: EUNKNOWN: unknown error, uv_spawn) — run 'claude daemon status'
1010```3634```
1011 3635
1012Claude Code 將模型系列別名(`opus`、`sonnet`、`haiku` 或 `fable` 之一)視為對該系列的請求,而不是對其最新版本的請求。在 Anthropic API 和 [AWS 上的 Claude Platform](/docs/zh-TW/claude-platform-on-aws) 上,受限制的系列別名解析為您的組織和 `availableModels` 允許清單允許的系列的最新版本,替換通知命名該版本。Claude Code 僅在系列的每個版本都受限制時才拒絕 `/model <alias>`。在 v2.1.205 之前,系列別名是根據其最新版本單獨替換或拒絕的,即使同一系列的較舊版本被允許。3636在某些帳戶上,訊息在 `daemon` 位置說 `background service`。
3637
3638在 npm 安裝上,在 `npm install -g @anthropic-ai/claude-code` 替換二進位檔案時出現的 `EUNKNOWN` 與[重新安裝期間的 `EACCES`](#eacces-when-starting-a-background-session) 有相同的原因,並在您在安裝完成後重試時清除。
3639
3640Claude Code 透過 PowerShell 啟動背景服務,以便服務在關閉終端時存活,在安裝時使用 PowerShell 7,否則使用 Windows PowerShell 5.1。當兩個 PowerShell 都無法執行時,Claude Code 改為直接啟動服務,因此只阻止 PowerShell 的原則不會導致此錯誤。如果您在沒有 npm 安裝執行時看到它,原則會阻止 Claude Code 可執行檔本身。
3641
3642在 v2.1.212 之前,Claude Code 僅使用 Windows PowerShell 5.1 啟動服務,因此任何群組原則阻止 PowerShell 5.1 的機器失敗,訊息為 `Couldn't start the session — EUNKNOWN: unknown error, uv_spawn`,即使安裝了 PowerShell 7。
1013 3643
1014**該怎麼做:**3644**該怎麼做:**
1015 3645
1016* 執行 `/model` 以從您的組織允許的模型中選擇。受限制的模型在選擇器中隱藏。3646* 如果訊息讀取 `Couldn't start the session`,升級到 v2.1.212 或更新版本。在較早的版本上,您也可以在單獨的終端中首先執行 `claude daemon run`,然後再次啟動背景工作階段。該命令在終端的前景中執行背景服務,因此服務僅在該終端保持開啟時持續。
1017* 如果受限制的模型是在 `--model`、`ANTHROPIC_MODEL` 或設定檔案的 `model` 欄位中設定的,請移除或更新該值,以便通知不會在每次啟動時重複出現3647* 如果 npm 安裝正在替換二進位檔案,等待它完成,然後再次啟動背景工作階段
1018* 如果您需要存取受限制的模型,請要求您的組織管理員啟用它。請參閱[組織模型限制](/docs/zh-TW/model-config#organization-model-restrictions)。3648* 如果錯誤在 v2.1.212 或更新版本上出現,沒有 npm 安裝執行,請要求您的 Windows 管理員在限制原則中允許 Claude Code 可執行檔
3649* 如果關閉終端時背景服務停止,Claude Code 在沒有 PowerShell 的情況下啟動它。安裝 PowerShell 7,或要求您的管理員解除阻止 PowerShell,以便服務可以超越終端。
1019 3650
1020<h3 id="thinking-type-enabled-is-not-supported-for-this-model">3651<h3 id="eacces-when-starting-a-background-session">
1021 此模型不支援 thinking.type.enabled3652 啟動背景工作階段時 EACCES
1022</h3>3653</h3>
1023 3654
1024您的 Claude Code 版本比 Sonnet 5、Opus 4.8 或 Opus 4.7 的最低版本更舊。CLI 發送了模型不再接受的思考配置。3655Claude Code 無法執行其自己的二進位檔案來啟動[背景服務](/docs/zh-TW/agent-view#the-supervisor-process),該服務託管背景工作階段。在 npm 安裝上,這通常意味著 `npm install -g @anthropic-ai/claude-code` 在那一刻替換二進位檔案,無論您執行它還是[自動更新程式](/docs/zh-TW/setup#auto-updates)執行。當您從[代理檢視](/docs/zh-TW/agent-view)開啟工作階段時,錯誤出現:
1025 3656
1026```text theme={null}3657```text theme={null}
1027API Error: 400 ... "thinking.type.enabled" is not supported for this model. Use "thinking.type.adaptive" and "output_config.effort" to control thinking behavior.3658Couldn't start the background service — spawn background service: EACCES: permission denied, posix_spawn '/usr/local/lib/node_modules/@anthropic-ai/claude-code/bin/claude'
3659```
3660
3661當您使用 `/background` 或 `claude --bg` 啟動工作階段時,相同的原因出現在 `Couldn't reach the background service (...)` 內。在相同重新安裝視窗期間,錯誤可能命名另一個代碼,例如 `ENOENT` 或 `ENOEXEC`,或 Windows 上的 `EUNKNOWN` 或 `EPERM`;跨重試持續的 `EUNKNOWN` 有[不同的原因](#eunknown-when-starting-a-background-session)。
3662
3663在 npm 安裝上,Claude Code 等待重新安裝完成並自動重試:最多十秒,以及在 npm 安裝 Claude Code 在機器上明顯仍在執行時最多兩分鐘,涵蓋另一個 Claude Code 程序下載更新。當安裝超過該等待時,失敗命名更新而不是裸錯誤代碼:
3664
3665```text theme={null}
3666Claude Code is being updated by npm on this machine (still not runnable after 2 min, EACCES) — try again when the update finishes
1028```3667```
1029 3668
3669在 v2.1.257 之前,等待在每種情況下停止在十秒,因此此錯誤在另一個 Claude Code 程序仍在下載更新時出現。在 v2.1.246 之前,Claude Code 立即失敗,沒有等待。
3670
1030**該怎麼做:**3671**該怎麼做:**
1031 3672
1032* 執行 `claude update` 並重新啟動 Claude Code。Opus 4.7 需要 v2.1.111 或更新版本。Opus 4.8 需要 v2.1.154 或更新版本。Sonnet 5 需要 v2.1.197 或更新版本3673* 等待幾秒,然後開啟工作階段或再次分派。當訊息說 Claude Code 正在更新時,在更新完成後重試。
1033* 如果您無法升級,請執行 `/model` 並改為選擇 Opus 4.6 或 Sonnet 4.63674* 如果錯誤在沒有 npm 安裝執行時持續,您的使用者無法執行已安裝的二進位檔案。檢查其權限及其目錄的,或重新安裝 Claude Code。
1034* 如果您在 [Agent SDK](/docs/zh-TW/agent-sdk/overview) 中遇到此問題,請改為升級 SDK 套件。Opus 4.8 需要 TypeScript SDK v0.3.154 或更新版本和 Python SDK v0.2.88 或更新版本。Sonnet 5 需要 TypeScript SDK v0.3.197 或更新版本
1035 3675
1036<h3 id="thinking-budget-exceeds-output-limit">3676<h3 id="background-service-exited-before-it-became-reachable">
1037 思考預算超過輸出限制3677 背景服務在變得可到達之前退出
1038</h3>3678</h3>
1039 3679
1040配置的擴展思考預算超過最大回應長度,因此沒有空間留給實際答案。3680Claude Code 啟動為[背景服務](/docs/zh-TW/agent-view#the-supervisor-process)的程序在變得可到達之前退出,因此 Claude Code 無法開啟您的工作階段。當服務在退出前列印錯誤時,括號中的原因給出退出代碼或訊號以及服務列印的第一行,其命名停止它的內容:
1041 3681
1042```text theme={null}3682```text theme={null}
1043API Error: 400 ... max_tokens must be greater than thinking.budget_tokens3683Couldn't reach the background service (background service exited before it became reachable (exit code N): <the service's first error line>) — run 'claude daemon status'
1044```3684```
1045 3685
1046Claude Code 在 Anthropic API 上自動調整這些值。當 [`MAX_THINKING_TOKENS`](/docs/zh-TW/env-vars) 設定高於提供者的輸出限制時,或當計畫模式提高思考預算時,您通常會在 Amazon Bedrock 或 Google Cloud 的 Agent Platform 上看到此錯誤。3686當您從[代理檢視](/docs/zh-TW/agent-view)開啟工作階段時,相同的原因跟隨 `Couldn't start the background service —`。當服務在退出前未列印任何內容時,訊息改為說 `nothing on stderr`。
3687
3688Claude Code 使用服務的錯誤行報告失敗。在 v2.1.246 之前,失敗僅在 45 秒等待後表現,為 `background service did not become reachable within 45s`,沒有服務的錯誤行。
3689
3690兩個引用的原因有已知的原因:
3691
3692* `Error: claude native binary not installed.`:npm 安裝在那一刻替換 Claude Code 二進位檔案,因此服務執行 npm 的佔位符。在安裝完成後重試;如果沒有安裝執行時行持續,[完成 npm 安裝](/docs/zh-TW/troubleshoot-install#native-binary-not-found-after-npm-install)。在 v2.1.257 之前,macOS npm 自我更新在安裝視窗期間在每次啟動時產生此失敗。
3693* Windows 上每次啟動時 `nothing on stderr` 和退出代碼 1:`daemon.lock` 命名 Claude Code 既無法訊號也無法證明已消失的程序,因此每個新服務得出結論另一個保持鎖定並退出。Claude Code 可以證明其寫入器已消失的鎖定會自動替換,不會產生此失敗。當失敗在每次啟動時重複時,刪除 `~/.claude/daemon.lock`,然後開啟工作階段或再次分派。在 v2.1.257 之前,這樣的鎖定阻止每次啟動,直到您刪除檔案。
1047 3694
1048**該怎麼做:**3695**該怎麼做:**
1049 3696
1050* 降低 `MAX_THINKING_TOKENS`,或將 [`CLAUDE_CODE_MAX_OUTPUT_TOKENS`](/docs/zh-TW/env-vars) 提高到思考預算之上3697* 如果訊息引用一行,修復它命名的內容,然後開啟工作階段或再次分派。下次嘗試再次啟動服務
1051* 請參閱[擴展思考](/docs/zh-TW/model-config#extended-thinking)以了解預算如何與輸出長度互動3698* 執行 `claude daemon status` 檢查現在是否有服務執行
1052 3699
1053<h3 id="tool-use-or-thinking-block-mismatch">3700<h3 id="working-directory-no-longer-exists-when-starting-a-background-session">
1054 工具使用或思考區塊不匹配3701 啟動背景工作階段時工作目錄不再存在
1055</h3>3702</h3>
1056 3703
1057對話歷史以不一致的狀態到達 API,通常是在工具呼叫被中斷或回合在中途被編輯後。3704您嘗試在不再存在的目錄中啟動[背景工作階段](/docs/zh-TW/agent-view)。當您從代理檢視分派或在您工作的目錄被刪除或移動後執行 `/background` 時,會發生這種情況。當您附加到或重新啟動其程序已退出且其目錄已消失的工作階段時,也會發生這種情況,因為新程序會在相同目錄中啟動。Claude Code 不啟動工作階段,訊息命名遺漏的目錄:
1058 3705
1059```text theme={null}3706```text theme={null}
1060API Error: 400 due to tool use concurrency issues. Run /rewind to recover the conversation.3707Couldn't start a background session (working directory no longer exists or is not accessible: /tmp/demo)
1061API Error: 400 ... unexpected `tool_use_id` found in `tool_result` blocks
1062API Error: 400 ... thinking blocks ... cannot be modified
1063```3708```
1064 3709
1065所有三個變體都意味著同一件事:歷史中 `tool_use`、`tool_result` 和 `thinking` 區塊的序列不再與 API 期望的相符。3710在 v2.1.257 之前,工作階段似乎啟動,然後在代理檢視中顯示為失敗列,原因相同。
1066 3711
1067**該怎麼做:**3712**該怎麼做:**
1068 3713
1069* 如果您使用的是 Opus 4.7 或 Opus 4.8,請先執行 `claude update`。v2.1.156 之前的版本可能在正常工具使用期間觸發此錯誤,而 `/rewind` 不會清除它。3714* 重新建立訊息命名的目錄,或從存在的目錄分派,然後再試一次
1070* 執行 `/rewind` 或按 Esc 兩次,以回溯到損壞回合之前的檢查點並從那裡繼續。請參閱[檢查點](/docs/zh-TW/checkpointing)以了解如何建立和恢復檢查點。
1071 3715
1072<h3 id="usage-policy-refusal">3716<h2 id="wrapper-and-ide-errors">
1073 使用政策拒絕3717 包裝程式和 IDE 錯誤
3718</h2>
3719
3720這些錯誤來自啟動 Claude Code 的程式,例如 IDE 擴充功能或 [Agent SDK](/docs/zh-TW/agent-sdk/overview) 應用程式,而不是來自 Claude Code 本身。
3721
3722<h3 id="claude-code-process-exited-with-code-n">
3723 Claude Code 程序以代碼 N 結束
1074</h3>3724</h3>
1075 3725
1076API 拒絕回應,因為對話中的內容觸發了[使用政策](https://www.anthropic.com/legal/aup)檢查。訊息包括您可以引用給支援的請求 ID,如果您認為拒絕不正確。3726底層 `claude` 程序以非零代碼結束。結束代碼本身不會說明失敗的原因:真正的錯誤在於程序自己的輸出,包裝程式會在捕獲時附加該輸出,否則將其保留在日誌中。
1077 3727
1078```text theme={null}3728```text theme={null}
1079API Error: Claude Code is unable to respond to this request, which appears to violate our Usage Policy (https://www.anthropic.com/legal/aup). Please double press esc to edit your last message or start a new session for Claude Code to assist with a different task.3729Error: Claude Code process exited with code 1
1080```3730```
1081 3731
1082檢查評估完整對話,而不僅是您的最新提示,因此在同一工作階段中發送新訊息通常會重新觸發相同的拒絕。在使用 `--continue` 或 `--resume` 退出並重新開啟工作階段後也是如此,因為磁碟上的文字記錄仍然包含觸發內容。在 [Amazon Bedrock](/docs/zh-TW/amazon-bedrock)、[Google Cloud 的 Agent Platform](/docs/zh-TW/google-vertex-ai) 和 [Microsoft Foundry](/docs/zh-TW/microsoft-foundry) 上,此訊息也涵蓋模型的安全措施標記為網路安全主題的請求。請參閱[安全措施標記了網路安全主題](#safety-measures-flagged-a-cybersecurity-topic)。
1083
1084**該怎麼做:**3732**該怎麼做:**
1085 3733
1086* 按 Esc 兩次或執行 `/rewind` 以回溯到觸發拒絕的回合之前的檢查點,然後重新表述或採取不同的方法。請參閱[檢查點](/docs/zh-TW/checkpointing)。3734* 在 VS Code 中,按照錯誤顯示的**檢視輸出日誌**連結查看底層失敗
1087* 如果您無法識別哪個回合導致了它,請執行 `/clear` 以在同一專案中開始新的對話。您之前的對話會保留在磁碟上,並在 `/resume` 中保持可用。3735* 在 Agent SDK 應用程式中,在訊息迴圈周圍捕獲錯誤。[CLI 程序結束](/docs/zh-TW/agent-sdk/troubleshooting#cli-process-exit)下的項目涵蓋了您的程式碼在每個 SDK 語言中接收的內容。
1088* 在[非互動模式](/docs/zh-TW/headless)(`-p`) 中,其中無法進行倒帶,請在沒有 `--continue` 的新工作階段中使用重新表述的提示重試。政策檢查因模型而異,因此使用 `--model` 切換到不同的模型也可能在某些情況下解決拒絕。3736* 在終端機中的同一專案中執行 `claude`。失敗通常會在那裡重現,並顯示其真實錯誤訊息,您可以在此頁面上查詢。
3737* 在終端機中執行 `claude doctor` 以檢查安裝和設定
1089 3738
1090<h3 id="safety-measures-flagged-a-cybersecurity-topic">3739<h3 id="could-not-locate-the-claude-cli-on-path">
1091 安全措施標記了網路安全主題3740 無法在 PATH 上找到 Claude CLI
1092</h3>3741</h3>
1093 3742
1094模型的安全措施將對話中的內容標記為網路安全主題。訊息命名標記請求的模型:3743當您在整合終端機中開啟 Claude Code、終端機的殼層是 PowerShell,且擴充功能無法在 PATH 上找到已安裝的 `claude` 可執行檔時,[VS Code 擴充功能](/docs/zh-TW/vs-code)會在 Windows 上顯示此錯誤。擴充功能拒絕啟動 Claude Code,直到它在 PATH 上找到已安裝的 `claude`。
1095 3744
1096```text theme={null}3745```text theme={null}
1097API Error: Opus 4.8 has safety measures that flagged this message for a cybersecurity topic. To learn about the Cyber Verification Program and apply for access, visit our help center: https://support.claude.com/en/articles/14604842-real-time-cyber-safeguards-on-claude.3746Failed to run Claude Code: Error: Could not locate the Claude CLI on PATH. Launching by name in a PowerShell terminal would run a 'claude' from the open folder instead of the installed CLI, so the launch was blocked. Make sure the Claude CLI's install directory is on your system PATH (not only your PowerShell profile), then restart VS Code and try again. VS Code reads PATH when it starts, so PATH changes take effect only after a restart.
3747```
3748
3749**該怎麼做:**
3750
3751* 在 VS Code 外開啟新的 PowerShell 視窗並執行 `where.exe claude`。如果它沒有列印路徑,CLI 不在您的 PATH 上:按照[驗證您的 PATH](/docs/zh-TW/troubleshoot-install#verify-your-path)新增其安裝目錄。如果它列印了路徑,該項目來自您的 PowerShell 設定檔或來自 VS Code 尚未取得的 PATH 變更;接下來的兩個步驟涵蓋了這些情況。
3752* 將 PATH 項目設定為使用者或系統環境變數,而不是在您的 PowerShell 設定檔中。擴充功能不執行您的設定檔,因此只存在於那裡的 PATH 編輯永遠無法到達它。
3753* 變更 PATH 後重新啟動 VS Code。擴充功能檢查 VS Code 在啟動時捕獲的 PATH,因此 PATH 變更只有在重新啟動後才會生效。
3754
3755<h2 id="rewind-warnings-and-errors">
3756 Rewind 警告和錯誤
3757</h2>
3758
3759這些訊息來自 [`/rewind`](/docs/zh-TW/checkpointing) 程式碼還原。`Restored the code, but skipped N files` 是一個警告,表示 Claude Code 跳過了某些路徑。`No files were restored` 是一個錯誤,表示它沒有還原任何內容。
3760
3761<h3 id="restored-the-code-but-skipped-files">
3762 Restored the code, but skipped files
3763</h3>
1098 3764
1099If you were not engaging in a cybersecurity topic, please send feedback via /feedback.3765`/rewind` 程式碼還原跳過了一個或多個追蹤的路徑,而不是透過它們進行寫入或刪除。Claude Code 在以下情況下會跳過路徑:
3766
3767* 它是或已成為符號連結、硬連結或其他非一般檔案
3768* 其目錄自檢查點以來已變更
3769* 其備份無法安全讀取
3770
3771跳過的路徑保留其目前的內容。在 v2.1.216 之前,`/rewind` 會透過追蹤路徑上的連結進行寫入和刪除,並且不會報告部分還原。
3772
3773```text theme={null}
3774Restored the code, but skipped 2 files: the tracked path is (or became) a link or other non-regular file, its directory changed since the checkpoint, or its backup could not be safely read. Skipped files were left untouched — run with --debug for the paths.
1100```3775```
1101 3776
1102訊息連結到[網路安全驗證計畫](https://support.claude.com/en/articles/14604842-real-time-cyber-safeguards-on-claude),該計畫為合法網路安全工作授予存取權限。保護措施本身是伺服器端的,早於 v2.1.203;此版本僅更改了訊息的措辭和它連結到的頁面。3777**該怎麼做:**
3778
3779* 識別哪些檔案被跳過,以便您可以使用下面的步驟處理每個檔案。訊息只提供計數;位於 `~/.claude/debug/<session-id>.txt` 的偵錯日誌會在還原執行時列出每個跳過的路徑,因此在下次還原之前使用 `/debug` 開啟偵錯日誌。在 macOS 或 Linux 上,您可以改為直接找到連結:`find . -type l` 用於符號連結,`find . -type f -links +1` 用於硬連結檔案。
3780* 如果跳過的檔案是您有意建立的連結,例如由 dotfile 管理器管理的設定檔或由 pnpm 等工具硬連結的檔案,rewind 會保留其內容不變。若要復原工作階段對其所做的變更,請要求 Claude 反轉編輯或自行編輯檔案
3781* 如果您沒有建立連結,請在信任其內容之前檢查路徑:某些東西在檢查點之後替換了該檔案
3782
3783<h3 id="no-files-were-restored">
3784 No files were restored
3785</h3>
1103 3786
1104您看到的內容取決於您的提供者和模式:3787當您使用 [`/rewind`](/docs/zh-TW/checkpointing) 還原程式碼,且無法還原該檢查點中的任何檔案時,Claude Code 會顯示此訊息。對於每個檔案,Claude Code 在編輯前儲存的備份遺失,或 Claude Code 無法寫入或刪除該檔案。
1105 3788
1106* 在 [Amazon Bedrock](/docs/zh-TW/amazon-bedrock)、[Google Cloud 的 Agent Platform](/docs/zh-TW/google-vertex-ai) 和 [Microsoft Foundry](/docs/zh-TW/microsoft-foundry) 上,網路安全標記會產生[使用政策拒絕](#usage-policy-refusal)訊息。3789```text theme={null}
1107* [非互動模式](/docs/zh-TW/headless)省略 `/feedback` 句子。3790Failed to restore the code:
3791No files were restored: 1 file failed (backup missing, or the file could not be updated)
3792```
1108 3793
1109在 v2.1.203 之前,訊息讀取 `<model>'s safeguards flagged this message for a cybersecurity topic. If your work requires this access, you can apply for an exemption:` 後跟豁免表單連結。3794Claude Code 在[保留掃描](/docs/zh-TW/claude-directory#cleaned-up-automatically)中刪除工作階段的備份,預設情況下約在工作階段最後一次儲存後 30 天。如果您在之後恢復工作階段,`/rewind` 仍會列出其檢查點,但還原到其中一個可能會因此錯誤而失敗。如果訊息還說 `N paths were skipped for link safety`,請參閱[Restored the code, but skipped files](#restored-the-code-but-skipped-files) 以了解這些路徑。
1110 3795
1111**該怎麼做:**3796**該怎麼做:**
1112 3797
1113* 如果您的工作需要此內容,請通過[網路安全驗證計畫](https://support.claude.com/en/articles/14604842-real-time-cyber-safeguards-on-claude)申請存取權限3798* 以其他方式復原變更:要求 Claude 反轉其編輯,或從版本控制還原檔案。當備份消失時,再次執行 `/rewind` 會以相同方式失敗。
1114* 如果您的請求不是關於網路安全主題,請執行 `/feedback` 以報告誤報3799* 如果 Claude Code 無法寫入或刪除檔案,請修復阻止寫入的問題,例如檔案權限,然後再次執行 `/rewind`。
1115* 若要在同一工作階段中繼續工作,請按 Esc 兩次或執行 `/rewind` 以回溯到觸發標記的回合之前的檢查點,然後採取不同的方法。請參閱[檢查點](/docs/zh-TW/checkpointing)。3800* 若要在未來的工作階段中保留備份更長時間,請提高 [`cleanupPeriodDays`](/docs/zh-TW/settings-reference#cleanupperioddays)。
1116 3801
1117<h2 id="installation-errors">3802在 v2.1.260 之前,Claude Code 會無聲地跳過備份遺失的檔案,還原似乎成功。
1118 安裝錯誤3803
3804<h2 id="session-saving-warnings">
3805 工作階段儲存警告
1119</h2>3806</h2>
1120 3807
1121這些錯誤會在安裝或更新 Claude Code 時出現,來自 [安裝指令碼](/docs/zh-TW/setup#install-claude-code)、`claude install` 或 `claude update`。如需 `command not found`、PATH、權限和設定期間的 TLS 問題,請參閱 [疑難排解安裝和登入](/docs/zh-TW/troubleshoot-install)。3808Claude Code 在輸入框下方的持續行上顯示這些警告,當它未儲存您的工作階段文字記錄時。無論哪種方式,工作階段都會繼續運作;警告告訴您工作階段稍後可能會在 [`--resume`](/docs/zh-TW/sessions) 中遺失。
1122 3809
1123<h3 id="installation-was-killed-before-it-could-finish">3810<h3 id="transcript-writes-are-failing">
1124 安裝在完成前被中止3811 文字記錄寫入失敗
1125</h3>3812</h3>
1126 3813
1127當 `claude install` 步驟被信號終止時,安裝指令碼會報告。在 Linux 上,結束代碼 137 表示程序收到 SIGKILL,在低記憶體主機上,通常是核心記憶體不足 (OOM) 殺手。指令碼會列印此說明並以代碼 137 結束:3814Claude Code 在您工作時將文字記錄儲存到磁碟,其對[文字記錄檔案](/docs/zh-TW/sessions#where-transcripts-are-stored)的寫入失敗。該訊息以基礎錯誤代碼命名原因,例如磁碟已滿:
1128 3815
1129```text theme={null}3816```text theme={null}
1130Installation was killed before it could finish (exit code 137). This usually means the system ran out of memory.3817Transcript writes are failing (disk full — ENOSPC) · recent messages may not be saved for resume
1131Claude Code needs roughly 512MB of free memory to install. Free up memory, then run this script again.
1132```3818```
1133 3819
1134對於任何其他致命信號,以及 macOS 上的結束代碼 137,指令碼會列印 `Installation was killed before it could finish (exit code <N>)`,其中包含實際結束代碼,並省略記憶體不足的說明。該訊息來自 macOS 和 Linux 使用的安裝指令碼,也涵蓋 WSL 內的安裝;原生 Windows 安裝指令碼永遠不會列印它。在 v2.1.200 之前,指令碼只以 shell 的裸 `Killed` 行結束。3820警告根據錯誤在不同時間點出現:
3821
3822* 在不會自行清除的條件首次失敗時:磁碟已滿、超過磁碟配額、檔案系統唯讀、路徑超過檔案系統長度限制,或在 macOS 和 Linux 上,權限錯誤
3823* 在至少跨越一分鐘的重複失敗後,包括 Windows 上的權限錯誤,其中防毒軟體掃描可能會導致單次寫入失敗,然後在重試時成功
3824
3825在 v2.1.217 之前,Claude Code 會在沒有警告的情況下放棄失敗的寫入,稍後 `--resume` 遺失最近訊息是第一個跡象。
1135 3826
1136**該怎麼做:**3827**該怎麼做:**
1137 3828
1138* 停止其他程序以釋放記憶體,然後重新執行安裝程式3829* 修復錯誤代碼命名的條件:為 `ENOSPC` 釋放磁碟空間;為 `EDQUOT` 提高或清除配額;為 `EACCES`、`EPERM` 或 `EROFS` 恢復文字記錄位置的寫入存取
1139* 新增交換空間或移至更大的執行個體。請參閱 [在低記憶體 Linux 伺服器上安裝被中止](/docs/zh-TW/troubleshoot-install#install-killed-on-low-memory-linux-servers) 以取得交換檔案命令。3830* 警告在下一次成功寫入時自動清除;不需要重新啟動
3831* 在警告顯示時傳送的訊息稍後恢復工作階段時可能仍會遺失
1140 3832
1141<h3 id="the-connection-dropped-while-downloading-the-update">3833<h3 id="transcript-saving-is-off-skip-prompt-history">
1142 下載更新時連線中斷3834 因為設定了 CLAUDE\_CODE\_SKIP\_PROMPT\_HISTORY 所以文字記錄儲存已關閉
1143</h3>3835</h3>
1144 3836
1145當 `claude install`、`claude update` 或 [自動更新程式](/docs/zh-TW/setup#auto-updates) 正在擷取 Claude Code 二進位檔案時,與下載伺服器的連線已關閉,且重試未能恢復。當連線中斷、傳輸停滯或下載的檔案未通過校驗和時,Claude Code 會重試下載,最多嘗試三次。已完成的 HTTP 錯誤(例如 404)不會重試,因為伺服器已經回應。在 v2.1.202 之前,單一連線中斷會立即導致下載失敗,並顯示裸錯誤 `aborted`,而不是重試。3837此工作階段啟動時設定了 [`CLAUDE_CODE_SKIP_PROMPT_HISTORY`](/docs/zh-TW/env-vars),因此 Claude Code 不會為其寫入文字記錄或提示歷史記錄:
1146 3838
1147```text theme={null}3839```text theme={null}
1148The connection dropped while downloading the update (attempt 3/3: aborted). Check your network — proxies sometimes cut off large downloads.3840Transcript saving is off — CLAUDE_CODE_SKIP_PROMPT_HISTORY is set · --resume will not find this session; if unintended, unset it and restart
1149```3841```
1150 3842
1151括號中的文字命名失敗的嘗試和基礎網路錯誤。`claude update` 在 stderr 上以 `Error: Failed to install native update` 開頭該訊息。3843該變數是針對暫時性指令碼工作階段的有意選擇退出,但它也可以透過殼層設定檔、包裝指令碼或匯出它的父程序到達工作階段。
3844
3845**該怎麼做:**
1152 3846
1153保持連線但在 10 分鐘內未完成的下載會失敗,並顯示 `Download timed out: exceeded the total deadline`。Claude Code 不會重試逾時的下載,因為連線速度太慢而無法在期限內完成,在立即重試時也不會完成。下面的步驟適用於兩個訊息。在 v2.1.205 之前,相同的 10 分鐘期限被報告為 HTTP 用戶端的通用 `timeout of 600000ms exceeded`。3847* 如果您有意設定該變數,不需要採取任何行動;該通知確認工作階段不會出現在 `--resume`、`--continue` 或向上箭頭歷史記錄中
3848* 如果您沒有,請從啟動 `claude` 的殼層或指令碼中移除該變數,然後啟動新工作階段。目前工作階段的訊息不會被追溯儲存。
1154 3849
1155通常的原因是代理或閘道在傳輸完成前關閉長傳輸。Claude Code 二進位檔案是大型下載,因此永遠不會影響正常 API 流量的代理連線限制仍然可能中斷它。3850<h3 id="transcript-saving-is-off-child-session-marker">
3851 因為繼承了 CLAUDE\_CODE\_CHILD\_SESSION 標記所以文字記錄儲存已關閉
3852</h3>
3853
3854Claude Code 在它產生的子程序中設定 [`CLAUDE_CODE_CHILD_SESSION`](/docs/zh-TW/env-vars),並將繼承它的互動式工作階段視為巢狀:Claude Code 不會為其儲存文字記錄,因此 Claude 本身啟動的工作階段不會填滿您的 `--resume` 清單。此通知表示您目前的工作階段繼承了該標記:
3855
3856```text theme={null}
3857Transcript saving is off — inherited CLAUDE_CODE_CHILD_SESSION marker · restart with CLAUDE_CODE_FORCE_SESSION_PERSISTENCE=1 to keep future transcripts
3858```
3859
3860當您從另一個 Claude Code 工作階段內執行 `claude` 時,該通知是預期的;當標記透過長期存在的中介(例如終端機、`screen` 工作階段或 Claude Code 工作階段原本啟動的啟動器)洩漏時,它會發出誤分類的訊號。
3861
3862在 tmux 內,Claude Code 會偵測透過 tmux 伺服器全域環境到達的標記,並繼續儲存,因此該通知不會出現在該情況下。
1156 3863
1157**該怎麼做:**3864**該怎麼做:**
1158 3865
1159* 再次執行 `claude update`。在網路狀況良好的情況下,下載通常在下次執行時成功。對於逾時訊息,請從更快或限制較少的網路重新執行。3866* 如果您有意從另一個 Claude Code 工作階段內啟動此工作階段,不需要採取任何行動
1160* 如果您的網路需要代理,請在執行安裝程式或 `claude update` 之前設定 `HTTPS_PROXY`。請參閱 [檢查網路連線](/docs/zh-TW/troubleshoot-install#check-network-connectivity)。3867* 如果這是頂層工作階段,請結束並使用設定的 [`CLAUDE_CODE_FORCE_SESSION_PERSISTENCE=1`](/docs/zh-TW/env-vars) 重新啟動。儲存從重新啟動時開始套用,因此在此之前傳送的訊息不會被儲存。
1161* 如果公司代理持續關閉傳輸,請要求您的網路團隊允許從 `downloads.claude.ai` 進行完整下載。請參閱 [網路存取需求](/docs/zh-TW/network-config#network-access-requirements)。3868* 若要修復從相同終端機或啟動器的未來啟動,請從其環境中移除 `CLAUDE_CODE_CHILD_SESSION`
1162* 從您的 shell 執行 `claude doctor` 以進行安裝診斷
1163 3869
1164<h2 id="command-line-errors">3870<h2 id="configuration-warnings">
1165 命令列錯誤3871 設定警告
1166</h2>3872</h2>
1167 3873
1168這些錯誤來自 `claude` 命令列及其子命令。Claude Code 在執行您的提示或傳送任何 API 請求之前會列印這些錯誤。3874Claude Code 將大多數這些訊息寫入 stderr,而不是寫入對話中,並在啟動時寫入大多數訊息。當訊息出現在其他地方(例如在偵錯日誌中或作為對話檢視中的啟動通知)或在其他時間(例如[要求時的無法辨識模型診斷行](#unrecognized-model-id-on-a-request))時,條目會說明這一點。
1169 3875
1170<h3 id="conflict-between-bg-and-print">3876<h3 id="fullscreen-failed-start-notice">
1171 \--bg 和 --print 之間的衝突3877 全螢幕轉譯器未完成啟動
1172</h3>3878</h3>
1173 3879
1174此訊息需要 Claude Code v2.1.198 或更新版本。您在同一個 `claude` 呼叫中結合了 `--bg` 與 `-p` 或 `--print`。`--bg` 啟動一個[背景工作階段](/docs/zh-TW/agent-view#from-your-shell),您稍後可以使用 `claude agents` 附加到該工作階段,而 `--print` 以[非互動模式](/docs/zh-TW/headless)執行,永遠不會啟動 `claude agents` 附加到的互動工作階段。在 v2.1.198 之前,此組合會無聲地建立一個永遠無法附加的背景工作。3880此機器上的先前[全螢幕](/docs/zh-TW/fullscreen)工作階段在完成啟動前退出,因此 Claude Code 在傳統轉譯器上啟動此工作階段並列印以下其中一個通知:
1175 3881
1176```text theme={null}3882```text theme={null}
3883Claude Code 的全螢幕轉譯器上次在此機器上未完成啟動,因此此次啟動使用傳統轉譯器。它將在下次啟動時嘗試全螢幕;/tui default 保持傳統轉譯器。
3884
3885Claude Code 的全螢幕轉譯器在此機器上多次啟動失敗,因此已在此處關閉。執行 /tui fullscreen 以再次嘗試(這也會在更新後重設)。
1177```3886```
1178 3887
1179**該怎麼做:**3888**該怎麼做:**
1180 3889
1181* 移除 `-p` 或 `--print`。`--bg` 將提示作為其位置引數,所以 `claude --bg "<task>"` 是完整的命令。請參閱[從您的 shell 分派新代理](/docs/zh-TW/agent-view#from-your-shell)。3890* 遵循[全螢幕轉譯](/docs/zh-TW/fullscreen#fullscreen-renderer-didnt-finish-starting)。它說明您會收到哪個通知、Claude Code 在後續工作階段中的作用,以及如何再次嘗試全螢幕或保持傳統轉譯器。
1182* 若要以非互動模式執行提示並列印結果而不是建立背景工作階段,請移除 `--bg` 並執行 `claude -p "<task>"`3891* 如果已終止的工作階段列印了結束訊息,請參閱 [Claude Code 在無法復原的介面錯誤後退出](#exited-after-an-unrecoverable-interface-error)以了解它命名的內容。
1183 3892
1184<h3 id="the-json-schema-value-is-not-a-valid-json-schema">3893在 v2.1.236 之前,Claude Code 未列印通知,並在啟動失敗後繼續在全螢幕轉譯中啟動工作階段。
1185 \--json-schema 值不是有效的 JSON Schema3894
3895<h3 id="exited-after-an-unrecoverable-interface-error">
3896 Claude Code 在無法復原的介面錯誤後退出
1186</h3>3897</h3>
1187 3898
1188您傳遞給[`--json-schema`](/docs/zh-TW/cli-reference#cli-flags)的結構描述在[非互動模式](/docs/zh-TW/headless#get-structured-output)中未能通過 JSON Schema 編譯,所以 `claude` 以代碼 1 結束而不是執行提示。在 v2.1.205 之前,無效的結構描述會產生無結構的輸出且沒有錯誤,任何使用 `format` 關鍵字的結構描述都被視為無效。3899當 Claude Code 退出時會列印此訊息,因為其終端介面遇到無法復原的錯誤,在任一轉譯器中都是如此。第二句僅在[全螢幕](/docs/zh-TW/fullscreen)轉譯器啟動時發生錯誤時出現:
1189 3900
1190```text theme={null}3901```text theme={null}
1191Error: --json-schema is not a valid JSON Schema: data/type must be equal to one of the allowed values3902Claude Code 在無法復原的介面錯誤 (<error>) 後退出。它在全螢幕轉譯器啟動時發生,因此下次啟動將使用傳統轉譯器(CLAUDE_CODE_DISABLE_ALTERNATE_SCREEN=1 隨時強制執行)。
1192```3903```
1193 3904
1194第二個冒號之後的文字是驗證器的診斷,並命名失敗的關鍵字或位置。使用 `format` 關鍵字的結構描述(例如 `"format": "email"`)是有效的:Claude Code 接受 `format` 作為註解,不強制執行它。3905**該怎麼做:**
3906
3907* 再次啟動 Claude Code。若要繼續進行對話,請在同一目錄中執行 `claude --resume`。
3908* 如果訊息命名全螢幕轉譯器,[全螢幕轉譯](/docs/zh-TW/fullscreen#fullscreen-renderer-didnt-finish-starting)會說明下次啟動的作用,這取決於您如何開啟全螢幕,以及如何再次嘗試全螢幕或保持傳統轉譯器。
3909
3910在 v2.1.236 之前,Claude Code 在此類錯誤後退出而不列印訊息。
3911
3912<h3 id="agent-descriptions-are-over-the-15000-token-limit">
3913 代理程式描述超過 15.0k 令牌限制
3914</h3>
3915
3916Claude Code 在對話檢視中顯示此警告作為啟動通知,而不是在 stderr 上。您的[子代理程式](/docs/zh-TW/sub-agents)(除了內建代理程式外)的組合描述超過 15,000 個令牌,如 Claude Code 估計的那樣。每個代理程式計算其名稱加上其 `description` frontmatter。Claude Code 無論總數是否超過限制都會載入每個代理程式,因此警告不會改變載入的內容。
1195 3917
1196Claude Code 在結構描述編譯之前執行兩項檢查:它拒絕不可解析的 JSON 值並顯示 `Error: --json-schema is not valid JSON`,以及有效但不是物件的 JSON 並顯示 `Error: --json-schema must be a JSON object`。3918```text theme={null}
3919代理程式描述超過 15.0k 令牌限制(~16.2k 令牌)· 要求 Claude 修剪 .claude/agents/ 中的代理程式描述
3920```
1197 3921
1198**該怎麼做:**3922**該怎麼做:**
1199 3923
1200* 修復診斷命名的結構描述部分,然後重新執行命令3924* 縮短您的代理程式檔案的 `description` frontmatter,或要求 Claude 為您修剪它們。
1201* 如果診斷是 `schema too large`,請減少結構描述的巢狀和 `$ref` 重複使用3925* 移除您不再使用的代理程式檔案。
1202* 請參閱[取得結構化輸出](/docs/zh-TW/headless#get-structured-output)以取得有效的結構描述和命令
1203 3926
1204<h3 id="could-not-import-a-server-from-claude-desktop">3927<h3 id="workspace-has-not-been-trusted">
1205 無法從 Claude Desktop 匯入伺服器3928 工作區尚未受信任
1206</h3>3929</h3>
1207 3930
1208Claude Code 無法新增您在 `claude mcp add-from-claude-desktop` 中選擇的其中一個伺服器。該命令仍會匯入其他選定的伺服器,並為每個無法新增的伺服器列印一行。在 v2.1.205 之前,第一個失敗的伺服器會停止匯入,且沒有選定的伺服器被新增。3931Claude Code 在專案的 `.claude/settings.json` 或 `.claude/settings.local.json` 中找到 `permissions.allow` 規則或 `permissions.additionalDirectories` 項目,但未應用它們,因為[來自專案設定的允許規則需要工作區信任](/docs/zh-TW/permissions#project-allow-rules-and-workspace-trust)。計數、設定名稱和訊息中命名的檔案因您的設定而異。`deny` 和 `ask` 規則不受影響。
1209 3932
1210```text theme={null}3933```text theme={null}
1211Could not import my server: Invalid name my server. Names can only contain letters, numbers, hyphens, and underscores.3934忽略來自 .claude/settings.local.json 的 2 個 permissions.allow 項目:此工作區尚未受信任。在此處以互動方式執行 Claude Code 一次並接受信任對話,或在 /Users/you/.claude.json 中設定 projects["/Users/you/project"].hasTrustDialogAccepted: true。
1212```3935```
1213 3936
1214伺服器名稱之後的文字是原因。最常見的是名稱檢查:Claude Desktop 允許伺服器名稱中的字元(例如空格和句號),而 `claude mcp` 限制為字母、數字、連字號和底線。其他原因包括無法通過驗證的伺服器配置,以及被您組織的 [MCP 原則](/docs/zh-TW/managed-mcp)阻止的伺服器。
1215
1216**該怎麼做:**3937**該怎麼做:**
1217 3938
1218* 在 `claude_desktop_config.json` 中重新命名伺服器,僅使用字母、數字、連字號和底線,然後再次執行 `claude mcp add-from-claude-desktop`3939* 在目錄中執行 `claude` 並接受信任對話。[專案允許規則和工作區信任](/docs/zh-TW/permissions#project-allow-rules-and-workspace-trust)說明該接受涵蓋哪個資料夾。
1219* 使用 `claude mcp add` 或 `claude mcp add-json` 在有效名稱下直接新增該伺服器。請參閱[從 Claude Desktop 匯入 MCP 伺服器](/docs/zh-TW/mcp#import-mcp-servers-from-claude-desktop)。3940* 在[非互動模式](/docs/zh-TW/headless)中使用 `-p` 不會顯示對話。使用訊息列印的確切 `projects` 金鑰在 `~/.claude.json` 中設定 `hasTrustDialogAccepted` 項目。
3941* 如果訊息命名 `.claude/settings.local.json` 且您在 git 儲存庫外或在主目錄中啟動 Claude Code,請更新至 v2.1.200 或更新版本。版本 2.1.196 至 2.1.199 在這些工作區中將您自己的 `.claude/settings.local.json` 視為儲存庫提供的。在 v2.1.207 及更新版本上,如果您尚未信任資料夾,在 git 儲存庫外更新還不夠:確定資料夾不在儲存庫內會執行 git,Claude Code 僅在您接受信任對話後才執行該檢查,因此請使用第一步。您的主目錄和任何其他[設定主目錄](/docs/zh-TW/permissions#project-allow-rules-and-workspace-trust)豁免且不等待對話。請參閱[專案允許規則和工作區信任](/docs/zh-TW/permissions#project-allow-rules-and-workspace-trust)。
1220 3942
1221<h3 id="mcp-permission-prompt-tool-not-found">3943<h3 id="working-directory-is-a-network-path">
1222 找不到 MCP 權限提示工具3944 工作目錄是網路路徑
1223</h3>3945</h3>
1224 3946
1225您傳遞給 [`--permission-prompt-tool`](/docs/zh-TW/cli-reference#cli-flags) 的工具在執行首次需要權限決定時不在連接的 MCP 工具中,原因可能是其伺服器從未連接,或者沒有連接的伺服器公開該名稱的工具。Claude Code 仍會傳送您的提示:[非互動](/docs/zh-TW/headless)執行在第一個需要批准的工具呼叫時以此錯誤和結束代碼 1 結束,因此即使請求已發出也不會產生答案。在第一個提示之前,Claude Code 會等待最多由 [`MCP_TIMEOUT`](/docs/zh-TW/env-vars) 設定的每個伺服器連接逾時 30 秒,以便該伺服器連接。在 v2.1.206 之前,啟動不會等待伺服器完成連接,所以啟動緩慢但健康的伺服器也會產生此錯誤。3947Claude Code 不會將網路路徑新增為工作目錄。查詢網路路徑可以聯絡它命名的主機,在 Windows 上該聯絡可以將您的認證傳送給主機,因此 Claude Code 拒絕該路徑而不查詢它。當您使用此類路徑執行 `/add-dir` 時,或作為啟動時的警告時,您會看到此訊息。當它在啟動時出現時,Claude Code 啟動時不包含該目錄。
1226 3948
1227```text theme={null}3949```text theme={null}
1228Error: MCP tool mcp__permissions__approve (passed via --permission-prompt-tool) not found. Available MCP tools: none3950\\server\share 是網路路徑,無法新增為工作目錄。在 Windows 上,將共用對應到磁碟機代號,並在啟動時使用 --add-dir 傳遞它(在工作階段中新增的磁碟機代號尚未帶有遠端讀取信任)。
1229```3951```
1230 3952
1231`Available MCP tools:` 之後的清單命名了在等待結束時連接的 MCP 工具。3953Claude Code 以此方式拒絕的路徑包括:
3954
3955* UNC 共用,例如 `\\server\share`
3956* 自動掛載路徑,例如 `/net/<host>`,除非您從該主機的自動掛載下的目錄啟動 Claude Code
3957* 透過符號連結或連接點到達網路位置的本機路徑
3958
3959對應的磁碟機代號和 `\\wsl$` 路徑不計為網路路徑。
1232 3960
1233**該怎麼做:**3961**該怎麼做:**
1234 3962
1235* 檢查伺服器是否啟動並保持連接:在同一目錄中執行 `claude mcp list`,並確認伺服器列為已連接3963* 在 Windows 上,將共用對應到磁碟機代號,例如使用 `net use Z: \\server\share`,並在啟動時使用 `claude --add-dir Z:\` 傳遞磁碟機。
1236* 確認工具名稱與伺服器公開的 `mcp__<server>__<tool>` 名稱相符3964* 在 macOS 或 Linux 上,在本機路徑掛載共用並改為新增該路徑。
1237* 如果伺服器需要超過 30 秒才能啟動,請提高 [`MCP_TIMEOUT`](/docs/zh-TW/env-vars)3965* 如果路徑在 `permissions.additionalDirectories` 中,請從列出它的設定檔中移除它。
1238 3966
1239<h2 id="plugin-errors">3967在 v2.1.257 之前,Claude Code 接受可到達的網路路徑作為工作目錄。
1240 外掛程式錯誤3968
1241</h2>3969<h3 id="remote-managed-settings-failed-to-load">
3970 遠端受管設定無法載入
3971</h3>
1242 3972
1243這些錯誤來自 [外掛程式](/docs/zh-TW/plugins) 和 [市集](/docs/zh-TW/plugin-marketplaces) 設定。對於不會產生此頁面上其中一則訊息的外掛程式問題,例如無法載入的市集 URL 或已安裝但未出現的外掛程式,請參閱 [外掛程式疑難排解](/docs/zh-TW/discover-plugins#troubleshooting)。3973您的工作階段符合[伺服器受管設定](/docs/zh-TW/server-managed-settings)的資格,但 Claude Code 無法擷取它們,因此在互動工作階段中顯示此警告。括號中的原因命名失敗的內容,例如 `network error`、`request timed out` 或 `authentication rejected (401)`,行的其餘部分說明工作階段執行的策略:
1244 3974
1245<h3 id="marketplace-is-registered-from-an-untrusted-source">3975* **從較早成功擷取快取的設定**:Claude Code 在該快取策略上執行工作階段,除了[隱藏的環境變數](/docs/zh-TW/server-managed-settings#fetch-and-caching-behavior),行讀取 `using cached policy`。
1246 市集是從不受信任的來源註冊的3976* **無快取**:Claude Code 在沒有伺服器受管設定的情況下執行工作階段,行讀取 `no remote policy applied`。
3977
3978**該怎麼做:**
3979
3980* 對訊息命名的原因採取行動:對於網路原因,檢查此機器是否可以到達 `api.anthropic.com`;對於驗證原因,使用 `/status` 檢查您的登入
3981* 執行 `/status` 或 `claude doctor` 以取得完整診斷
3982
3983在 v2.1.248 之前,Claude Code 僅在偵錯日誌中報告設定擷取失敗。
3984
3985<h3 id="managed-settings-were-not-approved">
3986 受管設定未獲批准
1247</h3>3987</h3>
1248 3988
1249市集是以 [為官方 Anthropic 市集保留的名稱](/docs/zh-TW/plugin-marketplaces#marketplace-schema) 註冊的,但其註冊的來源不是 `anthropics` GitHub 儲存庫。Claude Code 每次載入或重新整理市集時都會重新檢查保留的名稱,因此市集和從中安裝的外掛程式會停止載入。在 v2.1.205 之前,只有在新增市集時才會檢查名稱,因此在名稱變成保留名稱之前註冊的項目會繼續載入。3989您的組織的[伺服器受管設定](/docs/zh-TW/server-managed-settings)包括需要您批准的設定,且您拒絕了[安全批准對話](/docs/zh-TW/server-managed-settings#security-approval-dialogs),因此 Claude Code 退出而不應用它們:
1250 3990
1251```text theme={null}3991```text theme={null}
1252Marketplace "claude-community" is registered from an untrusted source: The name 'claude-community' is reserved for official Anthropic marketplaces. Only repositories from 'github.com/anthropics/' can use this name. To fix it, remove the marketplace and re-add it from the official source.3992受管設定未獲批准;退出而不應用它們。
1253```3993```
1254 3994
1255**該怎麼做:**3995**該怎麼做:**
1256 3996
1257* 執行 `claude plugin marketplace remove <name>`,然後從官方 `github.com/anthropics` 儲存庫重新新增市集3997* 再次啟動 Claude Code 並批准對話以在您的組織設定下繼續。拒絕的對話不會被記住,因此在下次啟動時會再次出現。
1258* 如果您發佈了在名稱變成保留名稱之前使用該名稱的第三方市集,請重新命名它並要求使用者從您的來源重新新增它3998* 如果您對對話列出的設定不確定,在批准前詢問維護您的組織受管設定的人
1259* 請參閱 [市集結構描述](/docs/zh-TW/plugin-marketplaces#marketplace-schema) 下的保留名稱清單
1260 3999
1261<h3 id="plugin-command-references-user-config">4000<h3 id="mcp-server-is-blocked-by-enterprise-managed-policy">
1262 外掛程式命令在 shell 命令中參考 user\_config4001 MCP 伺服器被企業受管策略阻止
1263</h3>4002</h3>
1264 4003
1265外掛程式 hook、[monitor](/docs/zh-TW/plugins-reference#monitors) 或 MCP [`headersHelper`](/docs/zh-TW/mcp#use-dynamic-headers-for-custom-authentication) 命令參考 `${user_config.KEY}` [外掛程式選項](/docs/zh-TW/plugins-reference#user-configuration),而替換後的字串會被傳遞到 shell。設定的值包含 `$(...)` 、反引號或 `;` 會在該處作為程式碼執行,因此 Claude Code 拒絕啟動元件而不是替換該值。檢查在命令範本上執行,因此即使尚未設定任何值,錯誤也會出現。在 v2.1.207 之前,該值被替換到 shell 命令中。4004您在 `/mcp` 中選擇了伺服器上的**重新連線**,或在那裡重新開啟了已停用的伺服器,且[限制 MCP 伺服器](/docs/zh-TW/managed-mcp)的設定阻止該伺服器。Claude Code 拒絕連線它並顯示:
1266
1267措辭取決於哪個介面參考了該選項。shell 形式的 hook 會報告:
1268 4005
1269```text theme={null}4006```text theme={null}
1270Hook from plugin formatter@acme-tools references ${user_config.*} in a shell-form command. The substituted value would be re-parsed by the shell. Use exec form instead — {"command": "<executable>", "args": ["${user_config.KEY}", ...]} — or read $CLAUDE_PLUGIN_OPTION_<KEY> from the hook's environment. Command: ./scripts/notify.sh ${user_config.webhook_url}4007MCP 伺服器 <name> 被企業受管策略阻止
1271```4008```
1272 4009
1273monitor 會報告:4010以下任何設定都可能產生訊息:
4011
4012* 與伺服器相符的 [`deniedMcpServers`](/docs/zh-TW/managed-mcp#policy-based-control-with-allowlists-and-denylists) 項目,包括您自己的 `~/.claude/settings.json` 或專案的 `.claude/settings.json` 中的項目
4013* 伺服器不相符的 [`allowedMcpServers`](/docs/zh-TW/managed-mcp#policy-based-control-with-allowlists-and-denylists) 清單
4014* [`strictPluginOnlyCustomization`](/docs/zh-TW/settings-reference#strictpluginonlycustomization) 且 `mcp` 已鎖定,這會阻止在 `~/.claude.json` 和 `.mcp.json` 中設定的伺服器
4015* [`disableClaudeAiConnectors`](/docs/zh-TW/mcp#disable-claude-ai-connectors),當伺服器是 claude.ai 連接器時
4016
4017**該怎麼做:**
4018
4019* 檢查您自己的使用者和專案設定檔案中是否有這些設定之一,並變更或移除它
4020* 如果您自己的設定都不能解釋該阻止,請詢問您的管理員哪個受管設定阻止了伺服器
4021
4022在 v2.1.257 之前,**重新連線**和在 `/mcp` 中重新啟用可以連線伺服器,該伺服器被中途工作階段策略更新阻止。
4023
4024<h3 id="managed-settings-document-could-not-be-parsed">
4025 受管設定文件無法解析
4026</h3>
4027
4028您的組織部署[受管設定](/docs/zh-TW/managed-settings),且其中一個已部署的文件存在但無法解析為 JSON 物件,因此 Claude Code 在啟動時以代碼 1 退出,而不是執行而不使用文件帶來的策略。行在訊息前命名失敗的來源:
1274 4029
1275```text theme={null}4030```text theme={null}
1276Monitor "deploy-status" from plugin deploy-tools references ${user_config.*} in its command. The substituted value would be passed to a shell. Monitor commands cannot safely reference ${user_config.*}; have the monitor script read the value from a config file or prompt instead.4031/Library/Application Support/ClaudeCode/managed-settings.json:受管設定文件無法解析為 JSON 物件;其設定都不生效。修復或移除它。
1277```4032```
1278 4033
1279MCP `headersHelper` 會報告:4034來源是以下其中之一:
4035
4036* `managed-settings.json` 檔案的路徑或 `managed-settings.d` 下的放入檔案
4037* macOS 受管偏好設定設定檔、`per-user managed preferences` 或 `device-level managed preferences`
4038* Windows 登錄值、`Registry: HKLM\SOFTWARE\Policies\ClaudeCode\Settings`
4039
4040[尋找 Claude Code 放棄的項目](/docs/zh-TW/managed-settings#find-entries-claude-code-dropped)列出使每個來源無法解析的原因。
4041
4042Claude Code 拒絕啟動,即使另一個管理來源提供有效策略。您在互動工作階段、`claude -p`、Agent SDK 工作階段、[背景工作階段](/docs/zh-TW/agent-view)和大多數子命令(包括 `claude doctor`)中看到此錯誤。拒絕故意失敗關閉:Claude Code 無法解析的文件中的設定無法強制執行,啟動時不應用組織的控制項會執行工作階段。
4043
4044可解析文件中的架構問題不會產生此錯誤。[尋找 Claude Code 放棄的項目](/docs/zh-TW/managed-settings#find-entries-claude-code-dropped)涵蓋 Claude Code 對其所做的操作。
4045
4046當 `managed-settings.d/` 目錄存在但無法列出時,Claude Code 報告 `Managed settings drop-in directory could not be read:` 後跟基礎錯誤。[尋找 Claude Code 放棄的項目](/docs/zh-TW/managed-settings#find-entries-claude-code-dropped)涵蓋讀取失敗在啟動時退出的時間。
4047
4048**該怎麼做:**
4049
4050* 如果您管理機器,修復命名的文件使其解析為 JSON 物件,或移除檔案、設定檔或登錄值。空的 `managed-settings.json` 計為 `{}` 且不會阻止啟動。
4051* 如果您不管理,請要求您的管理員修復已部署的文件。您自己的設定檔案中沒有任何內容會導致或清除此錯誤。
4052
4053<h3 id="headershelper-not-run">
4054 headersHelper 未執行
4055</h3>
4056
4057Claude Code 僅使用其靜態 `headers` 連線了 MCP 伺服器,並跳過了伺服器的 [`headersHelper`](/docs/zh-TW/mcp#use-dynamic-headers-for-custom-authentication),因為協助程式是 shell 命令且資料夾沒有已儲存的信任。當您手動在 `~/.claude.json` 中設定其項目時,或在主目錄外,當您在互動工作階段中為其接受信任對話時,資料夾會獲得已儲存的信任。請參閱[在 headersHelper 執行前信任資料夾](/docs/zh-TW/mcp#trust-a-folder-before-its-headershelper-runs)以了解此檢查適用於哪些伺服器。
4058
4059Claude Code 僅在[非互動模式](/docs/zh-TW/headless)中寫入此行,每個伺服器一次。在互動工作階段中,它改為將相同的拒絕寫入偵錯日誌。
1280 4060
1281```text theme={null}4061```text theme={null}
1282headersHelper for MCP server 'internal-api' references ${user_config.*}. The substituted value would be passed to a shell; read the value inside the helper script instead (e.g. from an env var set in the server's "env" block).4062MCP 伺服器 'internal-api':headersHelper 未執行 — 此工作區沒有持久化信任;在此處以互動方式接受信任對話一次,或在 /Users/you/.claude.json 中設定 projects["/Users/you/project"].hasTrustDialogAccepted。
1283```4063```
1284 4064
4065訊息列印的 `projects` 金鑰是資料夾[專案允許規則和工作區信任](/docs/zh-TW/permissions#project-allow-rules-and-workspace-trust)說明 Claude Code 信任的金鑰。為父資料夾接受信任對話不滿足檢查,`-p` 或 SDK 工作階段也不滿足。
4066
1285**該怎麼做:**4067**該怎麼做:**
1286 4068
1287* 對於 hook,新增 `args` 陣列使其以 [exec 形式](/docs/zh-TW/hooks#exec-form-and-shell-form) 執行,其中每個 `${user_config.KEY}` 變成一個引數,中間沒有 shell。或者移除參考並在指令碼內讀取 `$CLAUDE_PLUGIN_OPTION_<KEY>` 環境變數4069* 在訊息命名的資料夾中執行 `claude`,接受信任對話,然後再次執行您的 `-p` 或 SDK 命令
1288* 對於 monitor,移除參考並讓 monitor 指令碼從設定檔讀取該值4070* 在 `~/.claude.json` 中自己設定 `hasTrustDialogAccepted` 項目,使用訊息列印的確切 `projects` 金鑰
1289* 對於 `headersHelper`,將 `${user_config.KEY}` 移到伺服器的 `headers` 欄位(不會進行 shell 解析),或在 helper 指令碼內讀取該值4071* 如果您在主目錄中啟動工作階段,請從您已信任的專案目錄工作。當您在主目錄中接受信任對話時,Claude Code 僅在目前工作階段中保持該信任。
1290 4072
1291<h2 id="tool-errors">4073<h3 id="malformed-tool-content-rule">
1292 工具錯誤4074 格式不正確的 Tool(content) 規則
1293</h2>4075</h3>
1294 4076
1295這些錯誤來自 Claude 的內建工具拒絕輸入。Claude 會自動修正大多數工具錯誤;以下兩個需要您進行變更,因為它們來自您控制的子代理定義或權限規則。4077您的設定檔案中的[權限規則](/docs/zh-TW/permissions#permission-rule-syntax)沒有 `Tool` 或 `Tool(content)` 的形狀,例如因為文字跟在右括號後面或其中一個括號遺失。Claude Code 跳過規則,並在互動工作階段啟動時在無效設定對話中列出它,以及在 [`claude doctor`](/docs/zh-TW/debug-your-config#check-resolved-settings) 輸出中:
1296 4078
1297<h3 id="agent-would-be-spawned-with-zero-tools">4079```text theme={null}
1298 Agent would be spawned with zero tools4080無效權限規則 "Bash(ls) x" 已跳過:格式不正確的 Tool(content) 規則。規則採用 Tool 或 Tool(content) 的形式,必須在右括號 ")" 處結束;括號內的內容是字面意思
4081```
4082
4083**該怎麼做:**
4084
4085* 在訊息列出的設定檔中,重寫規則使其在其右括號處結束,例如用 `Bash(ls *)` 代替 `Bash(ls) x`
4086* 將括號內的內容保留原樣。它們是字面意思,因此規則如 `Edit(./Finance (2024)/*)` 無需逃逸即有效
4087
4088在 v2.1.260 之前,Claude Code 將括號不相符的規則報告為 `Mismatched parentheses`。
4089
4090<h3 id="is-not-matched-by-file-permission-checks">
4091 不符合檔案權限檢查
1299</h3>4092</h3>
1300 4093
1301[子代理的 `tools` 清單](/docs/zh-TW/sub-agents#supported-frontmatter-fields)中沒有任何內容解析為工具,因此 Claude Code 拒絕啟動子代理,而不是啟動無法執行操作的代理。該訊息按它們未解析的原因對條目進行分組:未被識別的工具、不適用於子代理的工具,或已識別但與目前工作階段中的任何工具都不匹配。省略 `tools` 欄位永遠不會觸發此拒絕。MCP 伺服器模式(例如 `mcp__github__*`)不在豁免範圍內:當該伺服器沒有連接的工具時,啟動會被拒絕,並在不匹配的群組中顯示該模式。在 v2.1.208 之前,子代理會以零個工具啟動並返回空的或令人困惑的結果。4094Claude Code 在您的[設定檔案](/docs/zh-TW/settings#where-settings-live)、[受管設定](/docs/zh-TW/managed-settings)或 `--allowedTools`、`--disallowedTools` 或 `--settings` 旗標值中找到了具有路徑的 `Write`、`NotebookEdit`、`MultiEdit` 或 `Glob`[權限規則](/docs/zh-TW/permissions#read-and-edit)。它僅針對 `Edit` 和 `Read` 規則檢查檔案權限,因此它永遠不會查詢命名其他檔案工具之一的路徑規則。它保留規則並不改變其他任何內容;警告命名規則、其在括號中的來源和要寫入的替換:
1302 4095
1303```text theme={null}4096```text theme={null}
1304Agent 'code-reviewer' would be spawned with zero tools — refusing. Its tools list resolved to nothing: unrecognized [Grpe]. Fix the agent's tools frontmatter or pass a different subagent_type.4097權限拒絕規則 (.claude/settings.json):Write(docs/**) 不符合檔案權限檢查 — 僅 Edit(path) 規則。改用 Edit(docs/**)(Edit 規則涵蓋所有檔案編輯工具)。
1305```4098```
1306 4099
1307**應該怎麼做:**4100**該怎麼做:**
1308 4101
1309* 根據[子代理可用的工具](/docs/zh-TW/sub-agents#available-tools)更正錯誤命名的每個條目4102* 將 `Write(path)`、`NotebookEdit(path)` 和舊版 `MultiEdit(path)` 規則替換為 `Edit(path)`。`Edit` 規則涵蓋所有檔案編輯工具。
1310* 移除工作階段沒有的工具條目,例如來自未連接伺服器的 MCP 工具4103* 除了在 `--allowedTools` 中,Claude Code 接受 `Glob` 規則而不警告,將 `Glob(path)` 規則替換為 `Read(path)`。
1311* 若要讓子代理擁有父代理的所有工具,請刪除 `tools` 欄位,而不是列出工具4104* 在警告在括號中命名的來源處修復規則:設定檔案路徑,或 `--allowed-tools` 和 `--disallowed-tools` 的旗標本身。不存在於磁碟上的 `claude-settings-<hash>.json` 路徑代表內聯 `--settings` 值。修復您傳遞給該旗標的 JSON。
4105* 將裸工具名稱規則(例如 `Write` 或 `Glob`)保留原樣。Claude Code 在[工具級別](/docs/zh-TW/permissions#match-all-uses-of-a-tool)上相符它們,不會警告它們。
4106* 如果來源讀取 `managed policy settings`,將警告轉發給維護您受管設定的人,因為您無法自己清除它。
1312 4107
1313<h3 id="file-is-covered-by-a-read-deny-rule">4108在[背景工作階段](/docs/zh-TW/agent-view)或使用 `--output-format json` 或 `stream-json` 時,Claude Code 將警告寫入偵錯日誌而不是 stderr,因此機器讀取輸出保持乾淨。使用 `--debug` 在 `~/.claude/debug/<session-id>.txt` 處擷取它。在 v2.1.210 之前,Claude Code 接受這些規則而不警告。
1314 File is covered by a Read deny rule4109
4110<h3 id="has-a-wildcard-before-the-rest-of-the-command">
4111 在命令的其餘部分之前有萬用字元
1315</h3>4112</h3>
1316 4113
1317Edit 工具在與 [`Read` 拒絕規則](/docs/zh-TW/permissions#read-and-edit)相符的路徑上被呼叫,包括在該路徑建立新檔案。編輯會重寫 Claude 必須能夠讀回的內容,因此呼叫在任何檔案存取之前被拒絕。該規則僅阻止 Edit 工具:Write 和 NotebookEdit 不受 `Read` 拒絕規則涵蓋。在 v2.1.208 之前,只有 `Edit` 拒絕規則會阻止編輯,而 `Read` 拒絕規則單獨不會。4114Claude Code 在您的[設定檔案](/docs/zh-TW/settings#where-settings-live)、[受管設定](/docs/zh-TW/managed-settings)或 `--allowedTools` 或 `--settings` 旗標值中找到了 `Bash` 允許規則,其 `*` 在決定它是哪個命令的後續單詞之前,例如 `Bash(git * main)` 或 `Bash(git -C * status *)`。`*` 符合任何文字,包括在該位置插入的選項:`Bash(git * main)` 也批准 `git -c core.fsmonitor=<script> diff main`,其中 `-c` 使 git 執行命令命名的程式。[萬用字元模式](/docs/zh-TW/permissions#wildcard-patterns)顯示相符規則。
4115
4116警告存在是為了讓您縮小萬用字元比您預期更寬的規則。Claude Code 保留規則並不改變它相符的方式;警告命名規則及其在括號中的來源:
1318 4117
1319```text theme={null}4118```text theme={null}
1320File is covered by a Read deny rule in your permission settings and cannot be edited.4119權限允許規則 (.claude/settings.json):Bash(git -C * status *) 在命令的其餘部分之前有萬用字元,因此它也符合在該位置插入的任何選項並批准它們而不提示。對於 git,選項如 -c 和 --exec-path 可以執行任意命令。將該 * 替換為您的確切值,或僅在子命令後使用 *(例如 Bash(git status *))。
1321```4120```
1322 4121
1323**應該怎麼做:**4122**該怎麼做:**
1324 4123
1325* 如果 Claude 應該能夠編輯該檔案,請在 `/permissions` 或[設定](/docs/zh-TW/settings#permission-settings)中移除或縮小 `Read` 拒絕規則4124* 將子命令前的 `*` 替換為您的確切值:用 `Bash(git checkout main)` 代替 `Bash(git * main)`。
1326* 如果檔案必須保持未觸及狀態,請保留該規則並為相同路徑新增 `Edit` 拒絕規則,以便 Write 和 NotebookEdit 工具也被阻止4125* 將每個 `*` 移到子命令後:用 `Bash(git status *)` 代替 `Bash(git -C * status *)`。為您想允許的每個子命令寫一個規則。
4126* 在警告在括號中命名的來源處修復規則:設定檔案路徑,或 `--allowed-tools` 旗標本身。不存在於磁碟上的 `claude-settings-<hash>.json` 路徑代表內聯 `--settings` 值。修復您傳遞給該旗標的 JSON。
4127* 如果來源讀取 `managed policy settings`,將警告轉發給維護您受管設定的人,因為您無法自己清除它。
1327 4128
1328<h2 id="background-session-errors">4129Claude Code 不警告具有相同形狀的拒絕和詢問規則:它拒絕或提示它們相符的額外命令,而不是批准它們。它也不警告子命令在第一個 `*` 之前的規則,例如 `Bash(git commit *)`,或沒有單詞(除了選項)跟在 `*` 後的規則,例如 `Bash(git *)`,或關於 `:*` 前綴規則如 `Bash(git:*)`。
1329 背景工作階段錯誤
1330</h2>
1331 4130
1332[背景工作階段](/docs/zh-TW/agent-view)在沒有互動式終端的情況下執行,因此需要終端的命令在那裡的行為會有所不同。這些訊息會出現在背景工作階段的文字記錄中,在代理檢視中或附加後。4131在[背景工作階段](/docs/zh-TW/agent-view)或使用 `--output-format json` 或 `stream-json` 時,Claude Code 將警告寫入偵錯日誌而不是 stderr,因此機器讀取輸出保持乾淨。使用 `--debug` 在 `~/.claude/debug/<session-id>.txt` 處擷取它。在 v2.1.246 之前,Claude Code 接受這些規則而不警告。
1333 4132
1334<h3 id="commands-refused-in-a-background-session">4133<h3 id="crosssessioninbound-must-be-one-of-accept-hold-refuse">
1335 背景工作階段中被拒絕的命令4134 crossSessionInbound 必須是 accept、hold、refuse 之一
1336</h3>4135</h3>
1337 4136
1338在背景工作階段中,開啟互動式對話框的命令會被拒絕,並顯示一條訊息,說明在該處有效的表單或告訴您從常規終端執行命令。`/install-github-app`、`/mcp` 設定清單和 MCP 伺服器選單中的驗證操作都以這種方式被拒絕。在 v2.1.208 之前,它們在背景工作階段內開啟了對話框。4137設定檔案將 [`crossSessionInbound`](/docs/zh-TW/settings-reference#crosssessioninbound) 設定為 Claude Code 無法辨識的值,例如打字錯誤 `"reject"`。警告的第二句取決於哪個檔案保持該值;在使用者、專案、本機或 `--settings` 檔案中讀取:
1339在 v2.1.208 中,`/model` 選擇器也在背景工作階段中被拒絕,`/upgrade` 列印升級 URL 而不是開啟瀏覽器。4138
4139```text theme={null}
4140"crossSessionInbound" 必須是 "accept"、"hold"、"refuse" 之一;收到 "reject"。此值被忽略;當它存在時,跨工作階段訊息被保持以供您批准,而不是被傳遞。將其設定為上述值之一。
4141```
4142
4143在[受管設定](/docs/zh-TW/managed-settings)中,Claude Code 將無法辨識的值視為 `refuse`(最限制的值),警告說跨工作階段訊息被拒絕,直到管理員修復它。有關保持如何與您其他設定檔案中的值結合,請參閱 [`crossSessionInbound`](/docs/zh-TW/settings-reference#crosssessioninbound)。
4144
4145**該怎麼做:**
4146
4147* 將金鑰設定為 `"accept"`、`"hold"` 或 `"refuse"`,或移除它
4148* 當警告命名受管設定時,要求管理員修復該值
1340 4149
1341措辭會說明被拒絕的命令。`/mcp` 設定清單報告:4150在 v2.1.248 之前,Claude Code 忽略無法辨識的值而不警告。
4151
4152<h3 id="the-200k-limit-isnt-enforced">
4153 200K 限制未強制執行
4154</h3>
4155
4156您設定了 [`CLAUDE_CODE_DISABLE_1M_CONTEXT=1`](/docs/zh-TW/env-vars),這通常使[自動壓縮](/docs/zh-TW/model-config#default-auto-compact-thresholds)在 1M 上下文模型上保持工作階段至 200K 視窗,但沒有壓縮閾值將此工作階段限制在或低於 200K,因此對話可以超過它。
1342 4157
1343```text theme={null}4158```text theme={null}
1344Can't open MCP settings in a background session — use `/mcp enable|disable|reconnect <server>` to steer, or run /mcp from an interactive terminal to authenticate.4159CLAUDE_CODE_DISABLE_1M_CONTEXT 已設定,但 <model> 的 200K 限制未強制執行,因此此工作階段可以超過它。若要強制執行,設定 CLAUDE_CODE_AUTO_COMPACT_WINDOW=200000(或 autoCompactWindow 設定)。
1345```4160```
1346 4161
4162Claude Code 為它辨識為具有原生 1M 視窗的每個模型自行強制執行 200K 限制,對於它無法辨識的模型 ID,它在它假設的視窗處壓縮。當其他設定擊敗該強制執行時出現警告:
4163
4164* 模型 ID 不是 Claude Code 辨識的,例如[LLM 閘道](/docs/zh-TW/llm-gateway)別名,且您設定了 [`CLAUDE_CODE_DISABLE_UNKNOWN_MODEL_WINDOW_ENFORCEMENT=1`](/docs/zh-TW/env-vars) 或使用 [`CLAUDE_CODE_MAX_CONTEXT_TOKENS`](/docs/zh-TW/env-vars) 將假設的視窗提高到 200K 以上。在此情況下,訊息也提供 `or update to a Claude Code version that recognizes <model>` 作為補救。
4165* 透過 [`ANTHROPIC_BETAS`](/docs/zh-TW/env-vars) 或 [`--betas`](/docs/zh-TW/cli-reference#cli-flags) 旗標要求的 `context-1m` 測試版仍要求 API 在接受該測試版的模型上使用 1M 視窗,而沒有任何內容在 200K 處壓縮工作階段
4166
1347**該怎麼做:**4167**該怎麼做:**
1348 4168
1349* 使用訊息所說的表單,例如 `/mcp reconnect <server>`、`/mcp enable` 或 `/mcp disable`4169* 設定 [`CLAUDE_CODE_AUTO_COMPACT_WINDOW=200000`](/docs/zh-TW/env-vars),或 [`autoCompactWindow`](/docs/zh-TW/settings-reference#autocompactwindow) 設定為 `200000`,以便自動壓縮在 200K 邊界處壓縮
1350* 對於登入和授權流程,請從終端中的常規 `claude` 工作階段執行命令4170* 如果訊息命名此版本無法辨識的模型 ID,執行 `claude update`。辨識 ID 為 1M 上下文模型的版本無需進一步設定即可強制執行限制。
4171* 如果您想讓工作階段改為使用模型的完整視窗,取消設定 `CLAUDE_CODE_DISABLE_1M_CONTEXT`;警告僅報告 200K 限制未強制執行
1351 4172
1352<h3 id="claude_code_process_wrapper-launcher-errors">4173在[背景工作階段](/docs/zh-TW/agent-view)或使用 `--output-format json` 或 `stream-json` 時,Claude Code 將警告寫入偵錯日誌而不是 stderr。
1353 CLAUDE\_CODE\_PROCESS\_WRAPPER 啟動器錯誤4174
4175<h3 id="unrecognized-model-id-on-a-request">
4176 要求上無法辨識的模型 ID
1354</h3>4177</h3>
1355 4178
1356[`CLAUDE_CODE_PROCESS_WRAPPER`](/docs/zh-TW/corporate-launcher) 已設定,但其值無法使用,因此 Claude Code 拒絕啟動受影響的程序,而不是在沒有啟動器的情況下執行它。配置問題會報告為以變數名稱開頭並說明原因的訊息,例如:4179Claude Code 為您的 Claude Code 版本無法辨識的模型 ID 傳送了要求,並找不到將該 ID 對應到它辨識的模型的 [`modelOverrides`](/docs/zh-TW/model-config#override-model-ids-per-version) 項目。Claude Code 仍使用您設定的 ID 傳送要求,不退出或切換模型。
1357 4180
1358```text theme={null}4181```text theme={null}
1359CLAUDE_CODE_PROCESS_WRAPPER: launcher `/opt/corp/launcher` is not an executable regular file4182[claude-code:unrecognized_model] {"model":"my-proxy-model","query_source":"sdk"}
1360```4183```
1361 4184
1362啟動但退出而不用 Claude Code 替換自身的啟動器會導致它啟動的工作階段失敗,該工作階段在代理檢視中的列會報告啟動器 `must exec, not daemonize`,後面跟著啟動器列印的任何內容。由於啟動器而無法啟動或無法到達背景服務的工作階段會將啟動器問題報告為 `Couldn't reach the background service (...)` 內的原因。4185在讀取 stderr 的指令碼或工具中,符合 `[claude-code:unrecognized_model]` 前綴。在前綴和一個空格之後,Claude Code 寫入一行 JSON 物件。Claude Code 可以在更新版本中向其新增欄位,因此忽略您不期望的任何欄位。它至少寫入這兩個:
4186
4187* `model`:您設定的模型字串
4188* `query_source`:使用模型的要求路徑。Claude Code 為 `-p` 執行報告 `sdk`,為子代理程式報告以 `agent:` 開頭的值。
4189
4190Claude Code 根據您執行它的方式將行寫入兩個位置之一:
4191
4192* 在[非互動模式](/docs/zh-TW/headless)中使用 `-p`,Claude Code 在每個 `--output-format` 下將其寫入 stderr,因此您可以解析 stdout 而不過濾行
4193* 在互動工作階段或[背景工作階段](/docs/zh-TW/agent-view)中,Claude Code 改為將其寫入偵錯日誌;使用 `--debug` 在 `~/.claude/debug/<session-id>.txt` 處擷取它
4194
4195Claude Code 每個模型字串每個程序寫入行一次。它為每個進一步的無法辨識的 ID 寫入單獨的行,例如[子代理程式](/docs/zh-TW/sub-agents#choose-a-model)或[背景功能](/docs/zh-TW/costs#background-token-usage)使用的 ID。
4196
4197Claude Code 不為它解析為它辨識的模型的提供者 ID 寫入行,例如 Amazon Bedrock `us.anthropic.claude-...` ID、Google Cloud 的 Agent Platform ID 帶有 `@` 版本後綴,以及包含 Claude 模型 ID 的 Microsoft Foundry 部署名稱。Claude Code 檢查 Amazon Bedrock[應用程式推論設定檔 ARN](/docs/zh-TW/amazon-bedrock#map-each-model-version-to-an-inference-profile) 後面的模型,而不是 ARN 本身。它為無法解析的 ARN(例如打字錯誤的 ARN)寫入無行。
1363 4198
1364**該怎麼做:**4199**該怎麼做:**
1365 4200
1366* 將變數設定為可執行檔的絕對路徑,該路徑以呼叫 `exec "$@"` 結尾。請參閱[啟動器合約](/docs/zh-TW/corporate-launcher#the-launcher-contract)以了解完整合約4201* 如果您故意設定 ID,例如[LLM 閘道](/docs/zh-TW/llm-gateway)別名,將 [`modelOverrides`](/docs/zh-TW/model-config#override-model-ids-per-version) 項目新增到您的[設定檔案](/docs/zh-TW/settings#where-settings-live),以 ID 作為其值。使用 Anthropic 模型 ID 作為金鑰,而不是家族別名如 `opus`。對於範例行中的 `my-proxy-model`,新增此項目:
1367* 檢查 `/status`,它在其 Self-exec 項目中顯示已解析的啟動命令,並在執行中的背景服務不符合時發出警告,或從 shell 執行 `claude daemon status`
1368* 在修復 [settings](/docs/zh-TW/corporate-launcher#set-up-the-launcher) 的 `env` 區塊中的值後,使用 `claude daemon stop --any` 重新啟動背景服務,以便下一次分派啟動包裝的服務
1369 4202
1370<h2 id="configuration-warnings">4203 ```json theme={null}
1371 設定警告4204 {
1372</h2>4205 "modelOverrides": {
4206 "claude-opus-4-6": "my-proxy-model"
4207 }
4208 }
4209 ```
1373 4210
1374Claude Code 在啟動時將這些訊息寫入 stderr,而不是在對話中顯示錯誤。它們報告 Claude Code 讀取但未應用的設定。4211 Claude Code 然後將 `my-proxy-model` 視為 `claude-opus-4-6` 並停止寫入行。
1375 4212
1376<h3 id="workspace-has-not-been-trusted">4213* 如果 ID 命名比您的 Claude Code 版本更新的模型,執行 `claude update`
1377 工作區尚未受信任4214
4215* 如果 ID 是打字錯誤,在您可以設定模型的[位置](/docs/zh-TW/model-config#setting-your-model)或[別名變數](/docs/zh-TW/model-config#environment-variables)中修復它。如果 `query_source` 以 `agent:` 開頭,改為在您設定[子代理程式模型](/docs/zh-TW/sub-agents#choose-a-model)的位置修復它。
4216
4217在 v2.1.233 之前,Claude Code 為無法辨識的模型 ID 傳送要求時未寫入行。
4218
4219<h3 id="stale-sandbox-mask-files-left-by-a-killed-session">
4220 被殺死的工作階段留下的過時沙箱遮罩檔案
1378</h3>4221</h3>
1379 4222
1380Claude Code 在專案的 `.claude/settings.json` 或 `.claude/settings.local.json` 中找到了 `permissions.allow` 規則或 `permissions.additionalDirectories` 項目,但未應用它們,因為[來自專案設定的允許規則需要工作區信任](/docs/zh-TW/permissions#project-allow-rules-and-workspace-trust)。訊息中的計數、設定名稱和檔案名稱會根據您的設定而變化。`deny` 和 `ask` 規則不受影響。4223`claude doctor` 在其診斷中列印此警告,`/status` 列出相同的行。它在 Linux 和 WSL2 上出現,當[沙箱](/docs/zh-TW/sandboxing)啟用且檔案系統隔離開啟時。
4224
4225當沙箱化命令執行時,沙箱透過在那裡建立 0 位元組唯讀佔位符來保持對尚不存在的檔案的寫入拒絕,並在之後移除它。在該清理執行前被殺死的工作階段(例如透過 SIGKILL)會留下佔位符。後續工作階段在每次啟動時再次唯讀繫結它們,因此設定寫入(例如儲存「是,不要再問」)在其中一個所在的位置失敗。
1381 4226
1382```text theme={null}4227```text theme={null}
1383Ignoring 2 permissions.allow entries from .claude/settings.local.json: this workspace has not been trusted. Run Claude Code interactively here once and accept the trust dialog, or set projects["/Users/you/project"].hasTrustDialogAccepted: true in /Users/you/.claude.json.4228- 被殺死的工作階段留下的過時沙箱遮罩檔案:/home/you/project/.claude/settings.local.json
4229 修復:在該專案中沒有其他 Claude Code 工作階段執行時,使用 `rm <path>` 移除每個 — 0 位元組唯讀檔案(其中設定檔案所在)使「是,不要再問」無法儲存,沙箱在每次啟動時再次唯讀繫結它
1384```4230```
1385 4231
1386**該怎麼做:**4232**該怎麼做:**
1387 4233
1388* 在目錄中執行 `claude` 並接受信任對話框。即使父目錄已經受信任,對話框仍會出現,列出被保留的規則,並讓您可以拒絕並繼續工作而不使用這些規則。在 v2.1.200 之前,在這種情況下不會出現對話框,因此無法在那裡完成此步驟。4234* 退出在該專案中執行的任何其他 Claude Code 工作階段,然後使用 `rm` 刪除每個列出的檔案。警告命名最多三個檔案並計算其餘的,因此在刪除後重新執行 `claude doctor` 直到警告不再出現。另一個工作階段的沙箱仍在使用的佔位符是該工作階段寫入保護的活躍部分
1389* 在[非互動模式](/docs/zh-TW/headless)中使用 `-p` 時不會顯示對話框。使用訊息列印的確切 `projects` 金鑰在 `~/.claude.json` 中設定 `hasTrustDialogAccepted` 項目。4235* 如果您使用「是,不要再問」儲存的權限選擇未堅持,在刪除佔位符後再次儲存它
1390* 如果訊息命名 `.claude/settings.local.json` 且您在 git 儲存庫外或在主目錄中啟動 Claude Code,請更新至 v2.1.200 或更新版本。版本 2.1.196 至 2.1.199 在這些工作區中將您自己的 `.claude/settings.local.json` 視為儲存庫提供的。在 v2.1.207 及更新版本上,如果您尚未信任該資料夾,在 git 儲存庫外更新是不夠的:判斷資料夾是否在儲存庫內會執行 git,而 Claude Code 只在您接受信任對話框後才執行該檢查,因此請使用第一步。您的主目錄和任何其他[設定主目錄](/docs/zh-TW/permissions#project-allow-rules-and-workspace-trust)都被豁免,不需要等待對話框。請參閱[專案允許規則和工作區信任](/docs/zh-TW/permissions#project-allow-rules-and-workspace-trust)。4236
4237在 v2.1.257 之前,`claude doctor` 未標記這些檔案;較早版本在工作階段被殺死時留下相同的佔位符。
1391 4238
1392<h2 id="responses-seem-lower-quality-than-usual">4239<h2 id="responses-seem-lower-quality-than-usual">
1393 回應品質似乎低於預期4240 回應品質似乎低於預期
1398 4244
1399* 配置的 [`--fallback-model`](/docs/zh-TW/cli-reference#cli-flags) 在可用性錯誤後接管該輪次,並在文字記錄中顯示通知4245* 配置的 [`--fallback-model`](/docs/zh-TW/cli-reference#cli-flags) 在可用性錯誤後接管該輪次,並在文字記錄中顯示通知
1400* Amazon Bedrock 或 Google Cloud 的 Agent Platform 啟動檢查發現您的預設模型不可用4246* Amazon Bedrock 或 Google Cloud 的 Agent Platform 啟動檢查發現您的預設模型不可用
1401* [自動模型備用](/docs/zh-TW/model-config#automatic-model-fallback)在 Fable 5 上將工作階段移至預設 Opus 模型,並在文字記錄中顯示通知4247* [自動模型備用](/docs/zh-TW/model-config#automatic-model-fallback)在 Fable 5.1、Fable 5 和 Opus 5 上將工作階段移至標記類別的備用模型(當該類別有備用模型時),並在文字記錄中顯示通知
1402 4248
1403下面的模型選擇檢查可捕捉第二和第三種情況;第一種情況顯示為文字記錄通知而非 `/model` 變更。[模型配置](/docs/zh-TW/model-config)說明每個備用何時適用。4249下面的模型選擇檢查可以捕捉第二和第三種情況;第一種情況顯示為文字記錄通知而非 `/model` 變更。[模型設定](/docs/zh-TW/model-config)說明每個備用何時適用。
1404 4250
1405首先檢查這些項目:4251首先檢查這些項目:
1406 4252
1407* **模型選擇**:執行 `/model` 以確認您使用的是預期的模型。先前的 `/model` 選擇或 `ANTHROPIC_MODEL` 環境變數可能使您使用的模型比預期的要小。4253* **模型選擇**:執行 `/model` 以確認您在預期的模型上。先前的 `/model` 選擇或 `ANTHROPIC_MODEL` 環境變數可能使您在比預期更小的模型上。
1408* **努力程度**:執行 `/effort` 以檢查目前的推理級別,並針對困難的除錯或設計工作提高它。預設值因模型而異,因此在假設您低於最大值之前請先檢查。請參閱[調整努力程度](/docs/zh-TW/model-config#adjust-effort-level)以了解每個模型的預設值和 `ultrathink` 快捷方式。4254* **努力程度**:執行 `/effort` 以檢查目前的推理程度,並為困難的除錯或設計工作提高它。預設值因模型而異,所以在假設您低於最大值之前請先檢查。請參閱[調整努力程度](/docs/zh-TW/model-config#adjust-effort-level)以了解每個模型的預設值和 `ultrathink` 快捷方式。
1409* **上下文壓力**:執行 `/context` 以查看視窗的滿度。如果接近容量,請在自然中斷點執行 `/compact` 或執行 `/clear` 以重新開始。請參閱[探索上下文視窗](/docs/zh-TW/context-window)以了解自動壓縮如何影響較早的輪次。4255* **上下文壓力**:執行 `/context` 以查看視窗有多滿。如果接近容量,請在自然斷點執行 `/compact` 或執行 `/clear` 以重新開始。請參閱[探索上下文視窗](/docs/zh-TW/context-window)以了解自動壓縮如何影響較早的輪次。
1410* **過時的指示**:大型或過時的 `CLAUDE.md` 檔案和 MCP 工具定義會消耗上下文,並可能引導回應。`/doctor` 檢查會標記超大記憶體檔案和未使用的擴充功能,而 `/context` 會顯示 MCP 工具令牌使用情況。在 v2.1.205 之前,`/doctor` 開啟診斷畫面,標記超大記憶體檔案和子代理定義。4256* **過時的指示**:大型或過時的 `CLAUDE.md` 檔案和 MCP 工具定義會消耗上下文並可能引導回應。`/doctor` 檢查會標記超大的記憶檔案和未使用的擴充功能,而 `/context` 會顯示 MCP 工具的權杖使用情況。在 v2.1.205 之前,`/doctor` 開啟了一個診斷畫面,標記超大的記憶檔案和子代理定義。
1411 4257
1412當回應出錯時,回溯通常比用更正回覆效果更好。按 Esc 兩次或執行 `/rewind` 以回到不良輪次之前,然後用更具體的內容重新表述提示。在執行緒中更正會將錯誤的嘗試保留在上下文中,這可能會將後續答案錨定到它。請參閱[檢查點](/docs/zh-TW/checkpointing)。4258當回應出錯時,回溯通常比用更正回覆效果更好。按 Esc 兩次或執行 `/rewind` 以回到不良輪次之前,然後用更多細節重新表述提示。在執行緒中更正會將錯誤的嘗試保留在上下文中,這可能會將後來的答案錨定到它。請參閱[檢查點](/docs/zh-TW/checkpointing)。
1413 4259
1414如果在檢查上述項目後品質仍然似乎不對,請執行 `/feedback` 並描述您預期的內容與您得到的內容。以這種方式提交的回饋包括對話文字記錄,這是 Anthropic 診斷真實回歸的最快方式。如果 `/feedback` 在您的環境中不可用,請參閱[報告錯誤](#report-an-error)。4260如果在檢查上述項目後品質仍然似乎有問題,請執行 `/feedback` 並描述您預期的內容與您得到的內容。以這種方式提交的回饋包括對話文字記錄,這是 Anthropic 診斷真實迴歸的最快方式。如果 `/feedback` 在您的環境中不可用,請參閱[報告錯誤](#report-an-error)。
1415 4261
1416如果 Claude 警告懷疑提示注入,或因懷疑注入而拒絕請求,而警告命名的文字是 Claude Code 自動添加到對話中的上下文而非檔案或網路內容,請執行 `claude update` 並重試。如果更新後警告重複出現,請[報告它](#report-an-error)而不是將標記的內容貼回提示中。在 v2.1.201 之前,Sonnet 5 以相同方式拒絕了某些請求。4262如果 Claude 警告懷疑提示注入,或因懷疑注入而拒絕請求,而警告命名的文字是 Claude Code 自動添加到對話中的上下文而非檔案或網路內容,請執行 `claude update` 並重試。如果更新後警告重複出現,請[報告它](#report-an-error)而不是將標記的內容貼回提示中。在 v2.1.201 之前,Sonnet 5 以相同方式拒絕了一些請求。
1417 4263
1418<h2 id="report-an-error">4264<h2 id="report-an-error">
1419 回報錯誤4265 回報錯誤