claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] Setting DISABLE_PROMPT_CACHING Environment Variable Causes 401 Unauthorized Errors

Open Q00 opened this issue 4 months ago โ€ข 6 comments

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When the environment variable DISABLE_PROMPT_CACHING is set, the Claude Code extension fails to authenticate, resulting in a 401 Unauthorized error. Unsetting this environment variable immediately resolves the issue.

This behavior is unexpected because a feature flag for caching should not interfere with the authentication flow. Furthermore, this environment variable appears to be undocumented, making the issue difficult to diagnose.

What Should Happen?

Setting DISABLE_PROMPT_CACHING=true should disable prompt caching as intended, without affecting the user's authentication status. All commands should execute normally after a successful login.

Error Messages/Logs

API Error: 401 {"type":"error","error":{"type":"authentication_error","message":"OAuth authentication is currently not 
     supported."},"request_id":"req_011CTgM7o63aV9K39BERJn7c"} ยท Please run /login

The Debug log is below.

[ERROR] SyntaxError: SyntaxError: JSON Parse error: Unexpected identifier "API"
    at <parse> (:0)
    at parse (unknown)
    at <anonymous> (/$bunfs/root/claude:568:9937)
    at W (/$bunfs/root/claude:534:13292)
    at tFG (/$bunfs/root/claude:896:37032)
    at processTicksAndRejections (native:7:39)
[ERROR] Error in non-streaming fallback: 401 {"type":"error","error":{"type":"authentication_error","message":"OAuth authentication is currently not supported."},"request_id":"req_011CTgLuT9f6gsMsASFAMVqk"}
[ERROR] Error: Error: 401 {"type":"error","error":{"type":"authentication_error","message":"OAuth authentication is currently not supported."},"request_id":"req_011CTgLuT9f6gsMsASFAMVqk"}
    at new W5 (unknown:1:28)
    at new _Y (/$bunfs/root/claude:716:20515)
    at new jv (unknown:1:28)
    at generate (/$bunfs/root/claude:716:21006)
    at makeRequest (/$bunfs/root/claude:871:5359)
    at processTicksAndRejections (native:7:39)

Steps to Reproduce

In your terminal, set the environment variable:

export DISABLE_PROMPT_CACHING=true

Launch or restart Claude code from the same terminal session to ensure it inherits the environment variable.

Attempt to use any Claude Code command that requires authentication (e.g., /edit, /fix, or starting a new chat).

Observe the 401 Unauthorized error.

Claude Model

Sonnet (default)

Is this a regression?

Yes, this worked in a previous version

Last Working Version

1.0.88

Claude Code Version

2.0.1

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Warp

Additional Information

Image

You can just check the command "unset" and then it works. 404 error is not important.

Q00 avatar Oct 01 '25 11:10 Q00

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/6078
  2. https://github.com/anthropics/claude-code/issues/7855
  3. https://github.com/anthropics/claude-code/issues/4187

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and ๐Ÿ‘ the existing issue instead
  • To prevent auto-closure, add a comment or ๐Ÿ‘Ž this comment

๐Ÿค– Generated with Claude Code

github-actions[bot] avatar Oct 01 '25 11:10 github-actions[bot]

Are you still seeing this issue?

Which model are you using? Are you using first-party or Bedrock?

ant-kurt avatar Oct 07 '25 00:10 ant-kurt

Also - we're updating our documentation around the prompt caching environment variables. We have added DISABLE_PROMPT_CACHING_HAIKU, DISABLE_PROMPT_CACHING_SONNET, and DISABLE_PROMPT_CACHING_OPUS, which can be useful for older models that may not support this setting.

ant-kurt avatar Oct 10 '25 03:10 ant-kurt

I have the same issue - setting DISABLE_PROMPT_CACHING=true will cause a 401 error when restarting Claude and trying any prompt. The model setting is default (Sonnet 4.5), so that doesn't seem related.

eladroz avatar Oct 12 '25 14:10 eladroz

@ant-kurt

Are you still seeing this issue?

Which model are you using? Are you using first-party or Bedrock?

It is okay now with first-party when I unset all the variables that I used to use with Bedrock. As @eladroz said, this issue doesn't seem to be related to specific models.

Q00 avatar Oct 14 '25 05:10 Q00

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

github-actions[bot] avatar Dec 07 '25 10:12 github-actions[bot]

@ant-kurt Hi! Just checking in - are there any updates on this issue? Happy to help test or provide more details if needed.

Q00 avatar Dec 19 '25 02:12 Q00