AIニュース最前線
最新ニュースAI日報Hacker日報週報動画AIツールトレンド企業

AIニュース最前線

世界中のAI最新情報を日本語で毎時更新

最新ニュース日報トレンド企業プレミアムRSS
© 2026 ainew.jp特定商取引法に基づく表記
ニュース一覧元記事を開く
Cloudflare Blog·2026年4月15日 22:00·約12分で読める

プロジェクト・シンク:Cloudflare上で次世代AIエージェントを構築

#AIエージェント#Cloudflare Workers#長期実行(Durable Execution)#エッジコンピューティング#サブエージェント
TL;DR

Cloudflareは、従来のエージェント実行の課題を解決するため、長期実行・サブエージェント・永続セッションなどを備えた「Project Think」をAgents SDKに追加し、エッジ環境でのAIエージェント構築基盤を強化した。

AI深層分析2026年4月15日 23:45
4
重要/ 5段階
深度40%
4
関連度30%
5
実用性20%
3
革新性10%
4

キーポイント

1

AIエージェントのアーキテクチャ転換

従来の単一インスタンス型から、長期実行・サブエージェント・永続セッションを標準化した設計へ移行し、開発者が複雑なインフラ管理を省略できる基盤を提供。

2

既存エージェントの運用課題の明示

ローカル/VPS依存、アイドル時の高額コスト、手動セットアップの手間を指摘し、1対1対応するパーソナルシェフ型エージェントの大量並列実行が従来のコンテナ方式では非現実的であることを論証。

3

エッジ環境特化のスケーラビリティ設計

Cloudflare Workersのエッジネットワーク特性を活かし、耐障害性のあるファイバーとサンドボックス化された実行環境を組み合わせることで、数百万セッションの並列実行コストを抑制。

4

高度な開発者向けプリミティブの統合

ワークスペース・アイソレート・npm解決・ブラウザ実行・サンドボックスを階層化した「Execution Ladder」と、ランタイムでの自己生成拡張機能をSDKに標準搭載。

影響分析・編集コメントを表示

影響分析

Cloudflareはエージェント実行のインフラコストとスケーラビリティという根本課題を、エッジ環境特有の永続セッションとサンドボックス機能で解決策を示した。これにより、開発者は複雑なインフラ管理を省略し、ビジネスロジックに集中できるため、エンタープライズ向けAIエージェントの普及が加速する可能性がある。

編集コメント

Cloudflareはエージェント実行の「インフラコスト」と「スケーラビリティ」に焦点を当て、エッジ環境での長期実行基盤を提示した。技術的な深みは十分だが、自社プラットフォームへの依存度を高めるPR要素も強く、開発者はベンダーロックインのリスクを踏まえて評価する必要がある。

本日、私たちはProject Thinkを発表します。これはAgents SDKの次世代版です。Project Thinkは、長時間実行されるエージェント(永続的な実行、サブエージェント、サンドボックス化されたコード実行、持続的なセッション)を構築するための新しいプリミティブのセットであり、それらをすべて接続する意見のあるベースクラスです。必要なものを正確に構築するためにプリミティブを使用するか、または迅速に開始するためにベースクラスを使用してください。

今年初めに、私たちのAIへの考え方を根本から変えた出来事が起こりました。Pi、OpenClaw、Claude Code、Codexなどのツールは、シンプルだが強力なアイデアを実証しました。LLMにファイルの読み取り、コードの記述、その実行、そして学んだことの記憶という能力を与えれば、開発者向けツールというよりは汎用アシスタントのように見えるものが得られるということです。

これらのコーディングエージェントは、もはやコードを生成するだけでなく使われています。人々はこれらを使用してカレンダーの管理、データセットの分析、購入交渉、税務申告、そしてビジネスワークフロー全体の自動化を行っています。パターンは常に同じです。エージェントがコンテキストを読み取り、それについて推論し、行動を起こすためのコードを記述し、結果を観察し、反復します。コードは行動の普遍的な媒体です。

私たちのチームはこれらのコーディングエージェントを毎日使用しています。しかし、同じ壁に常にぶつかりました:

