En 30 secondes
A local coding model can handle small implementation tasks, but only when the work is broken down and carefully checked. JetBrains developer advocate Paul Everitt rebuilds the same Python app with cloud models, a hybrid cloud-and-local pair, and finally two local models. His comparisons show that subagents can protect the main agent’s context while increasing total work; cheaper models reduce usage charges but need tighter handoffs. The fully local example passes its tests after a repair, though memory requirements and hardware speed limit who can reproduce it.
- 1A fixed specification makes the different setups comparableThe same mission, technology stack and roadmap guide each rebuild of a small FastAPI application.
- 2Subagents isolated work but increased the total contextIn one cloud comparison, main-agent context fell while subagent context nearly doubled; overall context and turns rose around 50%.
- 3A cheaper implementer shifted work back to the coordinatorEight smaller Flash implementers reduced average context per subagent and price, but main-agent coordination and wall time increased.
- 4A local model needs smaller tasks and explicit limitsEveritt splits the roadmap, limits tools and steps, and asks the cloud coordinator to prepare a detailed handoff for each phase.
- 5A fully local setup needed a repair but passed the testsOn a 32 GB machine, a Qwen coordinator and Gemma implementer completed the toy app after a failed redirect test was fixed.
À retenir
- Use the same specification and validation to compare coding setups rather than treating one successful run as a benchmark.
- Give smaller implementer models one focused phase, the files and tests they need, and clear limits on changes.
- Review the handoff and run the tests yourself; a smaller model can loop or overwrite work.
- Subagents isolate context but can increase total tokens, coordination and time.
- Local inference can keep prompts and code on your machine, but model weights and context compete for memory.
Lire le texte remanié, chapitre par chapitre
The choices behind a coding agent
Model, provider and task division affect control, expense and privacy. The course changes these one layer at a time.
Andrew Ng introduces a course about choosing the coding agent, its model and where that model runs. Those choices affect cost, privacy, speed and how much control developers have over the workflow.
Paul Everitt says the aim is to choose an appropriate model for each job, decide what leaves the machine and shape which agents run. Local execution can be a privacy requirement, although current tools and hardware can take work to configure.
The course rebuilds a small web app each time so the task stays constant. Everitt starts with Claude Code and a hosted model, then separates work into subagents, changes models and ultimately brings both roles onto the local computer.
These are comparisons, not a claim that the fully local setup is always best. A hosted workflow may be easier; a cheaper model may be sufficient; keeping code local may justify extra setup.
A fixed project and a cloud baseline
A mission, stack and roadmap guide the same small application in every experiment. The first cloud build establishes a reference.
The app, Agent Clinic, has a homepage, a list of fictional complaints from agents about their humans and a form for adding one. The initial specification comes from a lightweight version of spec-driven development.
Three files record the mission, the technology stack and the roadmap. Normally a team would plan, build and review features separately; here the same written specs are used to request a whole implementation in each experiment.
Claude Code requires paid access, and some later hosted models require OpenRouter credit. Everitt prepares a Python project, a Git repository and virtual environment, and asks the agent to install the dependencies described in the stack.
The first implementation is a cloud baseline: Claude Code runs on the developer machine and asks Anthropic’s hosted Sonnet model to do the work. A fresh chat and the same specs give the comparison a starting point.
The prompt instructs the agent to follow the roadmap and run tests. Everitt reviews the reported issues and generated files, noting that even a link’s incorrect integrity attribute can break the page styling.
He starts the FastAPI server, checks the home and complaints pages and submits a complaint. Because the example has no database, new submissions disappear when the server restarts.
After validation, he removes the generated files to return to the starting state. The baseline is quick and relatively effortless, but provides less control over the model and where inference runs.
The baseline report separates main-agent and subagent activity. Claude Code chose to spawn a subagent even though the prompt did not require one; that helper used 54% of the context and made 61% of the tool calls in this run.
Everitt cautions against treating elapsed time as a clean benchmark: external conditions affect it, and another run can produce different numbers. The comparison is a way to understand tradeoffs rather than a universal ranking.
Fresh subagents and cheaper implementations
The coordinator delegates each phase to a fresh context, then switches its implementer to a cheaper model. Delegation protects context but adds overhead.
A long-running agent accumulates instructions, tool results and responses in one context. Everitt calls the decline that can accompany a long, messy context “context rot,” and says smaller local models have less room for it.
His remedy is to split the roadmap into phases and hand each part to a subagent with a fresh, focused context. The main agent gets a result back without having to carry the whole implementation conversation.
The new prompt still requests the entire app, but tells the main agent to delegate each phase. In this version both the main agent and the implementer use the same hosted Sonnet model.
The chat shows the separate handoffs and their results. Everitt reviews the main application, starts the server and checks the two pages and submission form before cleaning up again.
In this run main-agent context fell from 217,000 to 192,000 tokens, while subagent context rose from 257,000 to 511,000. Total context and turns increased around 50%, and tool calls about 20%; isolation had a coordination cost.
The next question is whether the detailed implementation needs the same expensive model. Everitt describes a stronger model as the planner and reviewer, and a smaller one as an implementer given a narrow, well-specified task.
A powerful model could prepare the architecture and roadmap, a mid-sized model coordinate a feature, and a cheaper one implement it. A vague plan can erase the savings if the team must pay for repeated mistakes and repairs.
Everitt selects Sonnet for the main agent and instructs the subagents to use Haiku. He asks the main agent to review the implementation, then separately runs tests and checks the application in the browser.
The example still works with the smaller implementer. Everitt emphasizes that model choice is a tradeoff: additional attempts can make a nominally cheaper model cost more and take longer.
Compared with the previous lesson, turns grew 50%, tool calls 48% and processed context 29%; average context per subagent turn fell from 21,000 to 17,000. Cost fell because more of the work ran on the cheaper model.
Choosing the agent and model provider
OpenCode and OpenRouter separate the coding harness from the cloud model. Everitt repeats the same implementation and validation.
Changing the coding agent opens more choices. Everitt installs OpenCode in his editor through the Agent Client Protocol and tests it with a hosted demonstration model before connecting other providers.
A coding agent still needs a model endpoint. OpenRouter provides one account and API connection to a catalog of hosted models, with token-based charges; it does not mean the models run locally.
He adds credit, creates an API key and configures OpenCode to use the provider. The key is a secret, and the long model list can be narrowed in configuration to the models the workflow actually uses.
Everitt selects DeepSeek V4 Pro for the hosted main agent and keeps Flash available. As model menus, agents and providers proliferate, the developer gains flexibility but also takes responsibility for choices.
Using OpenCode, OpenRouter and DeepSeek Pro, he builds the same app in one shot. He reviews the FastAPI code and template, runs the tests himself, then checks the pages and complaint submission.
The direct OpenCode run used 25 turns, 38 tool calls and about 530,000 context tokens, versus 19 turns, 28 calls and 474,000 in the earlier baseline. Its roughly two-cent cost shows a pricing difference, not proof of a better workflow.
A custom implementer and the price of coordination
A stronger model prepares work packets for a cheaper model. Smaller sessions save money in the example while the coordinator does more work.
Next he repeats the division into fresh subagents, one for each roadmap phase. The main agent coordinates while helpers carry the implementation context, and he again checks the running application.
The main agent used six turns and about 90,000 context tokens; the subagents consumed 94% of context and made 85% of calls. Compared with the direct run, total context rose 179%, calls 139% and cost nearly tripled in this example.
OpenCode can also define a specialized implementer in a Markdown file. Everitt assigns the smaller DeepSeek V4 Flash there, while DeepSeek Pro prepares the task packet and reviews the work.
A good handoff tells the implementer precisely which roadmap item to handle and gives enough context to act. The model selection lives in the subagent definition, so the user need not repeat it in every main-agent prompt.
Because the implementer is cheaper and smaller, he checks the coordinator’s review, runs tests manually and verifies both pages. Errors can become more serious as models shrink, making review and repair important.
Eight Flash implementers replaced two larger Pro helpers. Subagent context fell from 1.39 million to 882,000 tokens, but main-agent context rose from 90,000 to 712,000 as coordination expanded.
Overall context rose 8%, turns 56% and elapsed time 50%, while cost fell 28% in this run. Smaller packets lowered the burden on each implementer but did not eliminate work; they shifted some of it to the coordinator.
Serving a small model locally
LM Studio downloads and serves Gemma to OpenCode. A local endpoint changes where model inference happens.
Until now the models were hosted even though the agent and task split could be changed. Local inference requires a server on hardware the developer controls, whether a desktop or a private machine.
Everitt chooses LM Studio to download and serve a model. It has a chat interface, server controls and model search; the server supplies an endpoint that a coding agent can call.
The first target is a model that fits a 16 GB computer with some room remaining. He selects a 12-billion-parameter Gemma 4 variant and notes that local agentic coding is demanding on memory.
On Apple Silicon he selects an MLX build; for other hardware he suggests a GGUF variant. The eight-bit download is about 12.7 GB. A larger context also uses memory, so he sets a focused context and suggests lowering it if necessary.
After loading the model and starting LM Studio’s server, he tests it in chat. He then configures OpenCode with the local server URL and model identifier and checks the server log to confirm requests arrive.
The first request may be slow while the model loads, and interactive chat is not a reliable measure of agent speed. Once connected, the model is ready to serve as an implementer.
A local implementer needs scoped handoffs
A cloud coordinator prepares one small phase at a time and reviews the result. The small model operates under explicit tool and step limits.
The hybrid setup keeps the main model in the cloud through OpenRouter while a local Gemma model implements small tasks through LM Studio. Both endpoints expose a compatible API, but configuring the connection is easier than designing tasks the small model can complete.
Everitt switches the cloud coordinator to DeepSeek V4 Flash and divides the roadmap’s second phase, moving the complaint form into a separate tested phase. Smaller pieces reduce the work and context needed in one handoff.
He strengthens the implementer definition with a 12-step ceiling, permissions and disabled tools. Small models can loop, overwrite existing work, inspect irrelevant files or consume context unless the workflow gives them boundaries.
The instructions tell the implementer to work only on the assigned change, inspect current file contents and use appropriate file tools. They also direct it to run the provided tests, report the result and avoid an endless repair loop.
The user no longer requests the whole project in one shot. For each phase the coordinator prepares a handoff sized for the local model, including file details and the correct test command; the human can inspect and correct between phases.
Handoffs and agent instructions are guidance rather than guarantees. In one phase the coordinator wrote more code than requested; in another it followed the restriction. Everitt advises inspecting the packet rather than assuming consistent compliance.
After the three phases, Everitt runs tests himself, starts the server and checks the homepage, complaint list and form. The example works, but local hardware speed and small-model mistakes can make a run slower or require intervention.
The three local implementer runs averaged about 39,000 context tokens and seven tool calls each. The cloud coordinator used 69% of context and 59% of calls, demonstrating how phase isolation can move pressure to orchestration.
The metered cloud portion cost about two cents in that run, while local model usage carried no attributable API charge. Its eight-minute, 52-second elapsed time included all three sequential phases, so comparison with earlier runs needs care.
Running the coordinator locally too
A larger Qwen model handles coordination on a 32 GB machine. The local pair repairs a failed test and is checked by hand.
For the next step, the main agent must plan, prepare handoffs and review work using a local model too. A larger model can handle more demanding work, but it also consumes more memory.
Everitt selects Qwen 3.5 27B for a machine with 32 GB. Gemma already takes about 11 GB; he chooses a quantized Qwen variant to reduce memory needs, acknowledging the accuracy and capacity tradeoff.
The Q4 download is nearly 21 GB. He loads the model in LM Studio, adjusts context size, tests it in chat and adds it to OpenCode, verifying requests in the server activity log.
He repeats the three-phase workflow with Qwen as local coordinator and Gemma as local implementer. In this example the first handoff looks more useful than the one produced by the earlier cloud Flash coordinator.
The first two phases report no critical issues. The third encounters a failing test involving an HTTP redirect; the main agent prepares a repair handoff, and the tests then pass.
Everitt independently reruns the tests and checks the application pages and new-complaint form. This is a small demonstration, but it shows why a roadmap shaped for the models and human validation remain useful.
Compared with the hybrid lesson, main-agent context fell from 260,000 to 178,000 tokens while subagent context rose from 117,000 to 158,000; the combined total fell 11%. The local implementers did more iterative work.
The local run used 45 assistant turns versus six previously, but 57 tool calls versus 51. Everitt treats turns as an interaction pattern rather than a direct measure of useful work. Local execution had no metered usage charge in this accounting.
The third phase was the largest implementation task, with 12 turns, 11 calls and 69,000 context tokens, reflecting its form, submission, redirect and test requirements.
Everitt expects agent harnesses designed for smaller models to improve. Developers on machines with less memory can try more aggressively compressed models, but should evaluate the quality tradeoff.
Choosing tradeoffs rather than one tool
Everitt reviews the choices in models, providers and division of work. Local workflows are still developing.
The sequence began with a hosted default and added explicit specifications, subagents, independent providers and local models. The important skill is choosing an arrangement suited to the work rather than assuming one setup is best.
Sur la même chaîne
1:01:33EN
25:57EN
17:22EN
18:43EN
30:23EN