Part I / The Two Loops

Two loops, one machine

Before algorithms and GPUs, draw the system boundary correctly. One loop changes the policy. The other executes it. In modern agent systems, inference sits inside both.

01
Question

Where does learning stop and serving begin?

Case

A reasoning engine handles an incident, then learns from replay.

Payoff

A system map that prevents team-boundary confusion.

Start with two factories

Imagine a restaurant with a test kitchen and a dinner service. The test kitchen tries recipes, measures outcomes, and changes the cookbook. Dinner service follows a particular cookbook under real constraints: guests are waiting, ovens are finite, and the dining room cannot pause because a new sauce looks promising. Reinforcement learning is part of the test kitchen. Inference engineering is the discipline of making dinner service fast, predictable, economical, and faithful to the chosen cookbook.

The metaphor breaks in one useful place. The test kitchen also needs dinner service. To evaluate a recipe, somebody must cook it. To generate an RL trajectory, a policy must run inference, select tokens, call tools, receive observations, and continue. If we sample eight answers for every prompt, run a judge model, and repeat across thousands of prompts, the learning loop can execute far more inference than production traffic.

Mental model

Training changes parameters. Inference holds parameters fixed while using them. An RL run alternates between those modes: long bursts of fixed-policy inference create experience, then an optimizer changes the policy.

Follow one incident through both loops

Concrete example

A user asks: "Why did the western site lose connectivity at 14:03?" The serving system tokenizes the request, schedules a prefill, streams model output, executes topology and telemetry tools, appends their results to the context, and performs more decode steps. The answer arrives in 18 seconds and costs six tool calls.

That investigation is useful now, but it may also become experience. A privacy and provenance filter decides whether the trace is eligible. An evaluator checks the final cause, whether evidence supports it, whether the engine invented facts, and whether it ignored an alternate gateway. The trace joins other attempts generated in replayable seeded environments. Some are correct and efficient; others are persuasive failures.

The learning system can use that corpus in several ways. It can select strong traces for supervised fine-tuning. It can turn strong and weak pairs into preference data. It can use deterministic incident outcomes and structured rubrics as rewards for online rollouts. Each choice creates different data requirements, optimization behavior, and failure modes. None eliminates inference: every new attempt, reward-model judgment, or candidate evaluation runs one or more models.

Serve
Execute policy version 18 against a real or replayed incident.
Observe
Record actions, observations, timing, token counts, tool results, and provenance.
Evaluate
Apply outcome checks, process rubrics, cost metrics, and hard safety gates.
Learn
Construct an immutable dataset or generate on-policy rollouts, then update parameters.
Release
Compare candidate and incumbent on untouched gates before routing production traffic.

The two loops optimize different contracts

The learning loop improves a policy to maximize expected return over the tasks and trajectories it trains on. It cares about sample efficiency, exploration, data quality, reward validity, and policy stability. Held-out evaluation asks whether those improvements transfer beyond the training distribution. The serving loop maximizes useful work under operational constraints. It cares about time to first token, inter-token latency, requests or tokens completed within an SLO, accelerator utilization, memory, availability, and cost.

These objectives interact but are not interchangeable. A faster rollout engine can buy more samples per research day, which may improve the policy sooner. A policy update can change response length, tool-call frequency, KV-cache pressure, or speculative-decoding acceptance. A serving optimization can alter numerical behavior or scheduling enough to change rollouts. A rollout system optimized only for raw tokens per second can produce stale trajectories from old policies. A useful interface exposes versions, workload shape, provenance, and quality alongside the model endpoint.

LoopPrimary objectTypical constraintFailure that looks like success
LearningPolicy updateValid experience and stable optimizationReward rises while real task quality falls
ServingCompleted useful requestLatency, capacity, memory, reliabilityTokens per second rises while SLO goodput falls
Shared inferenceForward passesWorkload-dependent cost and schedulingBenchmark wins on a shape the application never sends
Misconception: RL is the trainer

The optimizer is only one component. An applied RL system also needs task sampling, environments, policy inference, tool execution, trajectory storage, rewards or preferences, evaluation, version transfer, and release control. In agent RL, rollout execution is often the operational center of gravity.

Three boundaries to keep crisp

Training inference versus production inference

Both execute a fixed model forward pass, but the workloads differ. Training rollouts may want many diverse samples, controlled temperatures, long tool traces, and asynchronous throughput. Production may want predictable tail latency, strict isolation, streaming, quotas, and rollback. Reusing a runtime does not mean reusing every serving policy.

Model quality versus system quality

A model can be excellent in isolation and poor inside an agent if tools are unreliable, observations are malformed, context assembly loses evidence, or timeouts reward premature answers. Conversely, good orchestration can mask a weak policy on easy tasks. Evaluate the full trajectory and its environment.

Raw throughput versus useful throughput

More tokens are not automatically more value. A late answer, an invalid trajectory, or a reward-hacking rollout consumes capacity without satisfying the contract. Later chapters use goodput for work that is correct enough and timely enough to count.

References