Building a Runtime Framework for Coding Agents: From Coding Assistants to Orchestrated Systems

    This article explains why coding agents need a runtime framework that connects the model, tools, and execution environment while tracking task state. It covers layered architecture, operating modes with scoped permissions, programmatic tool orchestration, event-based tracing, context management, custom modes, evaluation criteria, and a phased plan for building such a system.

    1. Why Coding Agents Need a Runtime Framework

    Having a model generate a code snippet is different from having it complete a change in a real project.

    The first task mainly requires the model to understand the request and produce text. The second requires the system to locate the project, read files, identify dependencies, modify the implementation, run tests, analyze errors, and adjust the plan when needed. The longer a task runs and the more engineering constraints it involves, the harder it becomes to keep results stable through conversational prompts alone.

    For this reason, coding agents usually need a runtime framework layered on top of the model. The framework connects the model, tools, and execution environment, and it maintains the state a task needs to make progress.

    In simple terms, the model proposes the next action. The runtime framework checks whether the action is allowed, executes it, stores the result, and decides how to return useful information to the model.

    This does not replace the model’s capabilities. It turns those capabilities into deliverable results by providing the engineering conditions they need.

    A mature runtime framework must answer the following questions:

    • Which directories and resources does the current task allow it to access?
    • Is each tool call the model proposes permitted?
    • After a command fails, should the system retry, revise the plan, or ask a human to intervene?
    • When the conversation becomes too long, which information must be kept?
    • After a task is interrupted, how does the system return to a trusted state?
    • After a change is made, what determines that the task succeeded?

    If these questions lack clear answers, the system may occasionally complete complex tasks, but it will struggle to build stable, reusable production capability.

    2. Architecture: Separating Reasoning, Control, and Execution

    A coding agent runtime should not be built as one ever-growing loop with features added on top. A better approach is to define the responsibility of each layer clearly and reduce the coupling between the model’s decisions and the system’s control logic.

    2.1 Interaction Layer: Express the Goal Without Hiding Execution Details

    The interaction layer receives user requests, shows the plan, presents file changes, and asks for authorization when necessary.

    For development tasks, a message such as “Processing” is not enough. Users need to know what the system is reading, what it plans to change, what it has run, and which steps remain.

    Actions such as deleting files, installing dependencies, accessing external networks, and committing changes need enough context to make the approval an informed decision, not a mechanical click.

    2.2 Control Layer: Maintain Task State and Execution Boundaries

    The control layer manages planning, step scheduling, resource budgets, retry policies, and stop conditions.

    A task can move through states such as pending, running, waiting for approval, verifying, completed, and failed. State changes should be triggered by explicit events rather than depending entirely on the model to declare them in natural language.

    For example, when the model says “the tests passed,” that statement alone should not move the task to completed. The system should also check the execution record to confirm that the tests actually ran, that the exit status was normal, and that the test scope covers this change.

    2.3 Execution Layer: Provide Limited, Inspectable Capabilities

    The execution layer handles file reads and writes, command execution, content search, and other external operations.

    When designing tools, inputs, outputs, and side effects should be explicit. File editing tools need to validate path scope. Command execution tools need to manage the working directory, runtime limits, and output size. Search tools should make clear which scopes the results come from.

    The vaguer a tool description, the more likely the model is to misuse the tool. The broader the tool’s permissions, the harder it is to control the impact of misuse.

    2.4 State and Audit Layer: Store Facts, Not Just Chat Logs

    The conversation is only part of a task. Execution state, approval decisions, file changes, and tool results also determine whether a task can be resumed and reviewed.

    For this reason, the runtime framework should store structured events and link them to specific tasks and execution steps. This gives the interface, troubleshooting, and evaluation statistics a shared data foundation.

    3. Multiple Operating Modes: Different Combinations of Capabilities and Permissions

    Different tasks do not need the same set of tools every time. More capabilities do not necessarily produce better results. They can also add selection overhead, consume more context, and increase security risk.

    A better approach is to treat each operating mode as a configuration that can be reviewed.

    3.1 Comprehensive Mode: For Full Development Tasks

    Comprehensive mode suits tasks that move through understanding the project, planning, implementing changes, and running verification.

    It can provide file operations, controlled command execution, search, plan management, and task decomposition. It should still limit the workspace scope and require approval for high-risk actions.

    For example, fixing an input validation defect usually does not require access to the entire user directory, and it should not have publishing permissions by default. Whether a tool exists and whether the current task is allowed to use it are two separate questions.

    3.2 Lean Mode: Reduce Noise and Simplify Diagnosis

    Lean mode keeps only a small set of basic capabilities, such as reading files, editing files, and running controlled commands.

    It is useful for studying how a model performs with fewer supporting features, and for checking whether a complex framework introduces additional problems. However, lean mode is not a pure measurement of the model in isolation. Prompts, tool response formats, the execution environment, and context strategy all still affect the results.

    Therefore, when comparing modes, keep the task, resource budget, and acceptance criteria fixed as much as possible. This prevents configuration differences from being mistaken for differences in the model.

    3.3 Specialized Mode: Tighten Behavior Around a Task

    Code review, documentation maintenance, dependency checks, and defect fixing each call for different strategies.

    For example, a review mode can be read-only by default. A documentation mode can restrict the scope of edits. A defect-fixing mode can require reproduction evidence before any code change.

    The value of specialized modes is not in adding another name. It lies in turning experience into explicit constraints that reduce unnecessary exploration.

    4. Programmatic Tool Orchestration: Fewer Interactions, Not Less Control

    In the traditional approach, the model makes one tool call, the framework executes it and returns the result, and then the model decides the next step. This pattern is easy to observe, but it can create considerable interaction overhead when many operations are repetitive.

    Another approach lets the model generate a restricted program that organizes multiple tool operations in a single execution. For example:

    Read the list of files to check
    → Filter the files that contain the target configuration
    → Extract the key fields
    → Summarize the differences
    → Return the results that need further judgment

    This approach suits steps with clear rules, high repetition, and batch processing potential. It can reduce how often intermediate results re-enter the model’s context. However, it does not guarantee that every task will be faster or cheaper. The actual benefit depends on tool latency, the volume of returned data, and the dependencies between tasks.

    More importantly, programmatic orchestration must be controlled:

    • It may access only explicitly authorized tools and resources.
    • It must limit execution time, concurrency, and output size.
    • It must define whether the program stops or keeps partial results when an error occurs.
    • Write and delete operations, which have side effects, require separate authorization.
    • The system should record key internal operations, not just the final summary.

    A failed batch job cannot simply be rerun. Read-only operations are usually safe to retry, but write operations that have partly completed may produce duplicate changes. The framework should distinguish idempotent operations from non-idempotent ones and require human confirmation where necessary.

    5. Event Trace: Making Execution Inspectable and Recoverable

    A reliable runtime record should not be just chat text plus a few terminal outputs. It should be a set of ordered, typed, and linked events.

    Events can include task creation, context loading, tool requests, policy checks, approval results, execution completion, file changes, verification results, and task termination.

    Each event should carry the identifiers needed to answer three questions:

    1. Which step triggered this operation?
    2. What information was visible to the system at the time of the operation?
    3. What result and side effects did the operation produce?

    It is important to distinguish recorded information from the model’s internal reasoning. The framework can record request content, visible outputs, and tool interactions. It should not claim to capture the model’s complete internal thinking. Reviews should rely on observable evidence, not on speculation about internal mental processes.

    5.1 Replaying a Log Is Not Reproducing an Execution

    Replaying an existing log shows events that already happened. Running the same task again may produce different results.

    Model output, external resources, timing, and file state can all change. To improve reproducibility, the system should also save the workspace version, key configuration, tool versions, and necessary environment information.

    Be especially careful with external writes. Replaying an interface record should not automatically resend messages, modify remote resources, or trigger publishing actions.

    5.2 Logs Also Need Security Governance

    Tool outputs may contain access credentials, personal information, or internal code. Logs kept for auditing should not be stored indefinitely or without discrimination.

    A sound design includes redaction of sensitive information, access control, retention periods, and review before export. For content that should not be persisted, the system can keep the status, a summary, or a verification value instead of the full original text.

    6. Context Management: Keep the Basis for Decisions, Not an Unlimited History

    In long tasks, the bottleneck is often not a lack of information but too much of it.

    Repeated file contents, lengthy command outputs, and outdated plans consume the model’s attention. Old conclusions can keep interfering with new decisions.

    A safer way to organize context is to separate three types of information:

    • Task constraints: the user’s goal, prohibited actions, and acceptance criteria.
    • Current state: modified files, verification results, and open issues.
    • On-demand evidence: source code excerpts, historical outputs, and search results.

    The first two types should be maintained consistently. The third should be loaded only when needed.

    When summarizing historical content, keep the key failure reasons, unverified assumptions, and explicitly prohibited operations. Context compression must not turn “uncertain” into “confirmed,” and it must not treat the model’s guesses as facts about the project.

    7. Custom Modes: Building Blocks With Clear Boundaries

    An important direction for runtime frameworks is combining tools, prompt constraints, workflows, and verification rules into reusable modes.

    For example, an “interface change check” mode could be defined as follows:

    • Goal: identify the compatibility impact that this change may cause.
    • Input: the change scope and related notes.
    • Permissions: read-only access to the specified directories.
    • Steps: extract the changes, locate call relationships, and check test coverage.
    • Output: a risk list, evidence locations, and items that need confirmation.
    • Stop conditions: complete the specified scope check, or reach the budget limit.

    This is more actionable than an instruction such as “You are a rigorous review expert,” because it defines the goal, the capability boundary, and the acceptance requirements together.

    The model can help draft a mode, but the draft should pass configuration validation, permission review, and an isolated trial run before a person approves it. The model must not be able to create a new mode that grants itself permissions it did not have.

    The more capable the composition, the more important the component contracts become. Components with vague inputs, outputs, or error handling may work correctly on their own, but they can form failure chains that are hard to diagnose once combined.

    8. Evaluating the Framework, Not Just the Demo

    Evaluating a coding agent should consider both the delivered result and the execution process.

    At minimum, build evaluation around the following dimensions:

    • Correctness: whether the change meets the acceptance criteria and avoids regressions.
    • Efficiency: completion time, number of interactions, resource consumption, and amount of human intervention.
    • Reliability: recovery after interruptions, error handling, and consistency across repeated runs.
    • Security: unauthorized access, exposure of sensitive information, and control of high-risk operations.
    • Auditability: whether the system can locate the failed step and explain key state changes.

    Test tasks should not include only smooth cases. They should also cover incomplete requirements, unstable tests, unavailable dependencies, insufficient permissions, and interrupted execution.

    In addition, stopping correctly without finishing can be more valuable than appearing to finish without verification. A mature system knows when to continue, when to ask for help, and when to refuse actions that exceed its authority.

    9. Rollout Path: Build a Closed Loop First, Then Add Autonomy

    For teams that plan to build a runtime framework, start with tasks that have a clear scope, such as localized bug fixes, test additions, or documentation updates.

    In the first phase, establish a controlled workspace, basic tools, event recording, and a manual approval process. This makes sure every change has evidence that can be reviewed.

    In the second phase, add task state, context summaries, failure handling, and recovery, so that an interrupted task can resume instead of starting over from guesswork.

    In the third phase, introduce programmatic tool orchestration, parallel subtasks, and custom modes, while setting up configuration review and continuous evaluation.

    The guiding principle across all phases is to show that the system can safely complete small tasks first, and only then expand its operating scope and level of autonomy.

    Competition among coding agents will depend on more than how much code a model can write. It will depend on whether the whole system can turn uncertain reasoning into engineering workflows that are verifiable, recoverable, and auditable. What is worth building is not a chat interface with ever more tools, but a system with clear boundaries, composable components, and results backed by evidence.