LLM Planning and Execution Separation: A Practical Guide to Optimizing Token Allocation
As LLMs enter the software engineering workflow, the developer pain point is shifting from "is the model smart enough" to "how should token quotas be allocated efficiently." This article introduces a vendor-neutral architecture that separates planning from execution: a strong reasoning model reads the repository and writes plans, while a local coding agent modifies files and runs tests. The two roles are connected by a local bridge service, a temporary encrypted tunnel, and a structured handoff protocol stored in the repository, keeping conversational and agent quotas isolated. It covers architecture principles, capability boundaries and security design, one-time setup, daily startup, a full walkthrough on a real project, troubleshooting, and efficiency tips—helping you get more out of existing quotas without extra cost.
As large language models are adopted across the software engineering workflow, the developer pain point is shifting from “is the model smart enough” to “how should token quotas be allocated to get the most value.” Complex tasks demand stronger planning capability, while shipping actual code requires a coding agent that can read and write repositories and execute commands. These two needs often belong to different products and separate billing pools, leaving one quota idle while the other is exhausted early. This article takes a neutral view and abstracts a class of “planning and execution separation” collaboration architectures: a model with strong reasoning and decomposition skills reads the project and writes the plan, a local coding agent changes files and runs tests, a local service and an encrypted tunnel connect the access path, and all plans and execution records are persisted to disk to form an auditable handoff protocol. The discussion covers architecture principles, capability boundaries and security design, one-time configuration steps, daily startup, a complete walkthrough on a real project, troubleshooting for common failures, and efficiency recommendations—so you can spend existing quotas where they matter most without adding cost.
1. The Problem: Why a Single Model Struggles to Both “Think It Through” and “Get It Done”
In real engineering work, a task usually contains two fundamentally different kinds of work. The first is cognition-intensive: reading requirements, mapping the existing implementation, judging the blast radius, and breaking the work into verifiable steps. The second is operation-intensive: editing multiple files, running builds and tests, and retrying based on failure output. The former depends on long-context understanding and stable reasoning; the latter depends on tool invocation, permission control, and repeatability.
When both kinds of work are squeezed into the same session and the same quota, three typical problems surface:
- Quota mismatch: planning consumes conversational quota while execution consumes agent quota. Mixing them often means “plenty of quota while thinking, not enough while changing code.”
- Context pollution: the volume of logs, errors, and temporary file content produced during execution crowds the context window and degrades the quality of later planning.
- Blurred responsibility boundaries: when the model both proposes and implements, it is hard to tell whether a failure came from a bad plan or a bad implementation, making rollback and auditing harder.
The industry is therefore converging on a shared understanding: split “planning” and “execution” into two roles, each using the most suitable model and quota pool, connected by a structured, versionable handoff artifact. This is both a cost issue and an engineering quality issue.
2. Solution Overview: Two Roles Plus a Plan on Disk
The recommended architecture boils down to “one bridge service + two roles + one handoff protocol.”
- Planning role: runs on the conversational side, excels at complex requirement analysis and task decomposition, and only outputs plans without touching source code.
- Execution role: runs as a local coding agent that can read and write the workspace, run controlled commands, execute tests, and write results back.
- Bridge service: a local service process that exposes a controlled interface through an encrypted tunnel so the conversational side can reach a specific repository.
- Handoff protocol: all plans, execution records, and failure reasons are written to a dedicated directory inside the repository, forming a machine-readable and human-reviewable state machine.
The key benefit of this design is quota isolation: planning draws on conversational quota, execution draws on agent quota, and neither crowds the other. For developers whose daily conversational quota goes unused, this turns idle resources into project progress.
Note that this article recommends the handoff mode: the planning role only “thinks it through and writes it down,” and the execution role “builds to spec.” This trades a bit of automation for controllability, rollback capability, and auditability, which is usually the safer choice in real projects.
3. How It Works: Local Service, Controlled Access, and the State Directory
The bridge service exposes the local repository to the planning role in the most minimal way possible, typically through four read-only or controlled capabilities:
- File tree reading: lets the model understand directory structure, module boundaries, and naming conventions.
- Source reading: reads key files on demand instead of loading the entire repository at once.
- Version state reading: reads the current branch, change list, and recent commits to determine the project state.
- Handoff directory read/write: reads historical plans and execution records, and writes new plan files.
Three security ground rules apply:
- Minimal exposure: expose only the current project directory; do not mount parent directories or the home directory.
- Read-only first: source and version state are read-only by default; write access is limited to the handoff directory.
- Credential isolation: generate an independent token per session; the tunnel address is temporarily valid and expires when the session ends.
A schematic directory and plan layout follows (illustrative only, not tied to any specific implementation):
your-project/.ai-bridge/plan-20260901-01.md # Plan for this taskexec-log-20260901-01.md # Execution record and test resultsstate.json # Task state: planned/running/done/failedsrc/tests/
A solid plan should contain fixed fields so the execution role can build without ambiguity:
# GoalA one-sentence, verifiable definition of done# Constraints- Do not change public interface signatures- Do not introduce new runtime dependencies# Steps1. Locate the entry file and call chain2. Modify the implementation and add unit tests3. Run formatting, static checks, and tests# Acceptance- The specified test command passes fully- No new warnings on critical paths
4. One-Time Setup: Environment and Initialization
Configuration is done once; after that, a single command starts everything each day. Four baseline conditions are recommended on the environment side:
- Runtime: Node.js 20 or later, used to run the bridge service.
- Conversational subscription: a conversational service with application and developer mode capabilities (described here as a generic capability).
- Local coding agent: installed and verifiable from the command line.
- Project conditions: an initialized Git repository with a workspace kept as clean as possible.
Sample self-check commands:
node -v # expect v20 or highercodex --version # expect a version number; the exact name depends on your local installationgit status -s # expect empty output or only expected changes
Recommended choices during initialization:
- Workspace: the current project directory, to avoid mixing multiple projects.
- Mode: handoff, with planning and execution separated.
- Command execution: safe, allowing only whitelisted read-only or low-risk commands.
- Tunnel: a temporary encrypted tunnel that requires no domain of your own, suitable for initial validation.
After initialization, the system automatically starts the local service, generates a session token, establishes the tunnel, and copies the access address to the clipboard. You can then paste that address into the application entry on the conversational side to complete the binding.
5. Daily Use: One-Command Startup and a Full Walkthrough
The daily flow compresses into three steps.
Step one, start the bridge:
codexpro start # sample command; use whatever your chosen tool provides
Step two, issue a planning request on the conversational side, for example: “Read the repository and the latest execution record, produce a fix plan for the intermittent login API timeouts, write it to the handoff directory, and do not modify source code.” The planning role then produces the plan file and a state marker.
Step three, return to the local machine and let the execution role build to spec:
Read the latest plan with state planned in .ai-bridge, implement it step by step, run the tests, and write the execution record back.
After execution, the state directory holds a complete “plan—changes—tests—conclusion” chain. If tests fail, the execution role should write a failure summary back to the record rather than blindly retrying; the planning role then revises the plan based on that failure information, forming a second iteration. This loop is more reliable than a single long instruction.
6. Boundaries, Risks, and Troubleshooting
- Tunnel interruption: usually caused by network restrictions; reconnecting is enough. For production, switch to a long-term solution with access control.
- Excessive permissions: if broad command execution was enabled, revoke it when the task ends and clear temporary tokens.
- Context bloat: read only file fragments relevant to the task; avoid loading the whole repository.
- Plan drift: stick to “plan to disk first, then execute,” and append any change as a new plan file instead of verbal increments.
- Sensitive data: never write keys, connection strings, or user data into the handoff directory; exclude them with ignore rules before committing.
7. Efficiency Recommendations
- Task slicing: keep each plan within a scope that can be verified in one pass; small steps make problems easier to locate.
- Dual-pool parallelism: planning and execution can advance different tasks in parallel, making full use of the two independent quotas.
- Record reuse: fix stable acceptance commands into project scripts to reduce repeated description in every plan.
- Measure and improve: track the “first-pass plan acceptance rate” and “average iteration rounds,” and let data drive process improvement.
Overall, using high reasoning capability for planning and tool execution capability for implementation, connected by a controlled bridge and a structured handoff protocol, is an effective path to raising the success rate of complex tasks without additional spending. The payoff is not only better quota utilization, but systemic gains in auditability, rollback, and continuous improvement of the engineering process.
