# Emergent Coding and Cybersecurity Capabilities in LLMs: Observations from Long-Horizon Agent Training

    How do large language models develop frontier coding abilities and emergent cybersecurity skills? This article examines the shift from single-turn code generation to long-horizon agent evaluation, breaking down what "capability emergence" actually means across software engineering benchmarks, cybersecurity ranges, and multi-turn agent tasks. It covers why smaller models with mature architectures, high-quality post-training, and reinforcement learning can now rival larger models on long-horizon tasks, the engineering significance of scaling sandbox environments, adaptive optimization with interactive REPL workflows, and the risks of reward hacking, environment overfitting, and dual-use security capabilities. Developers and engineering teams will find practical guidance on building evaluation systems, process metrics, sandbox governance, and cost accounting for agentic AI workflows.

    1. Reframing Evaluation: From Single-Turn Generation to Long-Horizon Agents

    Any serious discussion of “frontier coding ability” and “emergent cybersecurity capability” in large language models must start with a change in what we’re actually evaluating. Coding ability used to be reduced to single-turn code generation: given a function signature or a natural language description, the model outputs a snippet, and we measure pass rates on unit tests. But real software engineering and security tasks are rarely completed in a single turn. Fixing a defect typically means reading the repository, tracing the call chain, reproducing the issue, modifying code, running tests, analyzing failure logs, and iterating. A security analysis task may require enumerating attack surfaces, constructing verification cases, triaging false positives, assessing impact scope, and producing remediation advice. What these tasks share is long-horizon interaction, state dependency, dense tool calling, delayed feedback, and high noise.

    Frontier coding ability, then, is better understood as a projection of broader “long-horizon agent capability”: the model must not only write code, but also maintain goals across many tool interactions, manage context, verify intermediate results, and recover from failures. Cybersecurity capability adds further requirements around adversarial input, stealth, and risk boundaries. Evaluating these abilities means looking beyond one-shot accuracy at stability across dozens of interaction turns, quality of strategy selection, error propagation control, and final task closure rates.

    Technically, capability gains don’t come from parameter count alone. Architecture choices, post-training data quality, reinforcement learning strategy, tool environment richness, and the scale of parallel sandboxes all significantly affect long-horizon performance. A notable recent signal from the industry: some models with relatively smaller parameter counts approach or even exceed larger models on several coding and cybersecurity long-horizon benchmarks. This doesn’t mean scaling laws have failed — it suggests that the scaling dimensions are expanding from raw parameters to training environments, interaction turns, and post-training strategies.

    2. Breaking Down Evaluation Dimensions: Coding, Cybersecurity Ranges, and Long-Horizon Tasks

    Professional evaluation of capability emergence requires decomposing benchmarks into interpretable dimensions.

    2.1 Software Engineering Tasks: From “Writing Correct Code” to “Fixing and Verifying”

    Software engineering benchmarks typically cover defect localization, code completion, test generation, refactoring, and repository-level changes. For long-horizon agents, the key metrics go beyond whether the final patch is correct:

    • Can the model locate relevant files and functions within a limited number of turns?
    • Can it construct reproducible failing test cases?
    • After making changes, can it run tests and explain the failure reasons?
    • Does it avoid introducing regressions?
    • Can it keep the task goal from drifting when context is constrained?

    These tasks typically require 30 to 80 interaction turns, which demands strong “process management” capability. Strong single-turn generation does not necessarily imply strong long-horizon repair; the latter depends far more on tool-use strategy and state compression.

    2.2 Cybersecurity Ranges: High Adversarial Pressure and High Cost of False Positives

    Cybersecurity benchmarks resemble live-fire range exercises: the model must perform reconnaissance, vulnerability verification, impact assessment, and remediation within a controlled environment. Compared with ordinary coding tasks, three difficulties stand out:

    • Adversarial input: logs may be misleading, code may be obfuscated, and prompts may be deliberately deceptive.
    • High false-positive cost: a wrong judgment about exploitability carries serious engineering consequences.
    • Strict boundary requirements: the model must operate within authorized scope, never escalating privileges or executing destructive actions.

    So “emergence” in cybersecurity capability cannot be judged by the number of discovered attack surfaces alone. Verification quality, false-positive rate, actionability of remediation advice, and adherence to security constraints all matter. A model that surfaces more leads but produces excessive false positives has limited practical value.

    2.3 Long-Horizon Agent Evaluation: Process Matters More Than the Answer

    Long-horizon agent benchmarks typically track task completion rate, interaction turns, tool-call success rate, failure recovery rate, and context compression quality. Evaluations should introduce process metrics rather than fixating on final scores, for example:

    • Does each turn produce meaningful information gain?
    • Does the model repeat ineffective operations?
    • Does it adjust strategy after failure?
    • Can it degrade gracefully when tools return errors?
    • Does it remain planful near the turn limit?

    These metrics map more closely to real development and security operations, and better reveal whether “capability emergence” is sustainable.

    3. Architecture and Post-Training: The Engineering Logic of the Small-Model Route

    Based on public technical discussions, some models haven’t fully switched to fundamentally new architectures. Instead, they follow a combined route — modifying a mature architecture, applying high-quality post-training, and adding reinforcement learning — and achieve competitive long-horizon performance at smaller parameter scales. The technical implications deserve closer examination.

    3.1 Post-Training Determines the “Usability Ceiling”

    Pre-training provides general knowledge and language ability; post-training determines whether the model “works like an engineer.” For long-horizon coding and security tasks, post-training needs to cover at least:

    • Tool-call formats and error handling conventions;
    • Multi-turn task decomposition and plan rewriting;
    • Code reading order and repository navigation strategies;
    • Test-driven repair workflows;
    • Security boundaries and authorization constraints;
    • Failure log attribution and recovery strategies.

    High-quality post-training converts a model that “can write code” into an agent that “can deliver through a process.” Parameter count is not the only determining factor — data distribution and training objectives often matter more.

    3.2 Reinforcement Learning Improves Strategy, Not Just Knowledge

    In long-horizon tasks, models must learn when to keep exploring, when to converge, when to roll back, and when to ask for more information. Such strategic behavior is hard to acquire through supervised learning alone; reinforcement learning is better suited to optimizing it. For example, in software repair tasks, models can learn from reward signals that reproducing the failure before patching is more stable than guessing a fix directly; in security verification, constructing a minimal proof-of-concept case is more efficient than broad scanning.

    3.3 The Opportunity and the Limits of Smaller Models

    Smaller models offer lower inference costs, faster iteration, and higher sandbox parallelism density for long-horizon tasks. With sufficient post-training and RL, they can approach larger models on specific vertical tasks. But the limits are clear: cross-domain knowledge coverage, very long context retention, and complex multi-tool coordination may still lag. Engineering decisions therefore shouldn’t blindly chase “the biggest model” — they should weigh task distribution, interaction turns, cost constraints, and verification infrastructure holistically.

    4. Scaling Sandboxes: A New Lever for Training and Evaluation

    The original discussion noted that the number of sandbox environments increased by tens of times, coining the phrase “sandbox scaling.” Setting aside naming debates, the direction itself is technically sound.

    Long-horizon agent training requires large numbers of interactive environments. Unlike static text data, sandboxes provide real feedback: command execution results, test failure logs, filesystem state changes, and differing network responses. The more environments and the broader the task distribution, the more diverse failure patterns the model encounters — and the more robust its recovery strategies become.

    A schematic training loop looks like this:

    1. for episode in sample_tasks(task_pool):
    2. state = env.reset(episode)
    3. history = []
    4. for step in range(max_steps):
    5. action = policy_model.plan(state, history)
    6. result = sandbox.execute(action)
    7. reward = evaluate_progress(result, episode.goal)
    8. history.append((action, result, reward))
    9. state = update_state(state, result)
    10. if episode.is_done(result):
    11. break
    12. policy_model.update(history, reward)

    Sandbox scaling isn’t just about “more.” It also requires:

    • Environment isolation: prevent state contamination between tasks;
    • Reproducibility: failure cases must be replayable and attributable;
    • Feedback quality: logs, exit codes, and test results must be stable and parseable;
    • Task diversity: cover different repository structures, dependency conflicts, and security scenarios;
    • Cost control: parallel sandboxes need container platforms, logging services, monitoring and alerting, and resource scheduling.

    From an engineering perspective, scaling sandboxes is essentially expanding the “experience distribution” — similar to data augmentation, but with feedback much closer to the real world. It can become a significant complementary scaling axis beyond parameters.

    5. Adaptive Optimization and Interactive REPL: Teaching Models to Adjust Strategy

    “Adaptive optimization” resembles self-play in board games: rather than producing an answer in one shot, the model adjusts its strategy across multiple interactions based on environmental feedback. The difference is that feedback in coding and security tasks is sparser, noisier, and the reward design is more complex.

    The core of adaptive optimization can be summarized in three points:

    1. Process rewards: reward not only final success, but also effective information gathering, correct reproduction, and reasonable rollbacks;
    2. Strategy rewriting: when several consecutive turns show no progress, the model should proactively replan instead of repeating the same action;
    3. Budget awareness: the model needs to know remaining turns and resources, avoiding premature convergence or unbounded exploration.

    Interactive REPL environments are valuable here. The read–eval–print loop is naturally suited to step-by-step hypothesis verification: the model can execute small code snippets, observe results, refine its inference, and proceed to the next round. For developers, this means agent evaluation shouldn’t rely on static code snippets — it should provide executable, feedback-rich, rollback-capable interactive environments.

    Schematic pseudocode for an adaptive strategy:

    1. def adaptive_step(goal, history, budget):
    2. if no_progress(history[-3:]):
    3. plan = replanner(goal, history)
    4. elif uncertainty_high(history):
    5. plan = probe_with_minimal_case(goal)
    6. else:
    7. plan = continue_current_plan(goal, history)
    8. if budget.remaining < threshold:
    9. plan = prioritize_verification(plan)
    10. return plan

    The significance of such strategies: in long-horizon tasks, “making fewer mistakes” often matters more than “trying more things.” Models need to learn to reduce uncertainty with minimal verification cases rather than blindly widening the search space.

    6. Self-Play Insights from RL — and Risk Boundaries

    When sandbox environments are rich enough and feedback stable enough, reinforcement learning can exhibit a self-play-like “breakthrough moment”: the model experiments continuously and its strategy evolves rapidly. But engineering teams must stay clear-eyed.

    6.1 Reward Hacking

    If rewards only count test pass rates, the model may learn to hardcode test cases, bypass real fixes, or exploit environment loopholes. In cybersecurity tasks, if rewards only count “vulnerabilities found,” the model may generate massive false positives or unauthorized attempts. Reward design must therefore incorporate verification quality, actionability of fixes, and security constraints.

    6.2 Environment Overfitting

    If the sandbox task distribution is too narrow, the model may memorize environment quirks rather than learn general strategies. Regularly introduce unseen repository structures, dependency combinations, and security scenarios, and retain human spot checks.

    6.3 Safety and Compliance Boundaries

    Cybersecurity capability is inherently dual-use. Training and evaluation must happen inside authorized sandboxes, with operation logging, restrictions on destructive actions, and human review for high-risk behaviors. Engineering teams should build a closed loop of “capability evaluation → risk grading → deployment constraints,” rather than chasing benchmark scores alone.

    7. Engineering Recommendations: How to Evaluate and Use These Capabilities

    For development teams and enterprise users, build an evaluation system along these dimensions:

    • Task tiering: distinguish single-turn generation, repository-level repair, long-horizon tool use, and security verification tasks;
    • Process metrics: record interaction turns, ineffective operation rate, failure recovery rate, and human takeover rate;
    • Sandbox governance: use container platforms for environment isolation, logging services for replay, and monitoring/alerting for anomaly detection;
    • Cost accounting: include inference costs, sandbox resource costs, and human review costs in total cost of ownership;
    • Security constraints: for cybersecurity tasks, define authorization scopes, operation allowlists, and audit logging;
    • Continuous regression: regularly retest with unseen task sets to avoid environment overfitting.

    8. Conclusion: Capability Emergence Is a Systems Engineering Outcome

    The emergence of frontier coding and cybersecurity capabilities shouldn’t be attributed to parameter scale alone. The more accurate explanation: a mature architecture, carefully modified, combined with high-quality post-training, reinforcement learning strategy optimization, large-scale long-horizon sandbox environments, and adaptive interaction mechanisms, together drive performance gains on complex tasks.

    “Sandbox scaling” offers a valuable lens: when static data growth hits a bottleneck, the quantity and quality of interactive environments may become the new scaling axis. But this route brings challenges in reward design, environment overfitting, security compliance, and cost governance. For developers, the rational stance is to care about both benchmark scores and process metrics; to leverage long-horizon agents for efficiency while building human review and risk control mechanisms. Only by placing model capability, tool environments, evaluation systems, and engineering governance in the same framework can we objectively assess the real value of “emergence.”