KT is in beta: iPhone →Android & web →

How Palantir's Agent Engine Works

Katy & TheoEpisode 9 of The Machines Are Learning6 min

The Machines Are LearningEpisode 96 min · Katy & Theo
0:00-6:19

In the app you can ask Katy about anything mid-episode, then it picks back up.

Palantir's answer to flaky AI agents: stop improvising, start queueing events like a bank ledger.

Transcript

Katy

In Palantir's Agent SDK, an agent isn't a chatbot that improvises. It's a state machine: it processes queued events in order, deterministically, and updates its state.

Theo

Deterministic? With a language model in the middle? That sounds like a contradiction.

Katy

That's the trick. The model is the stateless part. Palantir's own definition, from their Agentic Runtime blog in January, is that an agent is a stateful control loop that repeatedly invokes a stateless reasoning core and feeds results back until a termination condition.

Theo

So the model is more like a function you call, and all the memory lives outside it.

Katy

Right. And the outside bit is built from three primitives: context items, events, and effects. Everything else is arrangement.

Theo

Start me with context items. That's just... the stuff the agent knows?

Katy

Think of them as cards on a table. Each one holds a piece of state: a document, a result, a chunk of the conversation. The docs say an event handler can create, delete or reorder context items, and dispatch events to a context item to update its data.

Theo

Reorder. Huh. Why would the order of your notes matter?

Katy

Because that stack is what becomes the model's prompt. Order is meaning. Even the system prompt is a function of current state, evaluated on every model request, so updating state changes the next set of instructions.

Theo

Okay, so the agent can rewrite its own briefing mid-task. That feels like it could go badly.

Katy

Which is where events come in. Nothing happens by vibes. Something dispatches a typed event, it goes in a queue, and it's processed in order.

Theo

Who's allowed to dispatch one?

Katy

Three sources, per the docs. A human sending one manually. An external automation on a schedule. Or the agent itself, from one of its own effects.

Theo

And effects are the doing part? The actually-send-the-email part?

Katy

Effects are the asynchronous work that happens outside the handler. Call an API, run a long query. When it finishes, it dispatches another event back into the queue.

Theo

Ah. So the loop closes. The messy, slow, real-world stuff never touches the deterministic bit directly.

Katy

It only re-enters as an event. That separation is the whole design.

Theo

Honestly, my instinct is that this is over-engineering. Why not let the model just call the tool and carry on?

Katy

Because of what breaks at length. Long-horizon planning is where agents fail: a subtly wrong assumption at step three, and by step fifteen the agent is pursuing a coherent but incorrect goal. Compounding error.

Theo

And nobody notices, because it still sounds confident.

Katy

That's the sharpest critique out there. Kiran Garimella wrote about an agent summarising an article it clearly couldn't access. Confident, detailed, completely fabricated. The failure mode isn't a crash, it's "sounds right".

Theo

So you end up verifying everything, which kills the point of delegating.

Katy

He calls that the verification tax. And the deeper one: responsibility without control. You're accountable for what it did without visibility into how.

Theo

Which the state machine actually fixes? Because the sequence is written down?

Katy

That's the old lesson, and it long predates AI. The distributed bakery and state-machine work, and Schneider's nineteen ninety tutorial, both rest on the same idea: outputs are completely determined by the sequence of requests processed, independent of time.

Theo

Same inputs, same order, same result. Replayable.

Katy

The team at Memobank built a core banking system this way. Transactions that span weeks, states stored in a database, side effects only fired once the state change is fully committed.

Theo

So you can't send the money and then fail to record it.

Katy

Or record it and never send it. Both leave the system inconsistent. They made side effects declarative data on the transition for exactly that reason.

Theo

And Palantir's version of that?

Katy

Fallback effects with retry policies, constant or exponential backoff. Plus something odd: in their Kubernetes environment, Rubix, nodes can't live longer than forty-eight hours.

Theo

Deliberately killing your own machines. That's a choice.

Katy

It forces every orchestration to be designed for disruption. If your agent can't survive its node vanishing, you find out on Tuesday, not during an incident.

Theo

Okay, give me a scenario. I want to see if I've got this.

Katy

Say your agent needs to pull a supplier's delivery data, which takes four minutes, and then decide whether to reroute a shipment. Where does each piece go?

Theo

The pull is an effect, because it's slow and external. When it finishes it dispatches an event. The handler takes that event and... makes a new context item with the data?

Katy

And possibly reorders the stack so the fresh data sits where the model will weight it.

Theo

Then the model reads the new state and recommends. And if the node dies at minute three, the effect retries rather than the whole thing collapsing.

Katy

That's it working. Three pieces: context items hold state, events change it in a fixed order, effects do slow work and report back as events.

Theo

And the model is a guest, not the host.

Katy

The caveat being it's a guest you still have to check. Determinism in the plumbing doesn't make the text true.

Theo

Yeah. The queue can be perfect and the summary still made up.

Katy

Next time something agentic goes sideways on you, ask which of those three it failed at. Usually it's the effect, quietly.

Sources

Katy and Theo researched this episode from these sources.

  1. Agent SDK • Advanced customization • Palantir
  2. Deconstructing the Bakery to Build a Distributed State Machine – Communications of the ACM
  3. Medium
  4. What AI Agents Still Cannot Do - Kiran Garimella
  5. Implementing fault-tolerant services using the state machine approach: a tutorial
  6. Medium
  7. Autonomous Agents: What They Can (and Cannot) Do Today | Dr. Vinayaka Jyothi