それらはあなたのラップトップまたは高価なVPS上でのみ実行されます:共有も、コラボレーションも、デバイス間の引き継ぎもできません。

アイドル状態のコストが高い:エージェントが作業中であれそうであれ、固定された月額コストがかかります。これをチームや企業規模にスケールさせると、費用はすぐに積み重なっていきます。

これらには管理と手動での設定が必要です:依存関係のインストール、更新の管理、アイデンティティとシークレットの設定。

さらに深い構造的な問題もあります。従来のアプリケーションは、1つのインスタンスから多くのユーザーにサービスを提供します。『Agents Week へようこそ』の投稿で言及したように、エージェントは1対1の関係です。各エージェントは独自のインスタンスであり、1人のユーザーにサービスを提供し、1つのタスクを実行します。レストランには大量の料理を効率的に提供するために最適化されたメニューとキッチンがあります。一方、エージェントはまるでパーソナルシェフのようなものです:毎回異なる食材、異なる技術、異なるツールを使用します。

これはスケーリングの数学を根本的に変えます。1億人の知識労働者が、たとえ控えめな同時実行数であってもエージェントアシスタントを使用する場合、数千万の同時セッションに対応する容量が必要です。現在のコンテナあたりのコストでは持続不可能です。私たちは異なる基盤を必要としています。

それが私たちが構築してきたものです。

Project Think の紹介

Project Think は、Agents SDK 向けの新しいプリミティブのセットを提供します:

ファイバーによる耐久性のある実行:クラッシュからの回復、チェックポイント、自動キープアライブ

サブエージェント:独自の SQLite と型付き RPC を持つ独立した子エージェント

永続セッション:木構造のメッセージ、フォーク、圧縮、全文検索

サンドボックス化されたコード実行:Dynamic Workers、codemode、ランタイムでの npm 解決

実行階層:ワークスペース、アイソレート、npm、ブラウザ、サンドボックス

自己記述拡張機能:ランタイム時に独自のツールを生成するエージェント

これらはすべて、Agent ベースクラスと直接連携して使用可能です。プリミティブを組み合わせて必要なものを構築するか、Think ベースクラスを使用して迅速に開始してください。それぞれがどのような役割を果たすのかを見ていきましょう。

長時間実行されるエージェント

今日存在するエージェントは、一時的なものです。セッション中に実行され、単一のプロセスやデバイスに紐付いていますが、そのセッションが終了すると消滅してしまいます。ノートパソコンのサスペンド時に停止してしまうコーディングエージェントは、単なるツールです。しかし、永続性を持ち、オンデマンドで起動し、中断から再開でき、ローカルランタイムに依存せずに状態を引き継ぐエージェントは、インフラストラクチャのようになり始めます。そしてそれは、エージェントのスケーリングモデルを根本から変えます。

Agents SDK は Durable Objects を基盤としており、すべてのエージェントにアイデンティティ、永続的な状態、メッセージによる起動能力を与えます。これはアクターモデルです:各エージェントは独自の SQLite データベースを持つ、アドレス可能なエンティティです。待機状態(hibernation)中は計算リソースをゼロ消費します。何らかのイベント(HTTP リクエスト、WebSocket メッセージ、スケジュールされたアラーム、受信メールなど)が発生すると、プラットフォームがエージェントを起動し、その状態を読み込んでイベントを渡します。エージェントは作業を行い、その後再び待機状態に戻ります。

VM / コンテナ

Durable Objects

アイドルコスト

常時フル計算コスト

ゼロ(待機状態)

スケーリング

容量のプロビジョニングと管理

自動、エージェント単位

状態

外部データベースが必要

組み込み SQLite

リカバリ

プロセスマネージャー、ヘルスチェックなどを構築する必要がある

プラットフォーム再起動、状態は保持される

ID / ルーティング

あなたが構築する(ロードバランサー、スティッキーセッション)

組み込み(名前 → エージェント)

10,000 個のエージェント、それぞれが時間の 1% の間アクティブ

10,000 個の常時稼働インスタンス

任意の時点でアクティブなのは約 100 個

これは、大規模なエージェントの実行における経済構造を変えます。「パワーユーザーごとに高価なエージェント 1 つ」というモデルではなく、「顧客ごとに 1 つのエージェント」「タスクごとに 1 つのエージェント」「メールスレッドごとに 1 つのエージェント」といった構築が可能になります。新しいエージェントを起動する限界コストは実質ゼロです。

クラッシュからの回復:ファイバーを用いた永続的実行

LLM(大規模言語モデル)呼び出しには 30 秒かかります。マルチターンエージェントのループはそれよりも長く実行されることがあります。その期間中の任意の時点で、実行環境が消滅する可能性があります:デプロイの実行、プラットフォームの再起動、リソース制限への到達などです。モデルプロバイダーへのアップストリーム接続は永久に切断され、メモリ内の状態が失われ、接続中のクライアントは説明なくストリームが停止したことを確認します。

runFiber() はこれを解決します。ファイバーとは、永続的な関数呼び出しのことです:実行開始前に SQLite に登録され、stash() を介して任意の時点でチェックポイント可能であり、再起動時に onFiberRecovered 経由で復元可能です。

import { Agent } from "agents";

export class ResearchAgent extends Agent {

async startResearch(topic: string) {

void this.runFiber("research", async (ctx) => {

const findings = [];

for (let i = 0; i < 10; i++) {

const result = await this.search(topic);

findings.push(result);

}

return findings;

});

}

}

モデルの取得:Workers AI を使用した Moonshot K2.5 の呼び出し

getModel() {

return createWorkersAI({ binding: this.env.AI })(

"@cf/moonshotai/kimi-k2.5"

);

}

}

ストリーミング、永続化、中止/キャンセル、エラーハンドリング、再開可能なストリーム、そして内蔵されたワークスペースファイルシステムを備えた動作するチャットエージェントを作成するために必要なものは、実質的にこれだけです。npx wrangler deploy でデプロイしてください。

Think はあなたに代わって判断を行います。より多くの制御が必要な場合、関心のある項目を上書きできます:

上書き

目的

getModel()

使用する LanguageModel を返す

getSystemPrompt()

システムプロンプト

getTools()

エージェントループ用の AI SDK 互換 ToolSet

maxSteps

1ターンあたりの最大ツール呼び出しラウンド数

configureSession()

コンテキストブロック、圧縮、検索、スキル

内部では、Think は各ターンで完全なエージェントループを実行します。コンテキスト(基本指示 + ツール説明 + スキル + メモリ + 会話履歴)を組み立て、streamText を呼び出し、ツール呼び出しを実行(コンテキストの膨張を防ぐために出力を切り捨て)し、結果を追加し、モデルが完了するまでまたはステップ制限に達するまでループします。各ターン後、すべてのメッセージは永続化されます。

ライフサイクルフック

Think は、パイプライン全体を管理する必要 없이、チャットターンの各段階でフックを提供します:

beforeTurn()

→ streamText()

→ beforeToolCall()

→ afterToolCall()

→ onStepFinish()

→ onChatResponse()

フォローアップのターンでは低コストなモデルに切り替え、使用可能なツールを制限し、各ターンでクライアント側のコンテキストを渡します。さらに、すべてのツール呼び出しをアナリティクスにログ記録し、モデルが完了した後に自動的に1つのフォローアップターンをトリガーします。これらはすべて、onChatMessage を置き換えることなく実現できます。

永続メモリと長時間の会話

Think はストレージレイヤーとして Session API を基盤に構築しており、分岐機能付きの木構造メッセージを提供します。

さらに、コンテキストブロックを通じて永続メモリを追加します。これらはモデルが時間とともに読み取りおよび更新できるシステムプロンプトの構造化セクションであり、hibernation(休眠)を跨いで保持されます。モデルは「MEMORY (重要な事実、set_context を使用して更新) [42%, 462/1100 トークン]」という表示を確認し、能動的に情報を記憶することができます。

