Intent-Driven Programming: How to Reduce Costs for Long-Running AI Agent Tasks

    A racing game prototype shows where a one-line prompt is enough and where engineering discipline takes over. This article explains how structured task cards, execution-layer guardrails, and automated acceptance checks turn a runnable prototype into a verifiable deliverable. It also outlines how to measure and reduce end-to-end agent costs without lowering the task success rate.

    A model update that demonstrated intent-driven programming renewed interest in a familiar idea: describe an application in one sentence and get something you can run. The more useful question is how to make that process repeatable. Using a small racing game as an example, this article connects three practices: expressing intent in natural language, enforcing limits at the execution layer, and reducing the cost of long-running agent tasks.

    1. What Intent-Driven Programming Can and Cannot Do

    Intent-driven programming lets developers describe a goal in natural language and delegate planning, code generation, revisions, and verification to an AI coding tool. Its strength is rapid prototyping. A one-line request for a racing game with a drivable car, a track, a timer, and both cockpit and chase-camera views can quickly produce a start screen and a playable core loop. For exploratory work, that shortens the path from idea to runnable software.

    But a runnable prototype is not necessarily ready to deliver. A one-line prompt rarely specifies acceptance criteria, visual constraints, nonfunctional requirements, or edge cases. The first version may look complete and play through while still missing the intended visual style, level of detail, or driving feel. The problem is not that intent-driven programming failed; it is that the request was not specific enough to verify the result. For delivery-oriented work, turn the prompt into a structured task card that captures the goal, acceptance criteria, constraints, available resources, prohibited actions, and budget.

    1. {
    2. "goal": "Build a racing game prototype",
    3. "acceptance": [
    4. "The car can accelerate, brake, and steer",
    5. "The track has boundaries and provides collision feedback",
    6. "The timer can start, stop, and reset",
    7. "Players can switch between cockpit and chase-camera views"
    8. ],
    9. "constraints": {
    10. "style": "Low-poly racing visuals",
    11. "ui": "Three screens: start, gameplay, and results",
    12. "performance": "No noticeable stutter during key interactions"
    13. },
    14. "budget": {
    15. "max_tokens": "Set based on task complexity",
    16. "max_tool_calls": "Set based on toolchain complexity",
    17. "max_loops": "Set based on the planned number of iterations"
    18. },
    19. "observability": ["Runtime logs", "Screenshots at key moments", "Acceptance check results"]
    20. }

    A task card replaces “this looks good enough” with criteria the team can check. Use the initial prompt to get a working skeleton, then use acceptance criteria to determine whether it is ready to deliver.

    2. What Drives the Cost of Long-Running Agent Tasks?

    A long-running agent task involves more than a single request and response. It may include multiple model requests, tool calls, execution loops, growing context, retries, and verification. Five sources of overhead matter in particular:

    1. Context growth. Carrying the full conversation history, tool results, and code snippets into every round increases token usage as the task progresses.
    2. Unnecessary output. Repeated plans, lengthy explanations, and content unrelated to acceptance checks consume tokens without advancing the task.
    3. Excessive iteration. A poorly scoped plan can lead to repeated edits to the same file or retries that do not address why a tool call failed.
    4. Verbose tool results. Unfiltered logs, directory listings, and build output add material the model may not need.
    5. Missing acceptance checks. Without automated verification, teams rely on manual judgment, and the resulting rework raises the actual cost.

    Even if unit prices stay the same, a task can cost less if it takes fewer tokens, tool calls, iterations, and retries to complete. The relevant trade-off is between cost and success rate: a Pareto improvement means lowering cost without reducing success, or improving success without increasing cost. Measure the full task, not just the price of an individual model request.

    3. Execution-Layer Guardrails

    The execution layer sits between the agent and its environment. It manages tool calls, sandboxing, permissions, timeouts, retries, logs, and acceptance checks. These controls keep long-running tasks bounded and make cost reductions more predictable.

    • Allowlist tools and apply least privilege. Expose only the files, commands, and network access the task requires. This reduces accidental changes and unnecessary exploration.
    • Enforce timeouts and budgets. Cap iterations, tool calls, and token usage. If a limit is reached, stop and return diagnostics.
    • Use structured outputs. Require a structured format for plans, tool arguments, and verification results to reduce parsing failures and repetitive explanations.
    • Trim and summarize tool results. Keep error lines, relevant paths, and acceptance evidence rather than passing raw output into the context.
    • Use idempotency and caching. Reuse results for repeated reads, builds, and queries instead of spending tokens on the same information again.
    • Run acceptance checks early. Run a script or checklist at the end of each iteration. If a check fails, fix the specific issue instead of starting over.

    The following pseudocode illustrates a budget check in the execution loop:

    1. def run_agent(task, budget):
    2. state = init_state(task)
    3. plan = planner(task, state)
    4. for step in plan:
    5. if budget.exceeded():
    6. return fallback_with_diagnostics(state)
    7. action = policy.select(step, state)
    8. result = execute_with_sandbox(action)
    9. state = update_state(state, summarize(result))
    10. if verifier.accept(task.acceptance, state):
    11. return state
    12. return targeted_repair(task, state)

    The loop illustrates three principles: stop when the budget is exhausted, summarize tool results before adding them to the agent’s context, and stop as soon as the acceptance checks pass. Each targets unnecessary token use or extra iterations.

    4. Two Iterations on a Racing Game Prototype

    The first iteration starts with a single sentence: “Build a racing game with a drivable car, a track, a timer, and cockpit and chase-camera views.” That can quickly yield a start screen and a playable game, even if the visuals and details fall short. The prompt is useful for getting from nothing to something runnable, but it does not establish what counts as done.

    For the second iteration, refine the prompt and task card. Specify low-poly visuals, the start, gameplay, and results screens, the desired acceleration, braking, and steering feel, the track boundaries and collision feedback, timer controls, a camera-switch shortcut, the UI layout, a performance budget, and an acceptance checklist.

    The execution layer captures screenshots at key moments, runtime logs, and verification results. The verifier checks that required elements are present, key presses register, the timer updates, the camera switches, and the car slows down on collision. If the first version is already playable, make targeted fixes rather than regenerating the whole game. This avoids spending tokens and iterations on functionality that already works.

    A repeatable order is to verify the complete gameplay loop first, then assess how the controls feel, check visual consistency, and finish with regression checks and a cost review. Address one class of problems per iteration rather than asking the agent to change everything at once.

    5. Measure Cost Alongside Success

    At a minimum, track token usage per task, tool calls, iterations, retries, acceptance pass rate, end-to-end latency, and how often manual rework is needed. The evaluation set should include simple tasks, long-running tasks, and tasks that require recovery from failure. Keep execution logs so runs can be replayed.

    The goal is not to minimize any one metric in isolation. It is to lower end-to-end cost without sacrificing the task success rate. Structured task cards define what success looks like, execution guardrails bound the work, and acceptance checks tell the agent when to stop. Together, they turn a one-line demo into a repeatable engineering process.