Context Agents

What is a "Context Agent"?

"Agentic" is the buzzword of the moment. Everyone wants to tell you what an agent is and isn't. So why are we creating a new agent framework?

Well, it's because we want to demonstrate that agents are really just loops of context management. All the latest buzzy features like skills, plugins and MCP servers and DAGs all exist to manage the state of context from an LLM.

We wanted to challenge ourselves: What would happen if we removed the framework, removed the code, and just gave the agent context.

An Empty Directory

Our "Context Agent" starts with a directory. We make that directory a sandbox for the agent. Like any good sandbox, you can throw in items for the agent to play with. Throw in Markdown documents and the agent will hoover up that as free context so it can explore its world.

Throw in an OpenAPI.yaml and the agent will instantly start to probe and test for connectivity to APIs. Most of this behavior by the LLM occurs unprompted. The eagerness to test and explore has been refined into these models with reinforcement learning.

Add in Some Tools

In addition to the execution directory, we give the agent one tool: execute_js. It is through execute_js that the agent reads files and acts on the user prompt. This setup is inspired by Cloudflare's CodeMode.

Rather than having the user have to write tools or connect in MCP servers with 40, 50 or 100 tools, we simplify the agent's context and tell it to just write the tools it wants all in a common context document that it can read, understand, and update over time.

Execute JS

Execute JS is also a very safe sandbox for us to use. We leverage the Deno runtime for code execution which allows us to control which domains can be accessed and provide absolute security guarantee that the agent can't break out of its directory.

Within the deno runtime, we've given context agents simple functions so that it feels like a POSIX environment:

globalThis.cat = cat;
globalThis.find = find;
globalThis.grep = grep;
globalThis.tree = tree;
globalThis.write = write;
globalThis.search_and_replace = search_and_replace;
globalThis.mkdir = mkdir;

With just these tools, the agent has everything it needs to dynamically create its world. Notice that this is just a collection of POSIX style file system commands. The agent can read files, write files, search and replace within files, and make directories. With these tools, the agent can create its own context and then use that context to respond to user prompts ot take action.

Memory and Self-Authorship

We find the best way to use Context Agents is to let them build themselves. That's why we've enabled two modes:

  • Build mode: Gives the agent free reign to write instructions and author JS tools that it can continue to use.
  • Execute Mode: Places limits on the write and search_and_replace tools so that the agent can write and modify everything in <exec_dir>/memories but can't modify its own tools or system prompt. In this way, the agent focuses on using its system not continuously improving and tends to respond a little faster.

Ready to go

Head over to Getting Started or try the Playground