Large Language Models: From Generating Answers to Completing Long-Horizon Tasks

    This article examines how LLM evaluation has shifted from answer quality to long-horizon task completion. It breaks down the core capabilities required, explains why token consumption has become a central cost metric, and shows how these abilities are expanding from coding into computer operation and multimodal scenarios. Readers will find practical guidance on state and memory management, context compression, budget constraints, three-layer evaluation, and sandbox-based deployment architecture.

    1. The Main Shift: Evaluation Moves From “Correct Answers” to “Finished Tasks”

    Over the past year, the conversation around large language models has moved from “generation quality” to “long-horizon tasks” and “token consumption.” This is not marketing language; it reflects a substantive change in how models are evaluated. Early on, we measured a model by whether it could produce a reasonable answer. Today, we measure whether it can still remember the original goal after dozens of tool calls and finish a task that can actually be verified.

    This curve can be summarized in three stages:

    • Single-turn generation: Mainly Q&A, summarization, and rewriting. Contexts are short, failure costs are low, and human review is enough to catch mistakes.
    • Multi-turn collaboration: Tool calls and structured output are introduced, and the model starts to “act,” but humans still divide the task into boundaries.
    • Long-horizon autonomy: The model decomposes goals, selects tools, handles exceptions, and rolls back and retries on its own, while humans only define the acceptance criteria.

    It is worth emphasizing that the shift toward coding and agents is inevitable. Coding tasks have three scarce properties: results can be verified automatically (compilation, tests, static checks), the process is observable (logs and diffs), and failures can be rolled back (version control). These three properties make coding the best testbed for training and evaluating long-horizon capabilities, which then spill over into other scenarios.

    2. Capability Breakdown: What Makes Long-Horizon Tasks Hard

    Treating “long-horizon” as a vague adjective has no engineering value. Broken down, it involves at least four layers of capability:

    1. Goal retention: Staying aligned with the original constraints in a long context without being diluted by intermediate information.
    2. State management: Distinguishing “known facts,” “assumptions,” and “items to verify,” and avoiding treating guesses as conclusions to build on.
    3. Tool orchestration: Choosing the right capability at the right time, including knowing when not to call a tool.
    4. Failure recovery: Recognizing error signals, locating the failing step, and deciding whether to retry or switch paths.

    The illustrative task loop structure below focuses on making “memory” and “steps” explicit rather than relying on the model to maintain them implicitly:

    1. state = {
    2. "goal": goal, # Original goal, read-only throughout
    3. "constraints": constraints,# Hard constraints, cannot be overridden by intermediate conclusions
    4. "facts": [], # Verified facts, with evidence sources
    5. "assumptions": [], # Assumptions, must be marked as pending verification
    6. "todo": plan(goal), # Step queue that can be dynamically reordered
    7. }
    8. while not done(state):
    9. step = state["todo"].pop()
    10. result = tool_call(step, context=build_context(state))
    11. if verify(result):
    12. state["facts"].append(evidence(result))
    13. else:
    14. state["assumptions"].extend(diagnose(result))
    15. state["todo"].push_front(replan(step, state))
    16. state = compact(state) # Context compaction, preserving goal and constraints

    The step most often overlooked in engineering is the last one: context compaction must preserve the goal and hard constraints without loss, otherwise a long-horizon task will “forget what it is doing” midway.

    3. Cost Structure: Why Token Consumption Became a Core Metric

    When a task grows from one turn to hundreds of turns, the cost model changes completely. A long-horizon task’s consumption is roughly made up of four parts:

    • System prompts and tool descriptions: Billed repeatedly every turn, and more tools make it more expensive.
    • Historical context: Grows linearly or even super-linearly with turns, and is the main cost source.
    • Tool return content: Logs, files, and page structures are often huge and need truncation and summarization.
    • Retries and rollbacks: Failed paths also consume budget and are hard to predict.

    So the focus of cost optimization is not “choosing a cheaper model” but reducing ineffective context. Practical approaches include layered memory (recent raw text, mid-term summaries, long-term key points), structured trimming of tool results, loading on demand instead of injecting everything, and caching results for repeated subtasks.

    A practical way to write a budget constraint is to treat cost as a first-class citizen in the loop:

    1. budget = {"max_steps": 60, "max_tokens": 400_000}
    2. def can_continue(state, usage):
    3. return (usage.steps < budget["max_steps"]
    4. and usage.tokens < budget["max_tokens"]
    5. and not state["todo"].is_empty())
    6. # When over budget, do not force it; deliver "current best result + list of unfinished items"

    4. Spillover: From Code to Computer Operation and Multimodality

    Once reliability in coding scenarios crosses the usability threshold, capabilities begin to spread into more specific scenarios. A clear recent trend is the combination of computer operation capabilities (locating elements and performing actions in a GUI or command-line environment, then reading feedback) with 3D and multimodal understanding. The value of these capabilities is covering the large number of legacy systems that “have no API, only an interface,” automating flows that previously required manual clicking.

    But engineering difficulty rises accordingly, requiring extra handling for:

    • Observability: UI state cannot be read directly and must rely on screenshots and structured parsing, which is noisy.
    • Idempotency: Repeated clicks or submissions can create dirty data, so action design must be re-entrant.
    • Permissions and auditing: When real business systems are involved, least privilege, operation trails, and interruptibility are hard requirements.
    • Human-machine collaboration: Set confidence thresholds and route low-confidence actions to human confirmation instead of forcing execution.

    5. Acceptance System: No Evaluation, No Long-Horizon Capability

    Long-horizon tasks cannot be accepted based on “looks good.” It is recommended to build three layers of evaluation:

    1. Result layer: Whether it passes tests, validation rules, or manual spot checks, producing a structured pass rate.
    2. Process layer: Number of steps, tool call success rate, number of rollbacks, and share of ineffective context.
    3. Cost layer: Token consumption and latency distribution per task, focusing on the long tail rather than the average.

    Only when all three layers are included in regression can a change to the model or prompt be judged as real progress rather than a random fluctuation on a small sample.

    6. Deployment Architecture: Building Stable Systems on General Cloud Capabilities

    To engineer the above capabilities, you can usually reuse a few general cloud capabilities without relying on any proprietary solution: a container platform to host sandboxed execution environments, object storage to hold intermediate artifacts and screenshots, a message queue for task distribution and peak shaving, logging services and monitoring alerts for process tracking and exception notification, and key management to centrally manage credentials. Baidu AI Cloud offers similar general-category capabilities in this kind of architecture, which can be combined as needed.

    A key design principle is sandbox isolation: model-generated code and UI actions must run in a restricted environment with minimized network, file system, and permissions, while keeping a complete operation trail for review.

    7. Conclusion

    Going from generating answers to completing verifiable long-horizon tasks essentially turns the model from an “advisor” into an “executor.” This requires developers to upgrade three things at the same time: explicit state and memory management, cost governance centered on ineffective context, and three-layer acceptance covering results, process, and cost. Whoever does these three things solidly can turn capability improvements into scalable productivity, and the progress curve of Chinese models in this direction is also expected to accelerate further under the continued drive of scenarios and feedback.