Requests with an empty tool set serialize as `"tools": []`, which strict OpenAI-compatible upstreams reject with 400
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- json, typescript
Research direction
Start in the TypeScript AI SDK layer that serializes OpenAI-compatible model requests, locating where an empty event.tools set becomes a tools array. Reproduce the request body against a strict upstream, then add a regression test confirming that requests with no effective tools omit the tools field and succeed.
Written by the indexing model from the issue text.
Description
- opencode 2.0.32, Linux, openai-compatible providers.
When the effective tool set for a model request is empty — in our case a plugin's compaction takeover clears inherited tools by setting event.tools = {} on its child sessions — the AI SDK layer serializes the request body with "tools": []. Strict OpenAI-compatible upstreams reject that:
{"error": {"type": "invalid_request_error", "param": "tools",
"message": "`tools` must not be an empty array. either provide at least one tool or omit the field entirely."}}
(HTTP 400; a second upstream answers 400 with a generic "upstream provider rejected the request". The same bodies with the tools field omitted return 200.)
Consequence here: every compaction request failed and the fallback chain exhausted — all compaction on the machine was down.
The OpenAI API treats tools as optional and accepts an empty array, and omitting the field is accepted everywhere; clients that model "no tools" as an empty set (the AI SDK's openai-compatible provider) cannot opt out of emitting it.
Request: when the effective tool set is empty, omit tools from the serialized body (or make that behavior configurable). This also makes the documented hook pattern of deleting tools from event.tools safe against strict upstreams.
Workaround we deployed: a local http.request hook plugin that deletes empty tools arrays from outgoing JSON bodies before the request leaves opencode.
- Dominant language
- TypeScript
- Stars
- 221k
- Forks
- 29.6k
- Avg merge
- 4h 35m
- Merged PRs (30d)
- 521
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from anomalyco/opencode
-
triaging
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
anomalyco/opencode#58821 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
anomalyco/opencode#58774 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
anomalyco/opencode#58725 · 1 comment ·
Maintainers usually reply within 1 day
-
Snapshot capture failure (EPERM spawning git) fails the whole step despite the best-effort contractPossibly taken @Dopetaiga claimed this 1 day ago. Openreproduced
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
anomalyco/opencode#58685 · 2 comments ·
Maintainers usually reply within 1 day
-
tui: PHP code blocks without `<?php` are not syntax highlightedPossibly taken @SwastikTripathi claimed this 1 day ago. Openreproduced
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
anomalyco/opencode#58664 · 2 comments ·
Maintainers usually reply within 1 day
All issues in anomalyco/opencode
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
MoonshotAI/kimi-code#4398 ·
Maintainers usually reply within 1 day
-
Xiaomi Mimo语音识别服务异常Openpending triage
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
package-lock.json : les binaires natifs macOS et Linux de unrs-resolver ont disparu depuis #1823Openbug dependencies
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
AxaFrance/design-system#2064 ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100