Skip to content

chore(examples,docs): cleanup & maintenance — standardize chat wiring on fetchLLM#711

Open
ankit-thesys wants to merge 8 commits into
mainfrom
fix/examples-fetchllm-first
Open

chore(examples,docs): cleanup & maintenance — standardize chat wiring on fetchLLM#711
ankit-thesys wants to merge 8 commits into
mainfrom
fix/examples-fetchllm-first

Conversation

@ankit-thesys

@ankit-thesys ankit-thesys commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Cleanup & general maintenance

No new features. This PR removes drift that accumulated after the Agent Interface SDK landed: example code that contradicts the docs, agent-facing docs describing removed APIs, and a few pieces of dead weight. Consumer-visible behavior is unchanged except that examples/scaffold now demonstrate the documented pattern.

1 · Example drift → aligned with the docs

The docs teach fetchLLM-first ("Most apps never construct a ChatLLM by hand" — adapters-and-formats), but 8 example apps and the CLI scaffold hand-rolled custom ChatLLM objects. Cleaned up:

Commit Cleanup
1df94b0d Drop-ins (zero route changes): openui-chat, shadcn-chat, material-ui-chat, supabase-chat, mastra-chat, form-generator → fetchLLM(...)
ae88f1cd hands-on-table-chat → fetchLLM; route now pins the shared table-store key to "default" (matches actual prior behavior — setThreadId was never called)
5d0e926f pi-agent-harness → fetchLLM; conversation id from body.threadId (header fallback kept); system prompt moved server-side; docs page updated to stop contradicting the example
0b433708 fastapi-backend → fetchLLM; systemPrompt optional; default prompt generated via generate:prompt and committed (no Node step needed to run the Python backend)
e89b3893 react-email: stale pinned react-headless 0.8.2workspace:*; migrated off removed flat ChatProvider props
75eb6354 CLI self-hosted template → fetchLLM (the scaffold the quickstart points at no longer teaches the anti-pattern)

Deliberately not converted (legitimate escape hatches, now documented as such): examples/openui-cloud, examples/harnesses/vercel-eve.

2 · Doc rot → corrected (6113ba76)

  • docs/public/AGENTS.md: Cloud quickstart rewritten fetchLLM-first; custom-ChatLLM guidance rescoped to genuinely non-HTTP cases; fetchLLM POST body contract corrected (real body: { threadId, runId, messages, tools: [], context: [] })
  • packages/react-headless/AGENTS.md: still described the removed threadApiUrl/apiUrl/processMessage era with a wrong file map — fully refreshed from the current tree
  • packages/react-headless/README.md: bare un-called adapter factories fixed, fetchLLM added; packages/react-ui/README.md: quickstart on fetchLLM, CSS import standardized on components.css
  • docs llms.txt: now advertises /AGENTS.md (it was invisible to agents discovering the site); CONTRIBUTING.md routes coding agents to the AGENTS.md system; vercel-eve AGENTS.md marks its custom ChatLLM as the intentional exception

3 · Hygiene (0b67d190)

Lockfile: react-email's old 0.8.2 tree removed; the importer for the gitignored examples/openui-cloud/vendor/ dropped — after which pnpm install --frozen-lockfile passes on a fresh checkout (long-standing CI lockfile debt). Devs with vendor/ locally will see the importer churn back on their next install — this hunk is isolated in its own commit and droppable if the trade-off isn't wanted.

Verification

  • tsc --noEmit + next/vite build for every converted app; fastapi additionally py_compile + prompt generation end-to-end; pi-harness runtime smoke test
  • CLI template verified by scaffolding a real app against published 0.12.1/0.9.1 (tsc + eslint + next build green)
  • Docs site builds; pnpm install --frozen-lockfile green on fresh checkout
  • Full-diff adversarial review: no blockers

Known divergence (tracked, out of scope)

The rewritten /AGENTS.md Cloud quickstart uses the RunAgentInput messages body while the unconverted examples/openui-cloud still posts { threadId, input } — converging them needs a fetchLLM body-mapping option (deferred SDK idea).

🤖 Generated with Claude Code

ankit-thesys and others added 8 commits July 3, 2026 00:53
Replace hand-written ChatLLM objects with fetchLLM({ url, streamAdapter,
messageFormat }) in openui-chat, shadcn-chat, material-ui-chat,
supabase-chat, mastra-chat, and form-generator. No route changes: all
routes read body.messages (supabase also body.threadId, which fetchLLM
sends natively) and ignore the extra RunAgentInput fields.

