Skip to content

mattcollins/cloudflare-codemode-example

Repository files navigation

Cloudflare Code Mode Example

This is a simple, working example of an AI agent using Cloudflare's 'Code Mode', based on the CodeACT pattern.

It is derived from Cloudflare's example at https://github.com/cloudflare/agents/tree/main/examples/codemode

It demonstrates how you can define a custom tool to be provided to the agent (see src/tools.ts)

Screenshot of Code Mode demo

Running the Demo

  1. Install dependencies (npm install)
  2. Create a .env file with your OpenAI API key (see .env.example)
  3. Run npm start to start the development server
  4. Visit http://localhost:5173 to see the demo
  5. Try asking about the weather, e.g. "How's the weather today?"

How Code Mode Works

Here's a sequence diagram showing how Code Mode works. cloudflare-codemode-sequence-diagram

You may also like to read this blog post about Code Mode.

About

A simple example of using Cloudflare's 'Code Mode' to define an AI agent.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published