Skip to content

feat(harness-grok-build): implement harness adapter for Grok build#16244

Draft
mlekhi wants to merge 22 commits into
mainfrom
harness-grok-build
Draft

feat(harness-grok-build): implement harness adapter for Grok build#16244
mlekhi wants to merge 22 commits into
mainfrom
harness-grok-build

Conversation

@mlekhi

@mlekhi mlekhi commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Background

Summary

Manual Verification

Checklist

  • All commits are signed (PRs with unsigned commits cannot be merged)
  • Tests have been added / updated (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features)
  • A patch changeset for relevant packages has been added (for bug fixes / features - run pnpm changeset in the project root)
  • I have reviewed this pull request (self-review)

Future Work

Related Issues

mlekhi and others added 5 commits June 17, 2026 16:15
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>

@felixarntz felixarntz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Comment thread packages/harness-grok-build/src/bridge/package.json Outdated
Comment thread packages/harness-grok-build/package.json Outdated

export type GrokBuildHarnessSettings = {
readonly model?: string;
readonly planMode?: boolean;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment on lines +569 to +581
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 => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@mlekhi mlekhi changed the title Harness grok build feat(harness-grok-build): implement harness adapter for Grok build Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants