Skip to content

Configuration

Think is configured by overriding methods and properties on your Think subclass. Most agents only override getModel().

Configuration overrides

Method / PropertyDefaultDescription
getModel()throwsReturn the LanguageModel to use
getSystemPrompt()"You are a helpful assistant."System prompt (fallback when no context blocks)
getTools(){}AI SDK ToolSet for the agentic loop
getScheduledTasks(){}Code-declared recurring prompts or handlers — refer to Scheduled tasks
getDefaultTimezone()undefinedDefault timezone for wall-clock scheduled tasks
getMessengers(){}Messenger ingress and delivery declarations — refer to Messengers
maxSteps10Max tool-call rounds per turn
sendReasoningtrueSend reasoning chunks to chat clients
configureSession()identityAdd context blocks, compaction, search, skills — refer to Sessions
getSkills()[]Return Agent Skills sources for on-demand skill activation — refer to Agent Skills
getSkillScriptRunner()nullEnable the optional run_skill_script tool
workspaceBashtrueInclude or configure the default workspace bash tool — refer to Tools
messageConcurrency"queue"How overlapping submits behave — refer to Client tools
waitForMcpConnectionsfalseWait for MCP servers before inference
chatRecoverytrueWrap WebSocket, sub-agent, programmatic, and continuation turns in runFiber for durable execution. Set to { maxAttempts, stableTimeoutMs, terminalMessage, onExhausted } to tune bounded recovery
chatStreamStallTimeoutMs0 (off)Opt-in inactivity watchdog: abort a turn whose model stream produces no chunk for this long (measures the gap between chunks, including tool execution). With chatRecovery on, a stall routes into bounded recovery

For chatRecovery and chatStreamStallTimeoutMs behavior, refer to Durable recovery.

Dynamic configuration

Think's class generics match Agent<Env, State, Props>. Persisted runtime configuration is typed at the configure<T>() and getConfig<T>() call sites, stored in SQLite, and survives hibernation and restarts.

JavaScript
export class MyAgent extends Think {
getModel() {
const tier = this.getConfig()?.modelTier ?? "fast";
const models = {
fast: "@cf/moonshotai/kimi-k2.6",
capable: "@cf/meta/llama-4-scout-17b-16e-instruct",
};
return createWorkersAI({ binding: this.env.AI })(models[tier]);
}
}
MethodDescription
configure<T>(config: T)Persist a typed configuration object
getConfig<T>(): T | nullRead the persisted configuration, or null if never configured

Expose configuration to the client via @callable:

JavaScript
import { callable } from "agents";
export class MyAgent extends Think {
getModel() {
/* ... */
}
@callable()
updateConfig(config) {
this.configure(config);
}
}

Session integration

Think stores conversations in a Session — the storage layer that holds your messages and gives the model writable memory. Two concepts come up here: context blocks are labelled sections of the system prompt the model can read and update (for example, a memory block of facts about the user), and compaction summarizes older messages so long conversations stay within the model's context window. Override configureSession to add persistent memory, compaction, search, and skills:

JavaScript
import { Think, Session } from "@cloudflare/think";
export class MyAgent extends Think {
getModel() {
/* ... */
}
configureSession(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();
}
}

When configureSession adds context blocks, Think builds the system prompt from those blocks instead of using getSystemPrompt(). Think's this.messages getter reads directly from Session's tree-structured storage.

For the full Session API — context blocks, compaction, search, skills, and multi-session support — refer to the Sessions documentation.

Package exports

ExportDescription
@cloudflare/thinkThink, Session, Workspace, skills namespace
@cloudflare/think/messengersMessenger contracts, Chat SDK bridge, state agent, delivery
@cloudflare/think/messengers/telegramTelegram messenger provider and delivery helpers
@cloudflare/think/workflowsThinkWorkflow, step.prompt() — Workflow prompts
@cloudflare/think/tools/workspacecreateWorkspaceTools() — for custom storage backends
@cloudflare/think/tools/executecreateExecuteTool() — sandboxed code execution via codemode
@cloudflare/think/tools/browsercreateBrowserTools() — Chrome DevTools Protocol tools
@cloudflare/think/tools/extensionscreateExtensionTools() — LLM-driven extension loading
@cloudflare/think/extensionsExtensionManager, HostBridgeLoopback — extension runtime

Dependencies

Peer dependencies you provide:

PackageRequiredNotes
agentsyesCloudflare Agents SDK
aiyesAI SDK v6
zodyesSchema validation (v4)
@chat-adapter/telegramoptionalRequired for Telegram messengers

Bundled with @cloudflare/think:

PackageNotes
@cloudflare/shellWorkspace filesystem
@cloudflare/codemodeCode execution for createExecuteTool()
just-bashSandboxed shell for the default workspace bash tool

The Agent Skills engine and its script runner live in agents/skills, so skill scripts pull @cloudflare/worker-bundler and just-bash through agents, not Think.