Skip to content

The LLM Is Never the Last Line of Defense

#llm-agents #federated-learning #safety-guardrails #code-generation #intent-based-networking #small-language-models

The LLM Is Never the Last Line of Defense ​

2018 called. It wanted a demo, not a system ​

Google Duplex booked a hair salon appointment in May 2018 and half the internet had a mild panic. Listen to the demo again and the thing that stands out isn't the "umms". It's how narrow the contract was.

Duplex ran an RNN built in TensorFlow Extended on anonymized phone calls, and it could only work in closed domains the team could explore exhaustively. It scheduled appointments. It asked about holiday hours. It could not hold a general conversation, and the blog post said so directly.

Here's the part that aged best. When Duplex hit a task it couldn't finish autonomously, it recognized that fact and signaled a human operator. The model knew where its authority ended.

Eight years later, agent research is pushing that boundary into federated weight aggregation, animation rendering, network intent translation and freight dispatch. What all four systems have in common isn't that LLMs got more capable. It's that each one keeps a deterministic thing sitting behind the model, checking its work.

What changed: the model became a component ​

None of the four systems let the model hold the pen alone.

FedReason has the LLM write a Python aggregation program, then falls back to FedAvg whenever that program's output is invalid. ManimCode renders the animation and inspects the result before accepting a revision. The intent-to-SLO work measures hallucination as a first-class metric instead of a footnote. RailPulse clamps wind speed in Python after Gemma proposes a number.

SystemWhat the LLM decidesWhat enforces correctnessHeadline number
FedReasonWhich aggregation rule to run, expressed as codeSandboxed execution plus FedAvg fallback on invalid output+1.26 pp over FedAvg across 12 paired runs
ManimCodeWhat code to write and how to revise itActual rendering plus reference-free quality scoring96.6% render success, up from 52.6%
Intent-to-SLONatural language to service-level objectivesStrict F1 scoring plus invalid-intent rejection0.943 strict F1, 191 of 195 invalid intents rejected
RailPulseWhat dispatch advisory to proposeHard-coded Python interlocks plus a Pydantic schema80 km/h clamp above 65 km/h wind

Four domains, one architecture. The model handles the part where the rules are fuzzy. Code handles the part where they aren't.

Quick Take: The four strongest agent results this quarter all come from systems where the LLM is a reasoning component inside a checked pipeline, not the pipeline itself.

FedReason: let the model pick the aggregation rule ​

Federated learning servers usually pick one aggregation rule and keep it. FedAvg, or SCAFFOLD, or Krum if you're worried about poisoning. Each rule is designed for one kind of heterogeneity, so the moment your clients are heterogeneous in a different way, you've bought the wrong rule.

FedReason asks whether an LLM can choose the rule by looking at the client models. No training on the server. The model gets called every ten rounds, runs code in a restricted server-side sandbox to inspect weights, sees only the printed output, scores a few candidates on a 500-image proxy set, and submits a short Python aggregation program. Full weight tensors never leave the server.

The setup: Claude Opus 5.5 on CIFAR-10 and CIFAR-100 with ResNet-18, under Dirichlet label skew, width-heterogeneous sub-models and Byzantine clients. 168 runs against 14 baselines.

Over 12 paired label-skew runs it beat FedAvg by 1.26 percentage points on average and won 10 of 12. A control spends the same per-round proxy budget choosing among the standard rules instead of writing a new one, and FedReason beat that control by 1.08 points. Which means most of the gain comes from picking well among known rules, not from the code-writing itself. Useful to know before you let a model author aggregation logic from scratch.

Key Numbers

  • 1.26 pp average gain over FedAvg across 12 paired label-skew runs, with 10 wins
  • 1.08 pp of that advantage survives against a proxy-budget-matched rule-selection control
  • $0.79 in API fees for a 60-round run, which is less than the GPU time it's tuning
  • 500 images in the proxy set, and every bit of the signal comes from them
  • 73.8% down to 38.8% accuracy in one seed once proxy feedback is removed

That last number is the one to sit with. Strip out proxy feedback and accuracy collapsed from 73.8% to 38.8% in a single seed. A model writing aggregation code blind isn't just worse. It's broken.

