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:
@@ -12,11 +12,12 @@ FROM roboco-agent-base
|
||||
|
||||
USER root
|
||||
|
||||
# opencode — the OpenAI-protocol agent runtime. The @ai-sdk/openai-compatible
|
||||
# package backs the custom xAI provider declared in the generated opencode.json;
|
||||
# opencode also resolves it at runtime, but pre-installing keeps first spawn off
|
||||
# the network.
|
||||
RUN npm install -g opencode-ai @ai-sdk/openai-compatible \
|
||||
# opencode — the OpenAI-protocol agent runtime. grok-build-0.1 is driven via the
|
||||
# OpenAI Responses API, so the provider package is @ai-sdk/openai (NOT
|
||||
# @ai-sdk/openai-compatible, which is chat/completions only and errors with
|
||||
# "responses is not a function"). opencode resolves it at runtime, but
|
||||
# pre-installing keeps first spawn off the network.
|
||||
RUN npm install -g opencode-ai @ai-sdk/openai \
|
||||
&& npm cache clean --force \
|
||||
&& rm -rf /root/.npm /tmp/*
|
||||
|
||||
|
||||
@@ -16,6 +16,10 @@ python -m roboco.llm.providers.opencode_config
|
||||
# positional); `--` separates it from flags so a prompt starting with `--`
|
||||
# cannot be parsed as CLI options. The model also comes from the rendered
|
||||
# config; --model is passed explicitly as belt-and-suspenders.
|
||||
#
|
||||
# `< /dev/null` is REQUIRED: without a closed stdin, `opencode run` hangs after
|
||||
# init in a headless / no-TTY environment (it blocks waiting on stdin). Verified
|
||||
# live — closing stdin lets the run proceed to the model call and exit cleanly.
|
||||
exec opencode run \
|
||||
--model "xai/${ROBOCO_AGENT_MODEL:-grok-build-0.1}" \
|
||||
-- "${ROBOCO_INITIAL_PROMPT:-}"
|
||||
-- "${ROBOCO_INITIAL_PROMPT:-}" < /dev/null
|
||||
|
||||
Reference in New Issue
Block a user