Wish-Based Programming: Building a Closed-Loop Practice for Autonomous Coding Agents
This article explores the shift from code completion to result delivery through "wish-based programming," where autonomous coding agents plan, code, run, verify, and fix tasks in sandboxed environments. It covers the five stages of the agent loop, self-feedback reinforcement learning, production architecture with sandboxing and observability, layered evaluation metrics, and the boundaries of which tasks are suitable for autonomous agents.
1. A Paradigm Shift: From Code Completion to Result Delivery
For the past several years, AI-assisted coding tools have operated at the level of “code snippets”: the developer writes half, the model completes the other half, and the human remains the executing agent. A new class of intelligent coding tools changes the unit of interaction to the “task”: the user provides a natural-language requirement, and the model breaks it down into steps, generates code, runs it in a controlled environment, checks the results for deviations, and iterates until it delivers a runnable, verifiable artifact. This interaction pattern—known in the industry as “wish-based programming”—essentially migrates the execution loop of software development from the human brain to an intelligent agent.
This shift brings three direct changes:
- Coarser input granularity: from function signatures and comment-level hints to requirement descriptions, acceptance criteria, and constraints.
- Stricter output contracts: the deliverable is no longer a text suggestion, but a code change that must pass compilation, tests, or static checks.
- Failure cost moves upstream: errors are exposed and fixed inside the sandbox, rather than discovered by humans during code review or in production.
It should be emphasized that this does not eliminate human responsibility. Instead, it moves the human role from “line-by-line writer” up to “requirement definer and acceptance checker.”
2. The Five Stages of the Loop and Their Engineering Implications
A workable autonomous coding loop typically consists of five stages, each with clear engineering constraints.
1. Plan
Turn a vague requirement into an executable task sequence. From an engineering standpoint, the plan must be structured and revisable, not a one-shot block of natural-language prose. A common approach is to have the model output a list of steps with dependencies, each carrying its expected verification method.
2. Code
Generate changes within the context of the existing codebase. The key factor is not generation capability but context retrieval quality: relevant files, interface definitions, and existing conventions must be recalled accurately, or the model will “invent” interfaces that don’t exist.
3. Run
Execute builds and tests in an isolated environment. This stage determines whether the loop can be trusted at all—without real execution, any subsequent “verification” is just the model’s imagination.
4. Verify
Structure the run results: compilation errors, failed test assertions, static-analysis warnings, performance metric deviations. The quality of the verification output directly determines whether the next round of fixes converges.
5. Fix
Make minimal necessary changes based on structured feedback. Engineering-wise, the scope of each fix should be constrained to prevent the model from rewriting large areas after a failure—“fixing one thing while breaking three others.”
Illustrative pseudocode (control flow only, not tied to any specific platform API):
task = parse_requirement(user_input) # requirement -> structured taskplan = agent.plan(task) # generate a revisable step sequencefor step in plan:patch = agent.code(step, context=retrieve(repo, step))result = sandbox.apply_and_run(patch) # build + test + static checksif result.passed:continuefeedback = normalize(result) # errors -> structured feedbackfor attempt in range(MAX_RETRY):patch = agent.fix(patch, feedback)result = sandbox.apply_and_run(patch)if result.passed: breakfeedback = normalize(result)if not result.passed:return escalate_to_human(task, plan, result)return deliver(patch, evidence=result.report)
Here, MAX_RETRY and escalate_to_human act as cost and safety valves: the former prevents infinite iteration from burning compute, while the latter ensures uncertainty is explicitly surfaced to humans instead of being silently swallowed.
3. Self-Feedback Reinforcement Learning: Making the Loop Improve Itself
Traditional supervised fine-tuning relies on human-labeled “correct code,” which is expensive and narrow in coverage. The idea behind self-feedback reinforcement learning is to use the loop’s own execution results as the reward signal.
- Objective reward source: unit test pass rates, compilation success, static-analysis warning counts, and whether tasks meet acceptance criteria—all automatically computable, no human scoring required.
- Dense feedback: a single task iteration can produce multiple intermediate signals, which is more conducive to convergence than the sparse “final answer right/wrong” reward.
- Self-improvement cycle: through the sample–execute–score–update loop, the model gradually learns to pass with fewer iterations—that is, to “plan better and make fewer mistakes.”
Two bias risks must be addressed in practice. The first is reward hacking: the model may learn to write code that “passes tests but has no real value” (e.g., hardcoding expected values). Mitigations include human spot checks, hidden test sets, and code quality constraints. The second is distribution shift: if dependency versions and directory structures in the training environment differ from real repositories, the learned policies won’t transfer. Training sandboxes should therefore be as isomorphic as possible to production execution sandboxes.
4. Production Architecture: Sandboxes, Context, and Observability
To turn the loop above into an operable system, three categories of general infrastructure capabilities must work together (generic capability categories only, no vendor-specific interfaces):
- Container platform: provides a disposable, resource-limited, quickly rebuildable execution environment for each task, destroyed when the task ends.
- Object storage: stores code snapshots, build artifacts, run logs, and evaluation reports as an auditable evidence chain.
- Log services and monitoring/alerting: collects iteration counts, latency, and failure-stage distribution, alerting promptly on anomalies.
- Message queues: decouple “task submission” from “long-running execution,” supporting async processing and retries.
Security boundaries cannot be omitted: the sandbox should default to no internet access, least privilege, and read-only host mounts, with writes confined to the workspace; secrets should be injected through controlled channels rather than written into code; and generated code should undergo static review before execution to guard against dangerous system calls.
5. How to Measure: Turning “Can Code” into Comparable Numbers
Autonomous coding capability should not be judged by impression. A layered evaluation is recommended:
| Dimension | Example Metrics | What It Measures |
|---|---|---|
| Effectiveness | Task pass rate, hidden-test pass rate | Real delivery capability |
| Efficiency | Average iteration rounds, average latency, token consumption | Loop convergence speed |
| Stability | Result variance across multiple runs of the same task | Reproducibility |
| Safety | Dangerous-operation interception rate, unauthorized access count | Effectiveness of boundary constraints |
| Collaboration | Human intervention rate, human rework rate | Reasonableness of human-agent division of labor |
Evaluation sets should come from real tasks in real repositories, with a portion of “never-seen-in-training” tasks reserved as a generalization check.
6. Scope of Applicability: Which Tasks Fit and Which Don’t
Suitable: tasks with clear boundaries and automatic verifiability, such as adding features with tests, fixing bugs with clear reproduction steps, large-scale refactoring and dependency upgrades, and writing scripts and data-processing pipelines.
Not suitable: tasks where requirements are highly ambiguous and acceptance criteria cannot be formalized; tasks involving irreversible production changes, permission systems, or compliance approvals; and cross-system architecture decisions. For these, the right usage is to have the agent produce proposals and prototypes while humans make the decisions and act as gatekeepers.
7. Conclusion
The value of “wish-based programming” lies not in replacing developers, but in handing verifiable, repetitive work to the loop while leaving judgment to humans. What truly determines real-world outcomes are three often-underestimated factors: the fidelity of the execution environment, the degree of structure in feedback signals, and the safety valves for iteration and cost. Building isomorphic sandboxes and a complete evidence chain on top of general cloud capabilities (containers, storage, logging, monitoring, messaging), and continuously evaluating with layered metrics, is the reliable path to moving autonomous coding agents from demos to production.