javascript
configureSession(session: Session) {
  return session
    .withContext("soul", {
      provider: { get: async () => "You are a helpful coding assistant." }
    })
    .withContext("memory", {
      description: "Important facts learned during conversation.",
      maxTokens: 2000
    })
    .withCachedPrompt();
}

セッションは柔軟です。エージェントごとに複数の会話を実行し、元の情報を失うことなく異なる方向を試すためにフォーク(分岐)することができます。

コンテキストが増大すると、Think は破壊的な圧縮ではなく非破壊的圧縮で制限に対処します。古いメッセージは削除されるのではなく要約され、完全な履歴は SQLite に保存されたままになります。

検索機能も組み込まれています。FTS5 を使用することで、セッション内の会話履歴やすべてのセッションにわたってクエリを実行できます。また、エージェントは search_context ツールを使用して自身の過去のデータを検索することも可能です。

実行パイプライン全体が接続された状態

Think は、すべての実行ステップを getTools() の単一返却値に統合しています:

import { Think } from "@cloudflare/think";

import { createWorkspaceTools } from "@cloudflare/think/tools/workspace";

import { createExecuteTool } from "@cloudflare/think/tools/execute";

import { createBrowserTools } from "@cloudflare/think/tools/browser";

import { createSandboxTools } from "@cloudflare/think/tools/sandbox";

import { createExtensionTools } from "@cloudflare/think/tools/extensions";

export class MyAgent extends Think {

extensionLoader = this.env.LOADER;

getModel() {

/* ... */

}

getTools() {

return {

execute: createExecuteTool({

tools: createWorkspaceTools(this.workspace),

loader: this.env.LOADER

}),

...createBrowserTools(this.env.BROWSER),

...createSandboxTools(this.env.SANDBOX), // エージェントごとに設定:ツールチェーン、リポジトリ、スナップショット

...createExtensionTools({ manager: this.extensionManager! }),

...this.extensionManager!.getTools()

};

}

}

自己生成された拡張機能

Think はコード実行をさらに一歩進めます。エージェントは独自の拡張機能(TypeScript プログラム)を作成でき、これらは Dynamic Workers 内で実行され、ネットワークアクセスやワークスペース操作に対する権限を宣言します。

{

"name": "github",

"description": "GitHub 統合:PR、イシュー、リポジトリ",

"tools": ["create_pr", "list_issues", "review_pr"],

"permissions": {

"network": ["api.github.com"],

"workspace": "read-write"

}

}

Think の ExtensionManager は拡張機能をバンドルし(オプションで @cloudflare/worker-bundler を介して npm 依存関係を含む)、Dynamic Worker に読み込んで新しいツールを登録します。この拡張機能は DO ストレージに永続化され、ハibernation(休止状態)後も存続します。

原文を表示

Today, we're introducing Project Think: the next generation of the Agents SDK. Project Think is a set of new primitives for building long-running agents (durable execution, sub-agents, sandboxed code execution, persistent sessions) and an opinionated base class that wires them all together. Use the primitives to build exactly what you need, or use the base class to get started fast.

Something happened earlier this year that changed how we think about AI. Tools like Pi, OpenClaw, Claude Code, and Codex proved a simple but powerful idea: give an LLM the ability to read files, write code, execute it, and remember what it learned, and you get something that looks less like a developer tool and more like a general-purpose assistant.

These coding agents aren't just writing code anymore. People are using them to manage calendars, analyze datasets, negotiate purchases, file taxes, and automate entire business workflows. The pattern is always the same: the agent reads context, reasons about it, writes code to take action, observes the result, and iterates. Code is the universal medium of action.

Our team has been using these coding agents every day. And we kept running into the same walls:

They only run on your laptop or an expensive VPS: there's no sharing, no collaboration, no handoff between devices.

They're expensive when idle: a fixed monthly cost whether the agent is working or not. Scale that to a team, or a company, and it adds up fast.

They require management and manual setup: installing dependencies, managing updates, configuring identity and secrets.