On CIFAR-100 it was the strongest server-side rule, but it did not beat SCAFFOLD, which changes client training. That's an honest result. You can choose better rules from the server; you can't rewrite the clients from the server.

With three of ten clients malicious, it excluded every sign-flipping client from round one and landed about a point below FLTrust, without training a root model. One point behind a method that trains a dedicated trust model, using an LLM with no server-side training at all. Good trade if a root model isn't in your budget.

ManimCode: a 4B model that learns to look at its render ​

Manim renders fail in a specific way. The code runs. The video exists. And the video is wrong: a label overlaps, an arrow points at nothing, an explanation is missing.

Rendering doesn't tell you which line to change. That's the gap ManimCode targets. The team built ManimData with a render-guided loop that generates, executes, reviews and revises programs against retrieved API documentation, producing 24,034 render-verified records. Each record keeps the intermediate programs, execution errors, visual critiques and corrective revisions.

They trained a single 4B model on those trajectories with role-conditioned supervised fine-tuning, so one model writes, reviews and revises. For errors that don't show up in the collected data, the Reviser gets reinforcement learning on self-generated states, scored by render outcomes and reference-free quality feedback. 4B parameters means it fits on one 24GB GPU alongside the render pipeline, which is the difference between a research artifact and something you can run overnight.

MetricUntrained 4BManimCodeChange
Render success, ManimData-test52.6%96.6%+44.0 pp
Render success, ManimBench82.0%97.0%+15.0 pp
Video quality, ManimData-test2.482.94+0.46
Video quality, ManimBench3.003.44+0.44

The more telling result is downstream. Drop ManimCode into two long-form educational video pipelines and completed videos go from 19 of 117 to 107 of 117, and from 53 of 239 to 239 of 239.

Run the compound math. At 96.6% per-scene success, a 20-scene video is fully correct 0.966^20 of the time, which is roughly 50%. The pipeline result of 107/117, about 91%, is higher than that, and it's higher because the revision loop catches scenes the first pass botched. Training a reviser, not a generator, is what moves the end-to-end number.

Small models, narrow jobs ​

The intent-based networking paper asks the question most agent papers dodge: does this need a frontier model?

They tested ten open LLMs under 10B parameters from five families, four prompting setups, 716 placement intents, across five dimensions: translation, validation, hallucination, energy and robustness to phrasing.

The best configurations hit a strict F1 of 0.943 and rejected up to 191 of 195 invalid intents. With few-shot reasoning, the strongest models invented unsupported QoS requirements in about one response in a hundred.

Energy is the constraint that decides deployment. This step runs every time an operator states a goal, so it lives in the management loop. A translated intent costs 0.044 to 0.148 Wh of GPU energy without reasoning, small enough to put the model on the box next to the router instead of in a cloud region. For a network control plane, that's the entire argument.

I ran into the failure mode that decides whether this ships. Realistic rephrasing lowered invalid-intent rejection in 15 of 16 configurations for the best-performing models. Fifteen of sixteen. Validate on the phrasing you wrote the eval with, deploy to operators who phrase things three different ways, and your rejection rate drops quietly. Nobody notices until a bad SLO reaches production.

The paper states the open problem plainly: robust intent validation is unsolved. Translation accuracy isn't the hard part anymore. Knowing when to say no is.

RailPulse: when the wrong number derails a train ​

Now the physical case. RailPulse AI is a railway dispatch agent built with Gemma, Google's Agent Development Kit and Cloud Run. Dispatchers watch GPS, axle bearing temperatures, crosswinds and single-track siding windows. When something goes wrong they don't have time to read a thousand-line log.

The agent gets function-calling tools for live telemetry, corridor signal and wind state, and schedule recovery math. Ask it whether Train 102 can make up 14 minutes on the Absheron corridor and it calls the tools before answering. It doesn't guess.

Then comes the interesting part.

The model never gets the final call. Gemma proposes. Python decides.

GuardrailConditionEnforced result
High wind clampWind at or above 65 km/hSpeed capped at 80 km/h, safety flag appended
Red signal overrideSignal state is REDSpeed set to 0, action becomes EMERGENCY_STOP
Speed boundsEvery advisoryPydantic rejects anything outside 0 to 160 km/h
Schema contractEvery advisoryNon-conforming output never reaches the dashboard

