[GH-ISSUE #2] Struggling to work with OpenCode #2

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

Originally created by @Ry-DS on GitHub (Dec 13, 2025).
Original GitHub issue: https://github.com/jwadow/kiro-gateway/issues/2

Hey!

I am trying to use this with OpenCode, with the following:

{
    "$schema": "https://opencode.ai/config.json",
    "provider": {
        "Kiro": {
            "npm": "@ai-sdk/openai-compatible",
            "name": "Kiro",
            "options": {
                "baseURL": "http://127.0.0.1:8000/v1",
                "headers": {
                    "Authorization": "Bearer password"
                }
            },
            "models": {
                "claude-opus-4-5": {
                    "name": "claude-opus-4-5"
                }
            }
        }
    }
}

with

PROXY_API_KEY="password"
KIRO_CREDS_FILE="~/.aws/sso/cache/kiro-auth-token.json"

and I seem to connect fine, but the server is giving

2025-12-14 00:41:51 | INFO     | kiro_gateway.routes:chat_completions:195 - Request to /v1/chat/completions (model=claude-opus-4-5, stream=True)
2025-12-14 00:41:51 | DEBUG    | kiro_gateway.debug_logger:prepare_new_request:63 - [DebugLogger] Directory debug_logs cleared for new request.
2025-12-14 00:41:51 | DEBUG    | kiro_gateway.routes:chat_completions:214 - Model cache is empty, skipping forced population
INFO:     127.0.0.1:51306 - "POST /v1/chat/completions HTTP/1.1" 400 Bad Request
2025-12-14 00:41:52 | ERROR    | kiro_gateway.routes:chat_completions:258 - Error from Kiro API: 400 - {"message":"Improperly formed request.","reason":null}

I feel like open code is using the API in unintended ways, or they changed something recently. What are some breadcrumbs to dig more into this?

Originally created by @Ry-DS on GitHub (Dec 13, 2025). Original GitHub issue: https://github.com/jwadow/kiro-gateway/issues/2 Hey! I am trying to use this with OpenCode, with the following: ``` { "$schema": "https://opencode.ai/config.json", "provider": { "Kiro": { "npm": "@ai-sdk/openai-compatible", "name": "Kiro", "options": { "baseURL": "http://127.0.0.1:8000/v1", "headers": { "Authorization": "Bearer password" } }, "models": { "claude-opus-4-5": { "name": "claude-opus-4-5" } } } } } ``` with ``` PROXY_API_KEY="password" KIRO_CREDS_FILE="~/.aws/sso/cache/kiro-auth-token.json" ``` and I seem to connect fine, but the server is giving ``` 2025-12-14 00:41:51 | INFO | kiro_gateway.routes:chat_completions:195 - Request to /v1/chat/completions (model=claude-opus-4-5, stream=True) 2025-12-14 00:41:51 | DEBUG | kiro_gateway.debug_logger:prepare_new_request:63 - [DebugLogger] Directory debug_logs cleared for new request. 2025-12-14 00:41:51 | DEBUG | kiro_gateway.routes:chat_completions:214 - Model cache is empty, skipping forced population INFO: 127.0.0.1:51306 - "POST /v1/chat/completions HTTP/1.1" 400 Bad Request 2025-12-14 00:41:52 | ERROR | kiro_gateway.routes:chat_completions:258 - Error from Kiro API: 400 - {"message":"Improperly formed request.","reason":null} ``` I feel like open code is using the API in unintended ways, or they changed something recently. What are some breadcrumbs to dig more into this?
kerem 2026-02-27 07:17:18 +03:00
  • closed this issue
  • added the
    bug
    fixed
    labels
Author
Owner

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

It's weird, because I already released a fix v1.0.1: https://github.com/jwadow/kiro-openai-gateway/releases/tag/v1.0.1

Are you sure that are you using v1.0.1?

The initial problem was that OpenCode was passing an inappropriately long "description" in the tool description. In release 1.0.1, I fixed this issue by detecting such long strings and moving them to system_prompt as the most logical and non-destructive solution.

If you are absolutely sure that you have the current version of the repository, then starting from version 1.0.1 the parameter is available in .env TOOL_DESCRIPTION_MAX_LENGTH which default equals to 10000 (10k).

Try playing with this value by adding it to .env. For example, 8000 to start, then try 5000.
TOOL_DESCRIPTION_MAX_LENGTH=8000
Restart the script every time you change .env.

I'm looking for feedback about your version and the resulting values.

<!-- gh-comment-id:3649497472 --> @jwadow commented on GitHub (Dec 13, 2025): It's weird, because I already released a fix v1.0.1: https://github.com/jwadow/kiro-openai-gateway/releases/tag/v1.0.1 Are you sure that are you using v1.0.1? The initial problem was that OpenCode was passing an inappropriately long "description" in the tool description. In release 1.0.1, I fixed this issue by detecting such long strings and moving them to system_prompt as the most logical and non-destructive solution. If you are absolutely sure that you have the current version of the repository, then starting from version 1.0.1 the parameter is available in .env `TOOL_DESCRIPTION_MAX_LENGTH` which default equals to 10000 (10k). Try playing with this value by adding it to .env. For example, 8000 to start, then try 5000. `TOOL_DESCRIPTION_MAX_LENGTH=8000` Restart the script every time you change .env. I'm looking for feedback about your version and the resulting values.
Author
Owner

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

I get the same issue:
2025-12-13 17:46:53 | ERROR | kiro_gateway.routes:chat_completions:258 - Error from Kiro API: 400 - {"message":"Improperly formed request.","reason":null}
INFO: 127.0.0.1:50300 - "POST /v1/chat/completions HTTP/1.1" 400 Bad Request

I'm on version 1.0.1

<!-- gh-comment-id:3649557483 --> @lonestike commented on GitHub (Dec 13, 2025): I get the same issue: 2025-12-13 17:46:53 | ERROR | kiro_gateway.routes:chat_completions:258 - Error from Kiro API: 400 - {"message":"Improperly formed request.","reason":null} INFO: 127.0.0.1:50300 - "POST /v1/chat/completions HTTP/1.1" 400 Bad Request I'm on version 1.0.1
Author
Owner

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

I'm on version 1.0.1

Did you tried to set this on .env?
TOOL_DESCRIPTION_MAX_LENGTH=8000
Or maybe?
TOOL_DESCRIPTION_MAX_LENGTH=5000

Set less than 10000

P.S. Restart the script every time you change .env.

If it works with lower values, let me know.

<!-- gh-comment-id:3649675221 --> @jwadow commented on GitHub (Dec 13, 2025): > I'm on version 1.0.1 Did you tried to set this on .env? `TOOL_DESCRIPTION_MAX_LENGTH=8000` Or maybe? `TOOL_DESCRIPTION_MAX_LENGTH=5000` Set less than 10000 P.S. Restart the script every time you change .env. If it works with lower values, let me know.
Author
Owner

@spermajohn737-web commented on GitHub (Dec 13, 2025):

i got other issue only in opencode, when it toolcalls it errors this

read our project

AI_TypeValidationError: Type validation failed: Value: {"id":"chatcmpl-5663be9b13d84ce18870e63607cb47cf","object":"chat.completion.chunk","created":1765654694,"model":"claude-opus-4-5-20251101","choices":[{"index":0,"delta":{"tool_calls":[{"id":"tooluse_AGJElOptTv2g2gVx4AGs5A","type":"function","function":{"name":"list","arguments":"{\"path\": \"C:\\\\Users\\\\1\\\\Desktop\\\\aitest\"}"}},{"id":"tooluse_AGJElOptTv2g2gVx4AGs5A","type":"function","function":{"name":"list","arguments":""}}]},"finish_reason":null}]}.
Error message: [{"code":"invalid_union","errors":[[{"expected":"number","code":"invalid_type","path":["choices",0,"delta","tool_calls",0,"index"],"message":"Invalid input: expected number, received undefined"},{"expected":"number","code":"invalid_type","path":["choices",0,"delta","tool_calls",1,"index"],"message":"Invalid input: expected number, received undefined"}],[{"expected":"object","code":"invalid_type","path":["error"],"message":"Invalid input: expected object, received undefined"}]],"path":[],"message":"Invalid input"}]
▣  Build · claude-opus-4-5-20251101

server response

2025-12-13 22:40:55 | INFO     | kiro_gateway.routes:chat_completions:195 - Request to /v1/chat/completions (model=claude-opus-4-5-20251101, stream=True)
2025-12-13 22:40:55 | DEBUG    | kiro_gateway.routes:chat_completions:214 - Model cache is empty, skipping forced population
2025-12-13 22:40:55 | INFO     | kiro_gateway.converters:process_tools_with_long_descriptions:255 - Tool 'bash' has long description (10622 chars > 10000), moving to system prompt
2025-12-13 22:40:55 | DEBUG    | kiro_gateway.converters:merge_adjacent_messages:118 - Merged adjacent messages with role user
2025-12-13 22:40:55 | DEBUG    | kiro_gateway.converters:merge_adjacent_messages:118 - Merged adjacent messages with role user
INFO:     127.0.0.1:28632 - "POST /v1/chat/completions HTTP/1.1" 200 OK
2025-12-13 22:41:01 | DEBUG    | kiro_gateway.streaming:stream_kiro_to_openai:183 - Streaming completed

<!-- gh-comment-id:3649744964 --> @spermajohn737-web commented on GitHub (Dec 13, 2025): i got other issue only in opencode, when it toolcalls it errors this ``` read our project AI_TypeValidationError: Type validation failed: Value: {"id":"chatcmpl-5663be9b13d84ce18870e63607cb47cf","object":"chat.completion.chunk","created":1765654694,"model":"claude-opus-4-5-20251101","choices":[{"index":0,"delta":{"tool_calls":[{"id":"tooluse_AGJElOptTv2g2gVx4AGs5A","type":"function","function":{"name":"list","arguments":"{\"path\": \"C:\\\\Users\\\\1\\\\Desktop\\\\aitest\"}"}},{"id":"tooluse_AGJElOptTv2g2gVx4AGs5A","type":"function","function":{"name":"list","arguments":""}}]},"finish_reason":null}]}. Error message: [{"code":"invalid_union","errors":[[{"expected":"number","code":"invalid_type","path":["choices",0,"delta","tool_calls",0,"index"],"message":"Invalid input: expected number, received undefined"},{"expected":"number","code":"invalid_type","path":["choices",0,"delta","tool_calls",1,"index"],"message":"Invalid input: expected number, received undefined"}],[{"expected":"object","code":"invalid_type","path":["error"],"message":"Invalid input: expected object, received undefined"}]],"path":[],"message":"Invalid input"}] ▣ Build · claude-opus-4-5-20251101 ``` server response ``` 2025-12-13 22:40:55 | INFO | kiro_gateway.routes:chat_completions:195 - Request to /v1/chat/completions (model=claude-opus-4-5-20251101, stream=True) 2025-12-13 22:40:55 | DEBUG | kiro_gateway.routes:chat_completions:214 - Model cache is empty, skipping forced population 2025-12-13 22:40:55 | INFO | kiro_gateway.converters:process_tools_with_long_descriptions:255 - Tool 'bash' has long description (10622 chars > 10000), moving to system prompt 2025-12-13 22:40:55 | DEBUG | kiro_gateway.converters:merge_adjacent_messages:118 - Merged adjacent messages with role user 2025-12-13 22:40:55 | DEBUG | kiro_gateway.converters:merge_adjacent_messages:118 - Merged adjacent messages with role user INFO: 127.0.0.1:28632 - "POST /v1/chat/completions HTTP/1.1" 200 OK 2025-12-13 22:41:01 | DEBUG | kiro_gateway.streaming:stream_kiro_to_openai:183 - Streaming completed ```
Author
Owner

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

Fixed in v1.0.2! 🎉

The 400 'Improperly formed request' error (and others) with OpenCode has been resolved.
At least I didn't encounter any errors in OpenCode, I called tools, created files, read directories, etc.

Please update to the latest version and let me know if you still experience any issues.

Release: https://github.com/jwadow/kiro-openai-gateway/releases/tag/v1.0.2

<!-- gh-comment-id:3649773903 --> @jwadow commented on GitHub (Dec 13, 2025): Fixed in v1.0.2! 🎉 The `400 'Improperly formed request'` error (and others) with OpenCode has been resolved. At least I didn't encounter any errors in OpenCode, I called tools, created files, read directories, etc. Please update to the latest version and let me know if you still experience any issues. Release: https://github.com/jwadow/kiro-openai-gateway/releases/tag/v1.0.2
Author
Owner

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

thank you it works for me now!

<!-- gh-comment-id:3649816726 --> @lonestike commented on GitHub (Dec 13, 2025): thank you it works for me now!
Author
Owner

@Ry-DS commented on GitHub (Dec 14, 2025):

legend! thanks for the quick turnaround

<!-- gh-comment-id:3650160141 --> @Ry-DS commented on GitHub (Dec 14, 2025): legend! thanks for the quick turnaround
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#2
No description provided.