And there's a deeper structural issue. Traditional applications serve many users from one instance. As mentioned in our Welcome to Agents Week post, agents are one-to-one. Each agent is a unique instance, serving one user, running one task. A restaurant has a menu and a kitchen optimized to churn out dishes at volume. An agent is more like a personal chef: different ingredients, different techniques, different tools every time.

That fundamentally changes the scaling math. If a hundred million knowledge workers each use an agentic assistant at even modest concurrency, you need capacity for tens of millions of simultaneous sessions. At current per-container costs, that's unsustainable. We need a different foundation.

That's what we've been building.

Introducing Project Think

Project Think ships a set of new primitives for the Agents SDK:

Durable execution with fibers: crash recovery, checkpointing, automatic keepalive

Sub-agents: isolated child agents with their own SQLite and typed RPC

Persistent sessions: tree-structured messages, forking, compaction, full-text search

Sandboxed code execution: Dynamic Workers, codemode, runtime npm resolution

The execution ladder: workspace, isolate, npm, browser, sandbox

Self-authored extensions: agents that write their own tools at runtime

Each of these is usable directly with the Agent base class. Build exactly what you need with the primitives, or use the Think base class to get started fast. Let's look at what each one does.

Long-running agents

Agents, as they exist today, are ephemeral. They run for a session, tied to a single process or device, and then they are gone. A coding agent that dies when your laptop sleeps, that’s a tool. An agent that persists — that can wake up on demand, continue work after interruptions, and carry forward the state without depending on your local runtime — that starts to look like infrastructure. And it changes the scaling model for agents completely.

The Agents SDK builds on Durable Objects to give every agent an identity, persistent state, and the ability to wake on message. This is the actor model: each agent is an addressable entity with its own SQLite database. It consumes zero compute when hibernated. When something happens (an HTTP request, a WebSocket message, a scheduled alarm, an inbound email) the platform wakes the agent, loads its state, and hands it the event. The agent does its work, then goes back to sleep.

VMs / Containers

Durable Objects

Idle cost

Full compute cost, always

Zero (hibernated)

Scaling

Provision and manage capacity

Automatic, per-agent

State

External database required

Built-in SQLite

Recovery

You build it (process managers, health checks)

Platform restarts, state survives

Identity / routing

You build it (load balancers, sticky sessions)

Built-in (name → agent)

10,000 agents, each active 1% of the time

10,000 always-on instances

~100 active at any moment

This changes the economics of running agents at scale. Instead of "one expensive agent per power user," you can build "one agent per customer" or "one agent per task" or "one agent per email thread." The marginal cost of spawning a new agent is effectively zero.

Surviving crashes: durable execution with fibers

An LLM call takes 30 seconds. A multi-turn agent loop can run for much longer. At any point during that window, the execution environment can vanish: a deploy, a platform restart, hitting resource limits. The upstream connection to the model provider is severed permanently, in-memory state is lost, and connected clients see the stream stop with no explanation.

runFiber() solves this. A fiber is a durable function invocation: registered in SQLite before execution begins, checkpointable at any point via stash(), and recoverable on restart via onFiberRecovered.

import { Agent } from "agents";

export class ResearchAgent extends Agent {

async startResearch(topic: string) {

void this.runFiber("research", async (ctx) => {

const findings = [];

for (let i = 0; i < 10; i++) {

const result = await this.callLLM(Research step ${i}: ${topic});

findings.push(result);

// Checkpoint: if evicted, we resume from here

ctx.stash({ findings, step: i, topic });

this.broadcast({ type: "progress", step: i });

}

return { findings };

});

}

async onFiberRecovered(ctx) {

if (ctx.name === "research" && ctx.snapshot) {

const { topic } = ctx.snapshot;

await this.startResearch(topic);

}

}

}

The SDK keeps the agent alive automatically during fiber execution, no special configuration needed. For work measured in minutes, keepAlive() / keepAliveWhile() prevents eviction during active work. For longer operations (CI pipelines, design reviews, video generation) the agent starts the work, persists the job ID, hibernates, and wakes on callback.

Delegating work: sub-agents via Facets

