Skip to content

Add OpenAI Autofix example - #1193

Open
ankur-mittal95 wants to merge 5 commits into
mainfrom
codex/autofix-example
Open

ankur-mittal95 wants to merge 5 commits into
mainfrom
codex/autofix-example

Conversation

@ankur-mittal95

@ankur-mittal95 ankur-mittal95 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

What

Add a runnable AgentInterface example that generates UI with OpenAI directly and automatically repairs invalid OpenUI Lang through Autofix. A natural-language prompt streams into an interface; valid output skips repair, and repaired output replaces the preview in the same assistant reply.

Changes

  • Add a standalone Next.js example at examples/miscellaneous/autofix, using the OpenAI SDK with OPENAI_API_KEY and configurable OPENAI_MODEL (default gpt-4.1-mini). Autofix uses a separate THESYS_API_KEY.
  • Generate one component-library spec for the OpenAI system prompt, parser, and Autofix config message. Validate after generation completes, make a non-streaming repair request only when needed, and validate the result before rendering.
  • Keep final UI code in follow-up conversation context. Trim recent whole turns to the API context limits, preserve original output on failed repairs, and forward cancellation while preventing stale results.
  • Use fetchLLM() and agUIAdapter() with standard AG-UI SSE events. Keep request-scoped cancellation and incomplete-stream guards, and use a message-format hook to forward final UI code as history.
  • Show repair status, original/final source, and diagnostics in assistant replies. Keep reproducible broken programs in test fixtures only; the running example generates real model output.
  • Register the example and include its README covering setup, streaming, validation, repair, and both server-side credentials.

The API documentation fixes are already merged in #1200. This PR changes only files under examples/.

Test Plan

  • npm run verify: generated spec, ESLint, 36 tests, TypeScript, and production Next.js build passed.
  • Browser checks with isolated local provider responses: invalid output repaired in the same reply, valid follow-up skipped Autofix, repaired code forwarded as context, and cancellation closed the provider stream without publishing a stale result.
  • September 17 live Autofix checks through local Coda → Muse → Anthropic: invalid Heading repaired to Header, output passed local validation, and valid input returned unchanged with zero model tokens.
  • Browser checks with controlled generation and real Autofix: repaired output rendered, the next generation request contained repaired code, and a valid follow-up skipped repair. Two generation requests caused one real repair request.
  • npm and pnpm lockfile dependency specifiers match the manifest; Git whitespace checks passed.
  • After merging current main, both docs files match main exactly and the example directory is unchanged from the tested commit 31d2d37.

Tests exercise the real OpenAI SDK, parser, renderer, and HTTP route with stubbed network responses, including disconnected streams, authentication/quota errors, failed repairs, and cancellation. Browser fixtures are outside the example and are not shipped.

A fully live OpenAI generation-to-repair run remains blocked by OpenAI returning 429 credit_balance_exhausted. The real Autofix repair path has passed independently and through the browser with controlled generation; no fully live OpenAI-to-Autofix success is claimed.

Checklist

  • Related backend changes: Muse #604 and Coda #1031.
  • Added example setup instructions and registered the example.
  • Considered backwards compatibility: requires the config-message Autofix contract; no published package APIs change.

@vercel

vercel Bot commented Sep 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
openui-docs Ready Ready Preview Sep 18, 2026 6:17am UTC

Request Review

@ankur-mittal95 ankur-mittal95 changed the title Add AgentInterface Autofix example Add OpenAI Autofix example Sep 17, 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.

1 participant