Back to writing

Giving the LLM hands, part 1: from a fixed pipeline to a tool service

On a large project I worked on, the AI feature began as a fixed pipeline: gather the data, build one big prompt, ask the model once. It worked, but it kept the model on a short leash. This post is a high-level look at how we are loosening that, and at the small service that lets the model act safely.

Part 1 of 2. Part 2, MCP servers and the Relay client, covers how the tools are built and called.

A note before we start: the project and the service names below are made up. The shape of the architecture is what matters here, not the names.

Where we started

Call the platform Meridian. It is made of several apps. Atlas is the REST API that serves end users. Ledger and Compass are internal services: Ledger holds account and order data, and Compass holds policies and the product catalogue. The LLM is hosted on Amazon Bedrock.

The first version of the AI feature was a pipeline owned by Atlas. When a user asked something, Atlas called Ledger and Compass over their APIs, collected the answers, built a prompt from them with LangChain, and sent it to Bedrock in a single call.

UserasksAtlas APIgathers data,builds thepromptLedgerbusiness dataCompasspolicies, catalogLLM on Bedrockanswers onceRESTone big prompt
Before: Atlas gathers the data and builds one prompt. The model only sees what Atlas decided to give it.

Why a fixed pipeline holds the model back

The pipeline made one decision for the model, and made it early: what the model gets to see. Atlas chose the data before the model had read the question, so the model could not ask for anything else. If the answer needed one more fact, it either guessed or gave a vague answer.

It also cost time. Every request paid for every call, in order, before the model even started: Atlas waited for Ledger, then for Compass, then built the prompt, then called Bedrock. Most questions needed only part of that data, and the prompt carried the rest along anyway.

And it was hard to grow. A new capability meant changing the pipeline and the prompt in Atlas, which was already the busiest app in the system. The model had little say in how it was used.

Let the model decide what it needs

The change is to turn this around. Instead of building the context for the model, we describe what the model is allowed to do and let it decide. The model reads the question, picks a tool when it needs one, looks at the result, and chooses the next step. That is the agentic loop described in What is inside an AI agent.

Atlas stays the front door, a plain REST API that takes the user’s question and returns the final answer. It does not talk to the model any more. What is new is Relay, the service that does, and where the tools live.

Relay: the hands and feet of the LLM

For that we are building a new service, Relay. The model never calls Ledger or Compass directly. Every tool request goes through Relay, which has four jobs:

  • It builds the tool catalogue. It collects the tools the services offer, each with a plain-language description and a small, clear set of inputs, and gives the list to the model so it knows what it can ask for and how.
  • It checks every request. Are the inputs valid, and is this user allowed to see or do this? Relay acts on behalf of the user, so the user’s rights apply, not the model’s wishes.
  • It does the work. When the model asks for a tool, Relay calls Ledger or Compass, and combines their results where a tool needs both.
  • It shapes and records. It returns only what the model needs instead of whole records, and logs each call so we can see what the model did.

So Relay sits right next to the model and is the one that calls it: it hands over the list of tools, takes each request, does the work and returns the result. Ledger and Compass offer their tools through MCP, and Relay calls them. I wrote that part up in part 2.

UserasksAtlas APIfront doorRelay (new)the LLM's handschecks, logsLLM on Bedrockdecides next stepLedgerbusiness dataCompasspolicies, catalogtool calls
After: Atlas hands the question to Relay. Relay is the one that talks to the model, gives it its tools and does the work.

What changes, and what gets harder

BeforeAfter
Who decides what data is neededAtlas, before the question is readThe model, for each question
Calls to Ledger and CompassAlways, for every requestOnly when the model asks
The promptBuilt from fixed data with LangChainA short instruction plus tool descriptions
Adding a capabilityChange the pipeline in AtlasAdd a tool in Relay
Access rulesSpread across the pipelineEnforced in Relay, in one place

The trade-offs are real. A model that decides can take more than one round trip, so we limit the number of steps and set timeouts. Its path is less predictable than a fixed pipeline, so we log every tool call and review them. And because the model can now act, we start with read-only tools and add anything that changes data later, behind a confirmation step.

TakeawayThe model decides what it needs, and the platform decides what it is allowed to do. Do not build the context for the model; describe what it may do, and keep the rules in one place.

Next: part 2, MCP servers and the Relay client.

Working on something similar? Let's talk