mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
fix(grok): correct opencode provider (Responses API), stdin, reasoning cost
A live opencode run against api.x.ai/v1 surfaced three real bugs: 1. Provider package — grok-build-0.1 is driven via the OpenAI Responses API (opencode calls model.responses()). @ai-sdk/openai-compatible is chat/completions only and errors "responses is not a function". Switch the generated opencode.json provider + the grok image to @ai-sdk/openai. 2. Headless hang — `opencode run` blocks after init without a TTY; close stdin (`< /dev/null`) in the entrypoint so it proceeds to the model call. 3. Reasoning-token cost — grok-build-0.1 is a reasoning model; reasoning tokens bill as output but opencode stores them in a separate column. cost_for_session folds tokens_reasoning into output (else ~22x undercount). Verified end-to-end against a real session row (input=6120, output=1, reasoning=226, cache_read=1856): our pricing reproduces opencode's stored USD cost ($0.0069452) exactly. Tests anchored to that real row.
This commit is contained in:
@@ -71,7 +71,8 @@ def test_build_opencode_config_provider_and_model() -> None:
|
||||
instruction_paths=["/app/system-prompt.md"],
|
||||
)
|
||||
provider = cfg["provider"]["xai"]
|
||||
assert provider["npm"] == "@ai-sdk/openai-compatible"
|
||||
# grok-build-0.1 needs the Responses API → @ai-sdk/openai, not -compatible.
|
||||
assert provider["npm"] == "@ai-sdk/openai"
|
||||
assert provider["options"]["baseURL"] == "https://api.x.ai/v1"
|
||||
assert provider["options"]["apiKey"] == "xai-key"
|
||||
assert "grok-build-0.1" in provider["models"]
|
||||
|
||||
Reference in New Issue
Block a user