A single agent shouldn't do everything itself. Sub-agents are child Durable Objects colocated with the parent via Facets, each with their own isolated SQLite and execution context:

import { Agent } from "agents";

export class ResearchAgent extends Agent {

async search(query: string) { /* ... */ }

}

export class ReviewAgent extends Agent {

async analyze(query: string) { /* ... */ }

}

export class Orchestrator extends Agent {

async handleTask(task: string) {

const researcher = await this.subAgent(ResearchAgent, "research");

const reviewer = await this.subAgent(ReviewAgent, "review");

const [research, review] = await Promise.all([

researcher.search(task),

reviewer.analyze(task)

]);

return this.synthesize(research, review);

}

}

Sub-agents are isolated at the storage level. Each one gets its own SQLite database, and there’s no implicit sharing of data between them. This is enforced by the runtime where sub-agent RPC latency is a function call. TypeScript catches misuse at compile time.

Conversations that persist: the Session API

Agents that run for days or weeks need more than the typical flat list of messages. The experimental Session API models this explicitly. Available on the Agent base class, conversations are stored as trees, where each message has a parent_id. This enables forking (explore an alternative without losing the original path), non-destructive compaction (summarize older messages rather than deleting them), and full-text search across conversation history via FTS5.

import { Agent } from "agents";

import { Session, SessionManager } from "agents/experimental/memory/session";

export class MyAgent extends Agent {

sessions = SessionManager.create(this);

async onStart() {

const session = this.sessions.create("main");

const history = session.getHistory();

const forked = this.sessions.fork(session.id, messageId, "alternative-approach");

}

}

Session is usable directly with Agent, and it's the storage layer that the Think base class builds on.

From tool calls to code execution

Conventional tool-calling has an awkward shape. The model calls a tool, pulls the result back through the context window, calls another tool, pulls that back, and so on. As the tool surface grows, this gets both expensive and clumsy. A hundred files means a hundred round-trips through the model.

But models are better at writing code to use a system than they are at playing the tool-calling game. This is the insight behind @cloudflare/codemode: instead of sequential tool calls, the LLM writes a single program that handles the entire task.

// The LLM writes this. It runs in a sandboxed Dynamic Worker.

const files = await tools.find({ pattern: "**/*.ts" });

const results = [];

for (const file of files) {

const content = await tools.read({ path: file });

if (content.includes("TODO")) {

results.push({ file, todos: content.match(/\/\/ TODO:.*/g) });

}

}

return results;

Instead of 100 round-trips to the model, you just run a single program. This leads to fewer tokens used, faster execution, and better results. The Cloudflare API MCP server demonstrates this at scale. We expose only two tools (search() and execute()), which consume ~1,000 tokens, vs. ~1.17 million tokens for the naive tool-per-endpoint equivalent. This is a 99.9% reduction.

The missing primitive: safe sandboxes

Once you accept that models should write code on behalf of users, the question becomes: where does that code run? Not eventually, not after a product team turns it into a roadmap item. Right now, for this user, against this system, with tightly defined permissions.

Dynamic Workers are that sandbox. A fresh V8 isolate spun up at runtime, in milliseconds, with a few megabytes of memory. That's roughly 100x faster and up to 100x more memory-efficient than a container. You can start a new one for every single request, run a snippet of code, and throw it away.

The critical design choice is the capability model. Instead of starting with a general-purpose machine and trying to constrain it, Dynamic Workers begin with almost no ambient authority (globalOutbound: null, no network access) and the developer grants capabilities explicitly, resource by resource, through bindings. We go from asking "how do we stop this thing from doing too much?" to "what exactly do we want this thing to be able to do?"

This is the right question for agent infrastructure.

The execution ladder

This capability model leads naturally to a spectrum of compute environments, an execution ladder that the agent escalates through as needed:

imageimage

Tier 0 is the Workspace, a durable virtual filesystem backed by SQLite and R2. Read, write, edit, search, grep, diff. Powered by @cloudflare/shell.

Tier 1 is a Dynamic Worker: LLM-generated JavaScript running in a sandboxed isolate with no network access. Powered by @cloudflare/codemode.

