RFC: CodingAgent — a new @cloudflare/coding-agent package#1831
Merged
Conversation
Proposes promoting examples/sandbox-coding-agent (#1830) into @cloudflare/think as a supported `CodingAgent` class — a Think subclass that drives a CLI coding agent (Claude Code first) inside a Cloudflare Sandbox, exported per-CLI as `@cloudflare/think/claudecode`. Locks the surface before any core code moves: an internal TurnRuntime seam in Think (private, CodingAgent is its only consumer), a per-CLI adapter contract, tokenless AI Gateway egress + snapshot-based durability built in, DO-tuned recovery, and a conformance-test strategy for stream-json drift. Strategic stance: own the public interface, keep the engine swappable (a matured @ai-sdk/harness could become an impl detail behind the same class — #1829). Status: proposed. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Folds in the firm follow-ups from review: - §8 dynamic config (resolve-by-precedence, freeze-on-first-turn) + topology (standalone / Chats-child threads / orchestrated), with the "no top-level binding assumption" requirement. - §9 two seams designed in from day one: a filesystem backend interface (so the durable cloudflare/workspace VFS can supersede snapshots later) and run/preview by target (container dev server vs worker-bundler + env.LOADER). - §10 future-work pointer to a Workers-native runtime (Runtime B) behind the same TurnRuntime seam. - New alternative (adopt cloudflare/workspace now — rejected, preview-only) and expanded decision questions. Co-authored-by: Cursor <cursoragent@cursor.com>
…y pattern The fixed chats_index/ChatSummary schema is the part consumers outgrow immediately — a coding directory needs repo/branch/status/lastDiff, etc. So: - rfc-coding-agent §8: reframe "threads" as a userland directory pattern (plain Agent + subAgent with domain-specific metadata), not a `Chats` base class. The shipped, load-bearing primitives it leans on are unchanged (subAgent + Props, parentAgent, RemoteContextProvider). - rfc-think-multi-session: record the third (now-leaning) answer to open question #1 — don't ship a Chats base class; ship primitives + a thin client hook + an example. Co-authored-by: Cursor <cursoragent@cursor.com>
…e, pluggable engine Adversarial review reshaped the design: - New @cloudflare/coding-agent package, NOT a Think subclass/subpath. Extends AIChatAgent, so onChatMessage is the seam and Think core is untouched (drops the riskiest piece — the turn-runtime refactor). Honors the AGENTS.md layering preference (containers don't belong in the chat base). - Pluggable engine: CliEngine ships first (lift the example's mapper), HarnessEngine is the goal (reuses HarnessAgent's tested stream-mapping + session lifecycle; gated on #1829). No speculative multi-CLI adapter interface — extract after codex. - Durability redesigned around two decoupled lifecycles (DO vs container have different shutdown behaviors); reconcile-on-wake; honest that claude -p can't resume a killed turn and that re-run can double-apply edits; bound snapshot cost. - Egress scoped honestly (per-provider, TLS-dependent, OAuth CLIs can't be tokenless). - Branch is mutable working state (git checkout), only repo identity is frozen. - Filesystem VFS, preview, git ops, HITL, and Runtime B moved to "Directions" (not v1 seams). Added a Testing & CI section. Co-authored-by: Cursor <cursoragent@cursor.com>
Package name @cloudflare/coding-agent + /claude-code subpath confirmed. Engine default, snapshot policy, and first-PR scope remain deliberately open. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
design/rfc-coding-agent.md(status: proposed) — an RFC to extract thesandbox-coding-agentexample into a new@cloudflare/coding-agentpackage: aCodingAgentthat drives a coding agent (Claude Code first) inside a Cloudflare Sandbox, with a chat UI, durable sessions, recovery, and orchestration-friendliness.Key decisions
AIChatAgentbase — not Think.CodingAgent extends AIChatAgent, soonChatMessageis the seam and Think core is untouched (drops the riskiest piece of the original plan). A coding agent isn't a chat-model agent, so inheriting Think would leave ~half its surface inert; and a separate package honors theAGENTS.mdlayering preference (containers don't belong in the chat base) and can track whatever AI-SDK major@ai-sdk/harnessneeds without gating the repo.CliEngineships first (the example's mapper, works today, no new deps);HarnessEngineis the goal — it reuses the AI SDKHarnessAgent's tested stream-mapping and session lifecycle (detach/stop/suspendTurn/resume) for free, gated on the CF sandbox provider (Add an @ai-sdk/sandbox-cloudflare HarnessAgent provider (during ai v7 migration) #1829). No speculative multi-CLI adapter interface — extract after codex actually lands.-pcan't resume a killed turn (mid-turn recovery = reset-to-checkpoint + re-run, with double-apply risk called out), and snapshot cost must be bounded.Alternatives (Think subclass + core seam; hand-rolled mapper as the only engine; a Think subpath; adopt
cloudflare/workspacenow; keep as example) are documented with rationale.Open questions for reviewers
@cloudflare/coding-agent?) +/claude-codesubpath convention.CliEnginevsHarnessEngineas the default for the first release (ship now and migrate, or wait for Add an @ai-sdk/sandbox-cloudflare HarnessAgent provider (during ai v7 migration) #1829?).CliEnginesnapshot policy (what/how-often/thenode_modulesquestion).CliEngine+ tokenless egress + two-lifecycle durability + dynamic config + rewrite the example onto the package. Codex,HarnessEngine, preview, git ops, HITL, VFS deferred.Related
@ai-sdk/sandbox-cloudflareprovider (gatesHarnessEngine).Chatsbase class — note added todesign/rfc-think-multi-session.md.Test plan
pnpm run formatclean, no other files touched.