Skip to content

The Open Standard for Generative UI

Fix Autofix request and context limit docs (#1200)

ankur-mittal95d86879eea62d
diff --git a/docs/content/docs/gateway/api/autofix.mdx b/docs/content/docs/gateway/api/autofix.mdx
index 575b730e6..744d1e1e2 100644
--- a/docs/content/docs/gateway/api/autofix.mdx
+++ b/docs/content/docs/gateway/api/autofix.mdx
@@ -272,8 +272,8 @@ The generation may be bare OpenUI Lang, a fenced code block, or an assistant tur
## Limits
- The generation can be up to 100,000 characters.
-- The turns before it can hold up to 20 usable turns and 8,000 characters of text in total, counted after tool turns and non-text parts are dropped.
-- Only the most recent turns are used. Older turns are dropped first.
+- The turns before it can hold up to 20 usable turns and 8,000 characters of text in total, counted after tool turns, non-text parts, and config blocks are removed.
+- Requests exceeding either context limit are rejected with `400`. Trim older history before sending; the API does not drop it automatically.
- Up to two attempts are made to fix one generation.
- Only non-streaming responses are supported. `stream: true` is a `400`.
diff --git a/docs/content/docs/openui-lang/reliability.mdx b/docs/content/docs/openui-lang/reliability.mdx
index 11250870f..3372b6c93 100644
--- a/docs/content/docs/openui-lang/reliability.mdx
+++ b/docs/content/docs/openui-lang/reliability.mdx
@@ -117,6 +117,10 @@ For every generation, the Autofix API:
- **Answers** with the complete fixed generation, ready to render.
```ts
+import { generateSystemPrompt } from "@openuidev/lang-core";
+import OpenAI from "openai";
+import library from "./openui.spec.json";
+
const client = new OpenAI({
apiKey: process.env.THESYS_API_KEY,
baseURL: "https://api.thesys.dev/v1/autofix",
@@ -124,15 +128,22 @@ const client = new OpenAI({
const completion = await client.chat.completions.create({
model: "openui/autofix",
- // The generation to fix is the last assistant turn.
- messages: [...messages, { role: "assistant", content: generation }],
- library,
+ stream: false,
+ messages: [
+ // Send the component-library spec in the first system turn.
+ { role: "system", content: generateSystemPrompt({ cloud: true, library }) },
+ ...messages,
+ // The completed generation to fix is the last assistant turn.
+ { role: "assistant", content: generation },
+ ],
});
// completion.fix_summary.status is "already_valid", "fixed", or "fix_failed"
// completion.choices[0].message.content holds the fixed generation.
```
+`openui.spec.json` is the component-library spec generated by `openui generate --spec`. Autofix reads it from the first system or developer message; do not pass a top-level `library` field. See [Generate OpenUI Lang](/docs/gateway/generate-openui-lang) for how to generate the spec.
+
A generation that is already valid is free, and each fix is charged at a flat price. See the [Autofix API reference](/docs/gateway/api/autofix) for the full request and response format and the error codes.
### OpenUI Gateway