Skip to content

Adds Grok Build harness example #791

Open
vishxrad wants to merge 6 commits into
mainfrom
visharad/grok-harness
Open

Adds Grok Build harness example #791
vishxrad wants to merge 6 commits into
mainfrom
visharad/grok-harness

Conversation

@vishxrad

Copy link
Copy Markdown
Contributor

Summary

Adds a new Grok Build harness example that connects OpenUI’s AgentInterface to xai-org/grok-build.

Linear: TH-2347 — Grok Build harness

What changed

  • Added a Next.js harness under examples/harnesses/grok-build.
  • Uses OpenUI’s AgentInterface and openuiChatLibrary.
  • Runs Grok Build as a long-lived ACP process.
  • Maintains one Grok ACP session per OpenUI thread.
  • Translates ACP reasoning, tool calls, tool results, errors, and final responses into AG-UI events.
  • Persists browser threads and transcripts in local storage.
  • Handles cancellation, concurrent requests, retries, and restored sessions.
  • Validates final OpenUI Lang before streaming it to the renderer.
  • Smoothly paces OpenUI output and tool-call transitions.
  • Recovers valid OpenUI candidates from retried or noisy model output.
  • Renders a valid fallback card instead of exposing malformed OpenUI Lang.
  • Derives the OpenUI system prompt and validation schema directly from the component library in memory, without checked-in generated artifacts.
  • Adds tests covering ACP event translation, tool lifecycle handling, retries, output recovery, validation, and error serialization.

Architecture

OpenUI AgentInterface
        │
        │ AG-UI over HTTP/SSE
        ▼
Next.js chat route
        │
        │ ACP over stdio
        ▼
Grok Build agent

Grok Build exposes Agent Client Protocol events, while AgentInterface consumes supported browser streaming formats. This example therefore includes an ACP-to-AG-UI bridge that maps Grok’s native session updates into the message and tool-call lifecycle expected by OpenUI.

Future integration

The ACP bridge is currently implemented inside the example. If more ACP-compatible agents are integrated with OpenUI, we could promote this into an official server-side ACP adapter.

That integration could provide reusable handling for:

  • ACP process and session lifecycle
  • prompt delivery and cancellation
  • reasoning and tool-call event mapping
  • permissions and interactive requests
  • AG-UI streaming
  • OpenUI prompt attachment and final-output validation

OpenUI Lang and the renderer should remain protocol-independent; ACP support would live in the server integration layer.

Validation

  • Production build
  • TypeScript check
  • ESLint
  • 34 harness tests
  • Manual Grok Build model run
  • Tool-call and reasoning streaming
  • Invalid OpenUI output recovery
  • No generated prompt or component-schema files committed

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.

1 participant