After this, you'll be able to classify any background agent task as hosted-suitable or self-hosted-required, and explain the tradeoffs that drive that decision.
Before you start
Complete Stale Context Is Not a Stale Bug first; this lesson builds on coordination overhead so you factor branch-isolation complexity into the hosted-vs-self-hosted tradeoff.
The idea
Here is the before and after: You want to refactor a public utility module. You could connect it to Devin or OpenAI Codex cloud: paste the task, get a PR in 10 minutes, no setup required. Or you could run Claude Code in headless mode on your own machine: more setup, but it can read your internal fixtures, call your private APIs, and apply your custom CLAUDE.md rules. Which one? It depends entirely on what the task needs.
Hosted agents (Devin, OpenAI Codex cloud, GitHub Copilot Workspace) run in the provider's cloud. You give them a task, they open a PR. No machine to configure, no session to manage. The cost is less control: the agent uses the provider's environment, its tool set, and its data handling policy.
Self-hosted agents (Claude Code in headless mode, open-source orchestrators you run yourself) run on infrastructure you control. You can access your local environment, proprietary context, private API keys, and custom hooks. The cost is setup and maintenance.
The decision is simpler than it looks. Use hosted when: the task is bounded and well-specified, the codebase can be shared with the provider, no proprietary secrets are involved, and lower execution visibility is acceptable. Use self-hosted when: the task requires internal secrets or tools, the codebase cannot leave your infrastructure, you need custom approval hooks, or you need to call services with no cloud equivalent.
Desktop path: if you use Claude.ai web, hosted agents are your natural starting point. Connect your GitHub repo to a hosted provider and run bounded tasks there. For anything requiring your local environment, switch to Claude Code CLI in headless mode.
CLI path: `claude --headless` runs Claude Code as a self-hosted agent on any machine you control, with full access to your local context and custom CLAUDE.md.
Most production L9 teams use both. The skill is knowing which is which before you dispatch.
Try it (15 min)
Watch out for
Paste this into Claude:
I want to classify my background agent tasks as hosted-suitable or self-hosted-required. Here are 5-6 tasks I run or want to run as background agents: [list your tasks, e.g. 'refactor a public utility module', 'update all doc comments', 'run the security scan and open an issue', 'generate integration tests using our internal test fixtures', 'update the public API changelog']. For each task, evaluate: (1) Does it require proprietary secrets or internal tools? (2) Can the codebase context be shared with a hosted provider? (3) Is the task well-specified enough for a hosted agent's standard environment? (4) What is the blast radius if the hosted agent makes an unexpected change? Then give me a hosted/self-hosted verdict for each task with a one-sentence reason.
What good looks like:
When this breaks
Claude can do it for you
Say to Claude: 'I have these background agent tasks: [list]. For each one, tell me: hosted or self-hosted, and what is the deciding factor. Then draft the one-page decision guide I can share with my team so they can classify new tasks themselves.'
You can now
Classify five tasks as hosted or self-hosted with a specific deciding factor for each, and write a one-sentence team rule that any teammate could apply to a new task without re-litigating the decision.
Key takeaways
Hosted for bounded, well-specified, shareable tasks. Self-hosted for proprietary context, custom tooling, and tight blast radius control. Most mature setups use both.