Tier 2 adds npm. @cloudflare/worker-bundler fetches packages from the registry, bundles them with esbuild, and loads the result into the Dynamic Worker. The agent writes import { z } from "zod" and it just works.

Tier 3 is a headless browser via Cloudflare Browser Run. Navigate, click, extract, screenshot. Useful when the service doesn't support agents yet via MCP or APIs.

Tier 4 is a Cloudflare Sandbox configured with your toolchains, repos, and dependencies: git clone, npm test, cargo build, synced bidirectionally with the Workspace.

The key design principle: the agent should be useful at Tier 0 alone, where each tier is additive. The user can add capabilities as they go.

Building blocks, not a framework

All of these primitives are available as standalone packages. Dynamic Workers, @cloudflare/codemode, @cloudflare/worker-bundler, and @cloudflare/shell (a durable filesystem with tools) are all usable directly with the Agent base class. You can combine them to give any agent a workspace, code execution, and runtime package resolution without adopting an opinionated framework.

The platform

Here's the complete stack for building agents on Cloudflare:

Capability

What it does

Powered by

Per-agent isolation

Every agent is its own world

Durable Objects (DOs)

Zero cost when idle

$0 until the agent wakes up

DO Hibernation

Persistent state

Queryable, transactional storage

DO SQLite

Durable filesystem

Files that survive restarts

Workspace (SQLite + R2)

Sandboxed code execution

Run LLM-generated code safely

Dynamic Workers + @cloudflare/codemode

Runtime dependencies

import * from react just works

@cloudflare/worker-bundler

Web automation

Browse, navigate, fill forms

Browser Run

Full OS access

git, compilers, test runners

Sandboxes

Scheduled execution

Proactive, not just reactive

DO Alarms + Fibers

Real-time streaming

Token-by-token to any client

WebSockets

External tools

Connect to any tool server

MCP

Agent coordination

Typed RPC between agents

Sub-agents (Facets)

Model access

Connect to an LLM to power the agent

AI Gateway + Workers AI (or Bring Your Own Model)

Each of these is a building block. Together, they form something new: a platform where anyone can build, deploy, and run AI agents as capable as the ones running on your local machine today, but serverless, durable, and safe by construction.

The Think base class

Now that you've seen the primitives, here's what happens when you wire them all together.

Think is an opinionated harness that handles the full chat lifecycle: agentic loop, message persistence, streaming, tool execution, stream resumption, and extensions. You focus on what makes your agent unique.

The minimal subclass looks like this:

import { Think } from "@cloudflare/think";

import { createWorkersAI } from "workers-ai-provider";

export class MyAgent extends Think<Env> {

getModel() {

return createWorkersAI({ binding: this.env.AI })(

"@cf/moonshotai/kimi-k2.5"

);

}

}

That’s effectively all you need to have a working chat agent with streaming, persistence, abort/cancel, error handling, resumable streams, and a built-in workspace filesystem. Deploy with npx wrangler deploy.

Think makes decisions for you. When you need more control, you can override the ones you care about:

Override

Purpose

getModel()

Return the LanguageModel to use

getSystemPrompt()

System prompt

getTools()

AI SDK compatible ToolSet for the agentic loop

maxSteps

Max tool-call rounds per turn

configureSession()

Context blocks, compaction, search, skills

Under the hood, Think runs the complete agentic loop on every turn: it assembles the context (base instructions + tool descriptions + skills + memory + conversation history), calls streamText, executes tool calls (with output truncation to prevent context blowup), appends results, loops until the model is done or the step limit is reached. All messages are persisted after each turn.

Lifecycle hooks

Think gives you hooks at every stage of the chat turn, without requiring you to own the whole pipeline:

beforeTurn()

→ streamText()

→ beforeToolCall()

→ afterToolCall()

→ onStepFinish()

→ onChatResponse()

Switch to a lower cost model for follow-up turns, limit the tools it can use, and pass in client-side context on each turn. Also log every tool call to analytics and automatically trigger one more follow-up turn after the model completes, all without replacing onChatMessage.