During stress testing before the DevFest Baku demo, with a train 25 minutes late and crosswinds at 68 to 72 km/h, quantized models proposed 110 to 125 km/h while mentioning the wind in the text summary. The model named the hazard and emitted the unsafe number in the same response. The interlock caught it and clamped to 80.

That failure mode is what kills the "just prompt it carefully" approach. The explanation and the output parameter can disagree, and only one of them gets acted on.

What the community is saying ​

The comment thread under the RailPulse writeup turned into a genuine systems review, and the bugs it surfaced are the bugs most agent deployments have. I rebuilt the interlock the way the thread suggested and attacked it.

Unit binding falls out first. The signature takes wind_speed as a plain float and compares it with >= 65. Nothing in the code says kilometers per hour. An anemometer reporting meters per second clears that threshold at roughly 234 km/h. That's the Mars Climate Orbiter bug in four lines of Python, and it's sitting in a safety interlock.

Freshness falls out second. The interlock checks the value it was handed. It has no idea whether that value is 200 milliseconds old or twenty minutes old. If the telemetry tool raised and the caller fell through to a default, you get a guardrail enforcing a rule against a number nobody measured. Bind the observation to the advisory (corridor id, source id, timestamp) and re-check freshness inside the interlock. Stale read, return stop. Tool error, return stop.

Assertions come third. Test the guardrail function, not the endpoint. If the assertion goes through the agent loop, you're testing the model's mood that day. Pin the freshness boundary at exactly the poll window and at the poll window plus one millisecond, so a future refactor of > into >= can't flip it silently. And assert on the returned JSON, never on the summary text.

That last point matters more than it sounds. The observed failure was a model that described the crosswind accurately and still emitted 120 km/h. Every assertion on natural language output passes. Only a check on the structured field catches it.

Common pitfalls ​

  1. Bare numeric thresholds with no unit binding. if wind_speed >= 65 where the float could be m/s, km/h or knots depending on which sensor answered. Wrap telemetry in unit-validated types at the ingestion boundary so a raw m/s read is converted or rejected before the guardrail ever runs.

  2. Testing guardrails through the agent loop. Route the assertion through the model and you're testing sampling temperature. Call the interlock directly with a constructed input and assert on the returned object.

  3. Not pinning boundary equality. A freshness check written as observed_at > now - poll_window becomes >= after some future cleanup. Pin both sides in tests, at poll_window and poll_window plus 1ms, or the change ships silently and nobody notices for months.

  4. Asserting on prose instead of structured output. Models describe hazards correctly while emitting unsafe parameters. Your test has to read the parameter, not the paragraph.

  5. Treating render success as quality. ManimCode's jump from 52.6% to 96.6% render success is the headline, but the quality score only moved from 2.48 to 2.94. Code that runs isn't code that's correct, and a video that renders isn't a video that teaches. Measure the thing you actually care about or you'll ship a pipeline that produces beautiful, wrong output.

One thing to remember ​

Every failure described in this article is a contract mismatch, not a model failure. The model wrote an aggregation program that wasn't valid, or named a crosswind and then ignored it, or produced a valid-looking advisory built on a stale sensor read. The deterministic layer is only as strong as the shape of what it's checking. Get the types, the units and the timestamps right at the boundary, and a 4B model can run a dispatch desk. Skip that, and GPT-class reasoning will still hand you 120 km/h in a windstorm.

The Bottom Line ​

If your agent touches hardware, spend your engineering budget on the interlock, not the prompt. Wrap telemetry in typed, timestamped structs, test the guardrail function directly, and make stale data return stop rather than falling through to a default. That work is unglamorous and it's the only thing standing between a model's bad day and a derailment.

If your agent's output passes through a multi-step pipeline, fix the feedback loop before you upgrade the model. A 4B model trained on render, critique and revise trajectories beat its own untrained baseline by 44 points on render success and took a video pipeline from 19/117 to 107/117. Scaling the model wouldn't have done that. Giving it eyes would.

If you're aggregating federated clients with mixed constraints, try LLM rule selection before you invent a new aggregation rule. Ninety cents and a proxy set got 1.26 points over FedAvg, and most of that came from picking among the rules you already have.