feat(harness-grok-build): implement harness adapter for Grok build#16244
feat(harness-grok-build): implement harness adapter for Grok build#16244mlekhi wants to merge 22 commits into
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…pendency Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… resolver Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
defined via the shared commonTool helper
felixarntz
left a comment
There was a problem hiding this comment.
@mlekhi this looks like a great start! I haven't gotten it to work on my end yet, probably something with the config, but I left one comment regarding AI Gateway vs xAI direct usage.
mostly a few small comments for now.
|
|
||
| export type GrokBuildHarnessSettings = { | ||
| readonly model?: string; | ||
| readonly planMode?: boolean; |
There was a problem hiding this comment.
this is a good point, I don't think we support configuring it for the other harnesses at the moment; though not entirely sure here's a good fit since these options apply to an entire model session. the mode you're in is typically something you may want to switch mid-way through the session
| const DEFAULT_GROK_MODEL_GATEWAY = 'xai/grok-build-0.1'; | ||
|
|
||
| export type GrokBuildHarnessSettings = { | ||
| readonly model?: string; |
There was a problem hiding this comment.
something we support in the other harnesses is to set the amount of reasoning (or sometimes called thinking). does Grok Build support configuring that too?
| // Resolve auth → concrete grok CLI env vars, and pick the matching model id. | ||
| const resolvedAuth = resolveGrokBuildEnv(settings.auth); | ||
| const grokEnv = toGrokCliEnv(resolvedAuth); | ||
| const isGateway = resolvedAuth.AI_GATEWAY_API_KEY != null; |
There was a problem hiding this comment.
for getting the Gateway config, can you use the getAiGatewayAuthFromEnv() helper? I added it the other day so we can handle that centrally. the important point in that is that we also have to support VERCEL_OIDC_TOKEN as an accepted credential for AI Gateway
| doPromptTurn: async promptOpts => { | ||
| const { done } = wireTurn({ | ||
| emit: promptOpts.emit, | ||
| abortSignal: promptOpts.abortSignal, | ||
| }); | ||
| channel.send({ | ||
| type: 'start', | ||
| prompt: extractUserText(promptOpts.prompt), | ||
| ...(model ? { model } : {}), | ||
| }); | ||
| return { ...unsupportedToolControl, done }; | ||
| }, | ||
| doContinueTurn: async continueOpts => { |
There was a problem hiding this comment.
based on that you didn't implement tool examples yet, I assume Grok Build doesn't support custom tools at all? both doPromptTurn and doContinueTurn may receive a tools property. if this harnesses doesn't support custom tools, we should probably throw an exception so that it's at least obvious.
the other thing supported here is general instructions. that may be one we can work around even if not properly supported. The Codex harness for example automatically prepends those to the first message of a message - not super clean but okay enough as a workaround.
|
|
||
| // Direct (xAI) uses the bare id; the gateway requires the `xai/` prefix. | ||
| const DEFAULT_GROK_MODEL_DIRECT = 'grok-build-0.1'; | ||
| const DEFAULT_GROK_MODEL_GATEWAY = 'xai/grok-build-0.1'; |
There was a problem hiding this comment.
for some reason when I run the examples I get this error: Error: Couldn't set model 'xai/grok-build-0.1': Invalid params: "unknown model id". Run 'grok models' to see available models.
I have a valid xAI API key set - there may be something off where it thinks it's using AI Gateway?
Background
Summary
Manual Verification
Checklist
pnpm changesetin the project root)Future Work
Related Issues