[GH-ISSUE #3] Error in sandbox mode in Claude Code #3

Closed
opened 2026-02-27 07:17:18 +03:00 by kerem · 13 comments
Owner

Originally created by @lonestike on GitHub (Dec 14, 2025).
Original GitHub issue: https://github.com/jwadow/kiro-gateway/issues/3

Originally assigned to: @jwadow on GitHub.

working with Claude Code router, I have this error when running in sandbox mode (working fine in normal mode)

in Claude Code:

API Error: 400 {"error":{"message":"Error from provider(proxy - Kiro ide redirected,claude-opus-4-5: 400): {\"message\":\"Improperly formed 
    request.\",\"reason\":null}Error: Error from provider(proxy - Kiro ide redirected,claude-opus-4-5: 400): {\"message\":\"Improperly formed 
    request.\",\"reason\":null}\n    at nt (/opt/homebrew/lib/node_modules/@musistudio/claude-code-router/dist/cli.js:79940:11)\n    at p0 
    (/opt/homebrew/lib/node_modules/@musistudio/claude-code-router/dist/cli.js:80000:11)\n    at process.processTicksAndRejections 
    (node:internal/process/task_queues:105:5)\n    at async f0 
    (/opt/homebrew/lib/node_modules/@musistudio/claude-code-router/dist/cli.js:79965:96)","type":"api_error","code":"provider_response_error"}}

log of the python file:

2025-12-14 19:18:23 | ERROR    | kiro_gateway.routes:chat_completions:259 - Error from Kiro API: 400 - {"message":"Improperly formed request.","reason":null}
INFO:     127.0.0.1:61624 - "POST /v1/chat/completions HTTP/1.1" 400 Bad Request

Originally created by @lonestike on GitHub (Dec 14, 2025). Original GitHub issue: https://github.com/jwadow/kiro-gateway/issues/3 Originally assigned to: @jwadow on GitHub. working with [Claude Code router](https://github.com/musistudio/claude-code-router), I have this error when running in sandbox mode (working fine in normal mode) in Claude Code: ``` API Error: 400 {"error":{"message":"Error from provider(proxy - Kiro ide redirected,claude-opus-4-5: 400): {\"message\":\"Improperly formed request.\",\"reason\":null}Error: Error from provider(proxy - Kiro ide redirected,claude-opus-4-5: 400): {\"message\":\"Improperly formed request.\",\"reason\":null}\n at nt (/opt/homebrew/lib/node_modules/@musistudio/claude-code-router/dist/cli.js:79940:11)\n at p0 (/opt/homebrew/lib/node_modules/@musistudio/claude-code-router/dist/cli.js:80000:11)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n at async f0 (/opt/homebrew/lib/node_modules/@musistudio/claude-code-router/dist/cli.js:79965:96)","type":"api_error","code":"provider_response_error"}} ``` log of the python file: ``` 2025-12-14 19:18:23 | ERROR | kiro_gateway.routes:chat_completions:259 - Error from Kiro API: 400 - {"message":"Improperly formed request.","reason":null} INFO: 127.0.0.1:61624 - "POST /v1/chat/completions HTTP/1.1" 400 Bad Request ```
kerem 2026-02-27 07:17:18 +03:00
Author
Owner

@zeroaddresss commented on GitHub (Dec 14, 2025):

how do you use it with claude code? @lonestike @jwadow

<!-- gh-comment-id:3651990668 --> @zeroaddresss commented on GitHub (Dec 14, 2025): how do you use it with claude code? @lonestike @jwadow
Author
Owner

@lonestike commented on GitHub (Dec 14, 2025):

how do you use it with claude code? @lonestike @jwadow

you use claude code router to redirect the model used in claude code to the url provided by this project

<!-- gh-comment-id:3652008247 --> @lonestike commented on GitHub (Dec 14, 2025): > how do you use it with claude code? [@lonestike](https://github.com/lonestike) [@jwadow](https://github.com/jwadow) you use claude code router to redirect the model used in claude code to the url provided by this project
Author
Owner

@jwadow commented on GitHub (Dec 14, 2025):

sandbox mode

thanks for feedback.
i'm not familiar with "sandbox mode" in ccr. i installed it for the first time about 10 minutes ago, maybe I don’t know something.
what is it and how to enable it?

<!-- gh-comment-id:3652033082 --> @jwadow commented on GitHub (Dec 14, 2025): > sandbox mode thanks for feedback. i'm not familiar with "sandbox mode" in ccr. i installed it for the first time about 10 minutes ago, maybe I don’t know something. what is it and how to enable it?
Author
Owner

@lonestike commented on GitHub (Dec 14, 2025):

ccr doesn't change anything for Claude Code, it's just to route the queries from Claude Code to other urls (the great thing is that it leverages the usage of Claude Code with other models)
so when you are using Claude Code, you call /sandbox and it allows filesystem and network isolation
https://code.claude.com/docs/en/sandboxing

<!-- gh-comment-id:3652060321 --> @lonestike commented on GitHub (Dec 14, 2025): ccr doesn't change anything for Claude Code, it's just to route the queries from Claude Code to other urls (the great thing is that it leverages the usage of Claude Code with other models) so when you are using Claude Code, you call `/sandbox` and it allows filesystem and network isolation https://code.claude.com/docs/en/sandboxing
Author
Owner

@zeroaddresss commented on GitHub (Dec 14, 2025):

how do you use it with claude code? @lonestike @jwadow

you use claude code router to redirect the model used in claude code to the url provided by this project

can you please attach a minimal ~/.claude-code-router/config.jsonexample to use Opus 4.5 via proxy?
i'm missing something and traffic is not being redirected correctly. thanks in advance

<!-- gh-comment-id:3652078217 --> @zeroaddresss commented on GitHub (Dec 14, 2025): > > how do you use it with claude code? [@lonestike](https://github.com/lonestike) [@jwadow](https://github.com/jwadow) > > you use claude code router to redirect the model used in claude code to the url provided by this project can you please attach a minimal `~/.claude-code-router/config.json`example to use Opus 4.5 via proxy? i'm missing something and traffic is not being redirected correctly. thanks in advance
Author
Owner

@lonestike commented on GitHub (Dec 14, 2025):

of course, this should do it

{
  "LOG": true,
  "LOG_LEVEL": "debug",
  "CLAUDE_PATH": "",
  "HOST": "127.0.0.1",
  "PORT": 3456,
  "APIKEY": "",
  "API_TIMEOUT_MS": "600000",
  "PROXY_URL": "",
  "transformers": [],
  "Providers": [
    {
      "name": "proxy - Kiro ide redirected",
      "api_base_url": "http://0.0.0.0:8004/v1/chat/completions",
      "api_key": "my-super-secret-password-123",
      "models": [
        "claude-sonnet-4-5",
        "claude-opus-4-5"
      ]
    }
  ],
  "StatusLine": {
    "enabled": true,
    "currentStyle": "default",
    "default": {
      "modules": []
    },
    "powerline": {
      "modules": []
    }
  },
  "Router": {
    "default": "proxy - Kiro ide redirected,claude-opus-4-5",
    "background": "proxy - Kiro ide redirected,claude-opus-4-5",
    "think": "proxy - Kiro ide redirected,claude-opus-4-5",
    "longContext": "proxy - Kiro ide redirected,claude-opus-4-5",
    "longContextThreshold": 200000,
    "webSearch": "proxy - Kiro ide redirected,claude-opus-4-5",
    "image": ""
  },
  "CUSTOM_ROUTER_PATH": ""
}
<!-- gh-comment-id:3652100830 --> @lonestike commented on GitHub (Dec 14, 2025): of course, this should do it ``` { "LOG": true, "LOG_LEVEL": "debug", "CLAUDE_PATH": "", "HOST": "127.0.0.1", "PORT": 3456, "APIKEY": "", "API_TIMEOUT_MS": "600000", "PROXY_URL": "", "transformers": [], "Providers": [ { "name": "proxy - Kiro ide redirected", "api_base_url": "http://0.0.0.0:8004/v1/chat/completions", "api_key": "my-super-secret-password-123", "models": [ "claude-sonnet-4-5", "claude-opus-4-5" ] } ], "StatusLine": { "enabled": true, "currentStyle": "default", "default": { "modules": [] }, "powerline": { "modules": [] } }, "Router": { "default": "proxy - Kiro ide redirected,claude-opus-4-5", "background": "proxy - Kiro ide redirected,claude-opus-4-5", "think": "proxy - Kiro ide redirected,claude-opus-4-5", "longContext": "proxy - Kiro ide redirected,claude-opus-4-5", "longContextThreshold": 200000, "webSearch": "proxy - Kiro ide redirected,claude-opus-4-5", "image": "" }, "CUSTOM_ROUTER_PATH": "" } ```
Author
Owner

@jwadow commented on GitHub (Dec 14, 2025):

ccr doesn't change anything for Claude Code, it's just to route the queries from Claude Code to other urls (the great thing is that it leverages the usage of Claude Code with other models) so when you are using Claude Code, you call /sandbox and it allows filesystem and network isolation https://code.claude.com/docs/en/sandboxing

How do you get around your "Improperly formed request" error? Is it constant or occasional?
In my case chat and tools working.

I tried:

  • Mode: Sandbox BashTool, with auto-allow
  • Overrides: Strict sandbox mode (also tried Allow unsandboxed fallback)
Image
<!-- gh-comment-id:3652130961 --> @jwadow commented on GitHub (Dec 14, 2025): > ccr doesn't change anything for Claude Code, it's just to route the queries from Claude Code to other urls (the great thing is that it leverages the usage of Claude Code with other models) so when you are using Claude Code, you call `/sandbox` and it allows filesystem and network isolation https://code.claude.com/docs/en/sandboxing How do you get around your "Improperly formed request" error? Is it constant or occasional? In my case chat and tools working. I tried: - Mode: Sandbox BashTool, with auto-allow - Overrides: Strict sandbox mode (also tried Allow unsandboxed fallback) <img width="663" height="647" alt="Image" src="https://github.com/user-attachments/assets/a4bb33d7-236e-4967-bf9e-946547b6cdf0" />
Author
Owner

@lonestike commented on GitHub (Dec 14, 2025):

How do you get around your "Improperly formed request" error? Is it constant or occasional?

no I have it every time
Claude Code v2.0.69

and it works again as soon as sandbox is disabled

<!-- gh-comment-id:3652134300 --> @lonestike commented on GitHub (Dec 14, 2025): > How do you get around your "Improperly formed request" error? Is it constant or occasional? no I have it every time Claude Code v2.0.69 and it works again as soon as sandbox is disabled
Author
Owner

@jwadow commented on GitHub (Dec 14, 2025):

@jwadow can you update the README with a guide on how to use the proxy to work with Claude Code please? use Opus 4.5 as an example

Unfortunately, this isn't relevant to the project; it's about third-party app settings. I could, of course, but then I'd have to add guides for a bunch of other programs. Basically, you can search for it on Google; the main thing is to specify the correct ip:port of kiro gateway

<!-- gh-comment-id:3652143218 --> @jwadow commented on GitHub (Dec 14, 2025): > [@jwadow](https://github.com/jwadow) can you update the README with a guide on how to use the proxy to work with Claude Code please? use Opus 4.5 as an example Unfortunately, this isn't relevant to the project; it's about third-party app settings. I could, of course, but then I'd have to add guides for a bunch of other programs. Basically, you can search for it on Google; the main thing is to specify the correct ip:port of kiro gateway
Author
Owner

@jwadow commented on GitHub (Dec 14, 2025):

How do you get around your "Improperly formed request" error? Is it constant or occasional?

no I have it every time Claude Code v2.0.69

and it works again as soon as sandbox is disabled

I can't reproduce the error. Maybe you have custom tools or prompt or something?
I need this from you:

  • Enable in .env:
LOG_LEVEL="DEBUG"
DEBUG_LAST_REQUEST=true
DEBUG_DIR="debug_logs"
  • Restart gateway

  • When error occurs:

  1. immediately terminate (ctrl+c) the kiro gateway, so that debugged requests files are not overwritten by new ones
  2. copy full log from terminal and send it to me
  3. give me 2 json files from debug_logs: kiro_request_body.json and request_body.json

I might be able to find and fix it, but I can't promise anything. The process might be iterative, since I can't reproduce the error.

<!-- gh-comment-id:3652150105 --> @jwadow commented on GitHub (Dec 14, 2025): > > How do you get around your "Improperly formed request" error? Is it constant or occasional? > > no I have it every time Claude Code v2.0.69 > > and it works again as soon as sandbox is disabled I can't reproduce the error. Maybe you have custom tools or prompt or something? I need this from you: - Enable in `.env`: ``` LOG_LEVEL="DEBUG" DEBUG_LAST_REQUEST=true DEBUG_DIR="debug_logs" ``` - Restart gateway - When error occurs: 1. immediately terminate (ctrl+c) the kiro gateway, so that debugged requests files are not overwritten by new ones 2. copy full log from terminal and send it to me 3. give me 2 json files from debug_logs: `kiro_request_body.json` and `request_body.json` I might be able to find and fix it, but I can't promise anything. The process might be iterative, since I can't reproduce the error.
Author
Owner

@lonestike commented on GitHub (Dec 15, 2025):

yes, here are the files

kiro_request_body.json
request_body.json

<!-- gh-comment-id:3654132836 --> @lonestike commented on GitHub (Dec 15, 2025): yes, here are the files [kiro_request_body.json](https://github.com/user-attachments/files/24159858/kiro_request_body.json) [request_body.json](https://github.com/user-attachments/files/24159859/request_body.json)
Author
Owner

@jwadow commented on GitHub (Dec 15, 2025):

yes, here are the files

kiro_request_body.json request_body.json

I took the most direct approach - I simply sent your entire request to the gateway; there was no error. This means you have:

  1. An outdated version of the project (or modified)
  2. You reassigned the TOOL_DESCRIPTION_MAX_LENGTH parameter in .env to something higher than 10000 (just delete this line in .env)

The situation seems mystical (there's no such thing as magic). My Claude Code Router works with any settings, and even your broken request works perfectly. This means the problem is with your Kiro Gateway; I have no other explanation.

<!-- gh-comment-id:3655802547 --> @jwadow commented on GitHub (Dec 15, 2025): > yes, here are the files > > [kiro_request_body.json](https://github.com/user-attachments/files/24159858/kiro_request_body.json) [request_body.json](https://github.com/user-attachments/files/24159859/request_body.json) I took the most direct approach - I simply sent your entire request to the gateway; there was no error. This means you have: 1) An outdated version of the project (or modified) 2) You reassigned the `TOOL_DESCRIPTION_MAX_LENGTH` parameter in `.env` to something higher than 10000 (just delete this line in `.env`) The situation seems mystical (there's no such thing as magic). My Claude Code Router works with any settings, and even your broken request works perfectly. This means the problem is with your Kiro Gateway; I have no other explanation.
Author
Owner

@jwadow commented on GitHub (Dec 17, 2025):

@lonestike Hey! Just released v1.0.4 which fixes a bug with tool_calls being lost during message merging.

This might fix your sandbox mode issue — when Claude Code sends multiple assistant messages with tool_calls consecutively, the gateway was losing some of them, causing {"message":"Improperly formed request.","reason":null}.

Worth trying:

  1. Update to v1.0.4: https://github.com/jwadow/kiro-openai-gateway/releases/latest
  2. Test sandbox mode again

New debugging feature — if it still fails, use:

DEBUG_MODE=errors  # Only saves logs when requests fail

Let me know if it helps! If not, attach the debug files, i'll reopen issue and we'll investigate further.

<!-- gh-comment-id:3663708408 --> @jwadow commented on GitHub (Dec 17, 2025): @lonestike Hey! Just released **v1.0.4** which fixes a bug with tool_calls being lost during message merging. This *might* fix your sandbox mode issue — when Claude Code sends multiple assistant messages with tool_calls consecutively, the gateway was losing some of them, causing `{"message":"Improperly formed request.","reason":null}`. **Worth trying:** 1. Update to v1.0.4: https://github.com/jwadow/kiro-openai-gateway/releases/latest 2. Test sandbox mode again **New debugging feature** — if it still fails, use: ```env DEBUG_MODE=errors # Only saves logs when requests fail ``` Let me know if it helps! If not, attach the debug files, i'll reopen issue and we'll investigate further.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/kiro-gateway-jwadow#3
No description provided.