Persistent memory and long conversations

Think builds on Session API as its storage layer, giving you tree-structured messages with branching built in.

On top of that, it adds persistent memory through context blocks. These are structured sections of the system prompt that the model can read and update over time, and they persist across hibernation.The model sees "MEMORY (Important facts, use set_context to update) [42%, 462/1100 tokens]" and can proactively remember things.

configureSession(session: Session) {

return session

.withContext("soul", {

provider: { get: async () => "You are a helpful coding assistant." }

})

.withContext("memory", {

description: "Important facts learned during conversation.",

maxTokens: 2000

})

.withCachedPrompt();

}

Sessions are flexible. You can run multiple conversations per agent and fork them to try a different direction without losing the original.

As context grows, Think handles limits with non-destructive compaction. Older messages are summarized instead of removed, while the full history remains stored in SQLite.

Search is built in as well. Using FTS5, you can query conversation history within a session or across all the sessions. The agent is also able to search its own past using search_context tool.

The full execution ladder, wired in

Think integrates the entire execution ladder into a single getTools() return:

import { Think } from "@cloudflare/think";

import { createWorkspaceTools } from "@cloudflare/think/tools/workspace";

import { createExecuteTool } from "@cloudflare/think/tools/execute";

import { createBrowserTools } from "@cloudflare/think/tools/browser";

import { createSandboxTools } from "@cloudflare/think/tools/sandbox";

import { createExtensionTools } from "@cloudflare/think/tools/extensions";

export class MyAgent extends Think<Env> {

extensionLoader = this.env.LOADER;

getModel() {

/* ... */

}

getTools() {

return {

execute: createExecuteTool({

tools: createWorkspaceTools(this.workspace),

loader: this.env.LOADER

}),

...createBrowserTools(this.env.BROWSER),

...createSandboxTools(this.env.SANDBOX), // configured per-agent: toolchains, repos, snapshots

...createExtensionTools({ manager: this.extensionManager! }),

...this.extensionManager!.getTools()

};

}

}

Self-authored extensions

Think takes code execution one step further. An agent can write its own extensions: TypeScript programs that run in Dynamic Workers, declaring permissions for network access and workspace operations.

{

"name": "github",

"description": "GitHub integration: PRs, issues, repos",

"tools": ["create_pr", "list_issues", "review_pr"],

"permissions": {

"network": ["api.github.com"],

"workspace": "read-write"

}

}

Think's ExtensionManager bundles the extension (optionally with npm deps via @cloudflare/worker-bundler), loads it into a Dynamic Worker, and registers the new tools. The extension persists in DO storage and survives hibern

この記事をシェア

関連記事

Cloudflare Blog★42026年5月13日 22:00

Browser Run が Cloudflare コンテナ上で稼働し、高速化とスケーラビリティが向上

開発チームは Browser Run を Cloudflare のコンテナ基盤に再構築しました。これにより、1 分間に最大 60 ブラウザを起動可能になり、並行実行数は 120 に達し、以前より 4 倍の性能向上を実現しています。また、クイックアクションの応答時間が 50% 以上短縮され、信頼性も高まりました。

Cloudflare Blog★42026年5月1日 22:00

テナントに追従する耐久性実行を実現する「Dynamic Workflows」の発表

クラウドflare は、開発者向けプラットフォーム「Workers」において、テナントごとに動作ロジックを動的に実行できる新機能「Dynamic Workflows」を発表した。これにより、AI が実装を作成するアプリケーションや、マルチテナント SaaS の顧客ごとのビジネスロジックをランタイムで安全に処理できるようになる。

The Register AI/ML★42026年4月28日 01:20

AIの現実検証:3社がウォレット、住宅、ゲーム構築で学んだこと

シティ、ホームデポ、カプコンの経営陣は、AIエージェントが実験ツールから顧客対応業務へ移行する過程で得た知見を語った。次なる課題は、金銭や創造的出力に関わる際のガバナンスと信頼性の確保である。

ニュース一覧に戻る元記事を読む