Aligns the examples with what the docs already teach ("most apps never
construct a ChatLLM by hand"). Verified: tsc --noEmit + next/vite build
per app.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… server-side

The client used to send TableContext's threadId (always "default"), which
keys the server-side table store. fetchLLM sends AgentInterface's
per-thread uuid instead, which would desync chat tools from the visible
spreadsheet — so the route now keys the shared table store by the
constant "default" and ignores body.threadId, preserving today's actual
behavior (setThreadId was never called anywhere).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Page: custom ChatLLM -> fetchLLM (openAIReadableStreamAdapter +
  openAIMessageFormat); client no longer computes the system prompt.
- Route: conversation id now read from body.threadId (fetchLLM sends it),
  x-conversation-id header kept as fallback; system prompt computed
  server-side from openuiLibrary with body.systemPrompt as optional
  override.
- next.config.ts: issuer-scoped webpack external for genui-lib — Next 16's
  route-handler graph rejects its client-oriented React imports when
  bundled; scoping avoids a second React instance during page SSR.
- Docs page updated to match the new wiring (snippets + prose).

Verified: tsc, next build, runtime smoke test, docs build.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…e prompt

Frontend: custom ChatLLM -> fetchLLM (openAIReadableStreamAdapter +
openAIMessageFormat); the client no longer sends systemPrompt.
Backend: body["systemPrompt"] hard-KeyError -> optional override;
the default prompt is read from backend/app/system_prompt.txt, generated
by the new frontend generate:prompt script (Node, imports genui-lib).
The generated prompt file is committed so the Python backend runs
without a Node step; regenerate when the library prompt changes (README
updated).

Verified: vite build, py_compile, generate:prompt end-to-end.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ace llm

Upgrade off the stale pinned @openuidev/react-headless 0.8.2 to
workspace:* (matching sibling examples) and migrate ChatProvider off the
removed flat processMessage/streamProtocol props to
llm={fetchLLM({ url, streamAdapter: openAIAdapter(), messageFormat:
openAIMessageFormat })}. Route unchanged (reads body.messages).

Lockfile changes land separately in the final chore commit.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…neration

The scaffold the quickstart points at taught the hand-written-ChatLLM
anti-pattern. The template page now uses fetchLLM; the route serves the
system prompt server-side (body.systemPrompt optional override), reading
a file generated at build time by the new scripts/generate-prompt.mjs
(direct genui-lib import in a route breaks next build under the
react-server condition, so generation mirrors the committed-file pattern
other examples use).

Verified end-to-end: CLI built, template scaffolded into a scratch dir
against published 0.12.1/0.9.1, tsc + eslint + next build all green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- docs/public/AGENTS.md: Cloud quickstart rewritten fetchLLM-first (with
  a slice(-1) messageFormat wrapper and a route snippet consistent with
  the RunAgentInput body); custom-ChatLLM guidance rescoped to genuinely
  non-HTTP cases (vercel-eve); fetchLLM POST body contract corrected to
  { threadId, runId, messages, tools: [], context: [] }.
- packages/react-headless/AGENTS.md: full refresh off the removed
  threadApiUrl/apiUrl/processMessage props era — current {llm, storage}
  contract, regenerated file map (src/adapters, src/stream/formats,
  src/hooks), updated recipes and test-suite list.
- packages/react-headless/README.md: fetchLLM-first quickstart; fixed
  bare un-called adapter usages.
- packages/react-ui/README.md: quickstart on fetchLLM; CSS import
  standardized on components.css (styles/index.css is a byte-identical
  alias).
- docs llms.txt route: /AGENTS.md now advertised first in the index.
- CONTRIBUTING.md: routes coding agents to the AGENTS.md system.
- vercel-eve AGENTS.md: marks its hand-written ChatLLM as the intentional
  exception (client-side stream synthesis, no HTTP endpoint).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… importer

Two causes: (1) react-email's move from pinned react-headless 0.8.2 to
workspace:* removes the old 0.8.2 dependency tree; (2) pnpm install ran
in a checkout without the gitignored examples/openui-cloud/vendor/ dir,
so the lockfile's vendor-package importer (and its now-unreferenced
transitive entries) was dropped.

(2) is arguably a fix: pnpm install --frozen-lockfile now passes on a
fresh checkout (the known post-retire-shells CI lockfile debt). Devs with
vendor/ present locally will see this importer churn back on their next
install — drop this hunk at review if that trade-off is not wanted.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ankit-thesys ankit-thesys changed the title feat(examples): fetchLLM-first — convert examples & CLI template, fix agent-facing docs chore(examples,docs): cleanup & maintenance — standardize chat wiring on fetchLLM Jul 3, 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