Skip to content

About

An Agent Builder style workflow (guardrail, agent with a function tool, end node) on your own Cloudflare Worker, with the OpenAI Agents SDK and a plain chat page. MIT.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

An Agent Builder workflow, on your own Cloudflare Worker

OpenAI shuts down Agent Builder on Nov 30, 2026 (deprecations page). Its Code button exports a workflow as Agents SDK code. This example runs a workflow in that shape on a Cloudflare Worker, with the OpenAI Agents SDK for JavaScript and a small chat page in place of the hosted ChatKit embed.

src/workflow.js is our own sample workflow with the node shape of an Agent Builder TypeScript export: a guardrail node, one agent with a function tool, and an end node. A buyer's export replaces the guardrail, the agent and its tool; the rest of the Worker stays. We tested first against the export in this tutorial.

Files

  • src/workflow.js: runWorkflow and its three nodes. All the Agents SDK code is here.
  • src/index.js: the Worker. POST /chat takes { messages: [{ role, content }] }, checks it, and runs the workflow. ?stream=1 streams the answer as text.
  • public/index.html: the chat page (static assets). It keeps the history in the browser tab.
  • notes.json: what the search_notes tool searches.
  • worker.test.js: the input checks, the guardrail node, and one full turn with a tool call, against a fake model (no network).
  • check.mjs: three real turns against a running Worker, the last one blocked by the guardrail. output.txt is its real output.

Run it

npm install
node --test --test-concurrency=1 worker.test.js
OPENAI_API_KEY=sk-... npx wrangler dev        # http://localhost:8787
node check.mjs http://localhost:8787
npx wrangler login && npx wrangler secret put OPENAI_API_KEY && npx wrangler deploy

Another OpenAI-compatible provider: set OPENAI_BASE_URL and MODEL (our test used Groq, https://api.groq.com/openai/v1 and openai/gpt-oss-20b). Hosted tools then do not work, because they need OpenAI's Responses API.

Limits

  • The guardrail node is a plain word check on the user's messages, so a reworded attempt gets past it. A real export's guardrail node ports to @openai/guardrails 0.3.0, which runs on Workers (we tested its Jailbreak check there) and adds about 6.6 MB to the bundle.
  • After a message trips the guardrail, the rest of that chat is refused too, because the page sends the whole history. Reload the page to start over.
  • No ChatKit: its custom backend must speak the ChatKit server protocol, and OpenAI ships that only as a Python SDK.
  • No saved threads. Traces are off.

About

An Agent Builder style workflow (guardrail, agent with a function tool, end node) on your own Cloudflare Worker, with the OpenAI Agents SDK and a plain chat page. MIT.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages