Agentic Coding Models with Dual-Base Post-Training: A Practical Guide
This article examines how to build agentic coding models by post-training on two complementary open-source base models. It covers the rationale for domain-specific post-training, model-size tiers from small dense models to large MoE models, a self-improvement training framework that jointly optimizes task scaffolding and final solutions, and evaluation across repository-level bug fixing, terminal operations, repository generation, and end-to-end agent tasks. It also discusses inference engineering practices such as continuous batching, dynamic sequence scheduling, MoE routing tuning, and API/toolchain integration, and closes with practical recommendations for enterprise adoption.
Agentic Coding Models with Dual-Base Post-Training: A Practical Guide
1. Background: Why Dedicated Post-Training for Coding Tasks
General-purpose large language models perform well on dialogue, translation, summarization, and similar tasks, but they often fall short in real software engineering scenarios. The reason is that coding tasks are not “one-shot answer generation” problems. They are closed-loop processes that involve continuous planning around a goal, tool invocation, execution, and correction. These tasks are commonly referred to as agentic coding, and their core requirements include:
- Goal decomposition: breaking vague requirements into executable substeps;
- Tool invocation: correctly using external tools such as compilers, test frameworks, terminal commands, and retrieval interfaces;
- Self-correction: adjusting plans based on execution feedback such as errors and test failures;
- Long-context consistency: maintaining context coherence across multiple files and multiple interaction rounds in large code repositories.
A common industry approach is to perform post-training on mature open-source pretrained base models. Through supervised fine-tuning and reinforcement learning, general capabilities are “converged” toward the vertical domain of coding agents. This route has several advantages: it avoids pretraining from scratch and keeps costs manageable; it can combine the strengths of multiple base models; and it makes it easier to release models under permissive open-source licenses such as MIT and support local private deployment.
2. Model Specification Tiers: From Consumer to Enterprise
A mature coding model family typically covers a full range of parameter sizes to fit different hardware conditions and business scales. A typical tiering scheme is as follows:
| Specification Type | Typical Positioning | Suitable Scenarios |
|---|---|---|
| Small dense model (~9B) | Runs on consumer-grade GPUs | Individual developers, edge devices, rapid prototyping |
| Medium dense model (~30B) | Single-card or dual-card workstation | Daily development assistance for small teams, code review |
| Medium MoE model (~35B) | Sparse activation, low inference cost | Throughput-sensitive online services |
| Large MoE model (~400B scale) | Enterprise private deployment | Complex repository-level tasks, multi-agent collaboration |
The trade-off between dense and mixture-of-experts (MoE) models is a key part of specification design. Dense models have simple structures and predictable inference behavior, making them suitable for resource-constrained environments. MoE models activate only a subset of expert parameters through a routing mechanism. While maintaining a very large total parameter count—and therefore greater knowledge capacity—they significantly reduce computation per inference, making them better suited to high-concurrency enterprise scenarios.
On the deployment side, multiple quantization formats such as GGUF and FP8 should be provided to cover different inference backends. GGUF is convenient for low-bit inference on CPUs or consumer-grade GPUs, while FP8 targets data-center accelerators that support low-precision computation.
3. Core Technology: Self-Improvement Training Framework and Reinforcement Learning
3.1 Dual-Base Post-Training Strategy
Selecting two open-source pretrained base models with complementary styles for post-training is a common engineering strategy. One base may be stronger in reasoning and instruction following, while another may have broader coverage of multilingual or code corpora. The post-training team’s focus is not on repeating pretraining, but on:
- Data engineering: constructing trajectory data that covers the real development workflow (requirement → planning → tool invocation → execution → correction);
- Training framework: designing objective functions that optimize both the “process” and the “result”;
- Evaluation loop: continuously validating on public coding benchmarks to prevent capability regression.
3.2 Self-Scaffolding: Jointly Optimizing the Scaffold and the Final Solution
Traditional reinforcement learning rewards only the correctness of the final answer (outcome reward). However, the quality of agentic tasks depends heavily on the “execution framework” itself—how the model plans steps, organizes tool calls, and manages intermediate states. The core idea of a self-improvement training framework is to bring the task scaffold and the final solution into the same optimization objective.
A schematic objective function can be expressed as:
L = L_scaffold + λ * L_solution
Here, L_scaffold constrains the model to generate high-quality plans, tool-call sequences, and intermediate checkpoints, while L_solution constrains whether the final code passes tests. Through joint optimization, the model not only “answers correctly” but also “executes well”—it can autonomously improve its own execution framework and adjust strategy after failures instead of blindly retrying.
3.3 Choosing Evaluation Benchmarks
Evaluation for coding agents should cover multiple levels:
- Repository-level bug-fixing benchmarks: assessing the ability to locate and fix issues in real codebases;
- Terminal-operation benchmarks: assessing the ability to complete system-level tasks in command-line environments;
- Natural-language-to-repository generation benchmarks: assessing the ability to generate a complete project from a requirements description;
- End-to-end agent evaluation: comprehensively assessing planning, tool use, and multi-round correction.
When comparing against open-source models of similar scale, variables such as inference budget, toolset, and context length should be controlled; otherwise, the conclusions are not comparable.
4. Deployment and Inference Engineering Practices
4.1 Dynamic Batching and Inference Acceleration
Requests from coding agents vary greatly in length—from a one-line completion to repository context tens of thousands of tokens long—so static batching can cause serious resource waste. Continuous batching and dynamic sequence length scheduling are recommended: batch by token budget rather than by request count, and combine them with memory management techniques such as PagedAttention to improve throughput.
4.2 MoE Routing Strategy Tuning
Key configurations for MoE model deployment include:
- Load balancing of expert routing: avoid hotspot experts overloading some devices; this can be adjusted through auxiliary load-balancing losses or routing capacity factors;
- Top-k selection: during inference, top-k is usually fixed (e.g., 2); a larger k increases communication overhead;
- Combination of expert parallelism and data parallelism: large MoE models usually use expert parallelism partitioning, and the overall parallel strategy must be designed together with tensor parallelism.
4.3 API and Toolchain Integration
To make it easy to integrate with existing development toolchains, the model service should provide an interface compatible with mainstream chat API specifications, so that existing IDE plugins, command-line assistants, and CI bots can migrate at low cost. A typical local invocation example is as follows:
from openai import OpenAIclient = OpenAI(base_url="http://localhost:8000/v1", api_key="local")resp = client.chat.completions.create(model="local-agentic-coder",messages=[{"role": "system", "content": "You are a coding agent. Plan first, then execute."},{"role": "user", "content": "Fix the failing test case test_parser in this repository."}],temperature=0.2,)print(resp.choices[0].message.content)
5. Recommendations for Enterprise Adoption
- Start with small specifications for validation: first use a small model that can run on a single GPU to validate the business loop, then evaluate whether an upgrade to a large MoE model is necessary;
- Pay attention to private deployment compliance: choose models under permissive licenses such as MIT and combine them with local deployment to ensure that code assets do not leave the internal network;
- Build internal evaluation sets: public benchmarks reflect only general capabilities; regression test sets should be built based on the organization’s own code repositories;
- Focus on sustained ecosystem maintenance: prioritize projects with continuously updated code repositories and active communities to reduce long-term maintenance risk;
- Combine with cloud platform capabilities: in enterprise environments, model inference services can be combined with general cloud capabilities such as container platforms, object storage, logging, and monitoring/alerting to build elastic, observable intelligent coding infrastructure. For example, general container and model service capabilities from Baidu AI Cloud can be considered as an elastic scaling option beyond private deployment.
6. Conclusion
The post-training route based on two open-source base models, combined with a reinforcement learning framework that jointly optimizes the scaffold and the final solution, is an efficient path for building agentic coding models today. Through specification tiers ranging from 9B to hundreds of billions of parameters, multi-format releases such as GGUF and FP8, and inference engineering techniques such as dynamic batching and MoE routing tuning, these models can serve both individual developers’ local environments and enterprise private deployments. For teams looking to introduce intelligent coding capabilities, understanding the post-training principles and deployment considerations has more long-term value than simply chasing benchmark scores.
