AI · LLM · Agents · Node.js

Shipping LLM Features to Production: Prompt Versioning, Tool-Calling and Agents

How to turn an LLM demo into a reliable product feature: prompt versioning, tool-calling, agent orchestration, evaluations and cost control.

Sander Yazıcıoğlu Published: 3 min read Türkçe oku

Building an impressive LLM demo now takes a few hours. The hard part is turning that feature into a product component that runs thousands of times a day, can be measured, and has a known budget. These are the practices that helped me most while taking LLM flows to production at LiveTesting.

Treat prompts like code

A prompt is source code that defines your app's behaviour. It shouldn't live in a database row or in one developer's head.

  • Keep prompts in version control. One file per prompt, one commit per change.
  • Give each prompt a version id. Log which prompt version served every LLM call, such as summary-v7. When a complaint arrives, you know which version answered.
  • Separate template from data. Instead of pasting user data straight into the prompt, put it in clearly marked sections. It lowers prompt-injection risk and reads better.
export const summarizeRun = {
  id: 'summarize-run',
  version: 7,
  system: 'You summarise the results of a test run briefly and technically.',
  user: (run: RunSummaryInput) => `<run>\n${JSON.stringify(run)}\n</run>\nList the failed steps and likely causes.`
};

Tool-calling: the model's hands

Tool-calling (function calling) lets the model call functions you define: search a database, start a test run, fetch a device log. Three rules save a lot of pain:

  1. Keep tool schemas narrow. getFailedSteps(runId: string) rather than runSql(query: string). The less freedom the model has, the fewer mistakes it makes and the smaller the attack surface.
  2. Always validate arguments. Arguments from the model are as untrusted as user input. Validate them with a schema library such as Zod, and check permissions against the user's session.
  3. Ask for confirmation on side effects. Read-only tools can run automatically; irreversible actions such as deleting, paying or sending messages outside should wait for the user.
import { z } from 'zod';

const GetFailedSteps = z.object({ runId: z.string().uuid() });

async function handleToolCall(name: string, rawArgs: unknown, user: User) {
  if (name !== 'getFailedSteps') throw new Error(`Unknown tool: ${name}`);
  const { runId } = GetFailedSteps.parse(rawArgs);
  await assertCanReadRun(user, runId);
  return repository.failedSteps(runId);
}

Agent orchestration: start with a simple loop

"Agent" promises a lot, but most product needs are met by a bounded number of model → tool → model iterations. Before you reach for complex multi-agent architectures, try this:

  • Cap the steps. Let the loop run at most N times, or a bug becomes an infinite loop and an invoice.
  • Log every step. Which tool, which arguments, how long, what it returned. That trace is the only way to understand why the agent made a bad decision.
  • Leave deterministic work to code. Don't trust the model to compute dates, sort or filter; expose those as tools.

If your workflow is a known sequence (for example "fetch logs, summarise, draft a Jira ticket"), a fixed workflow is cheaper and more predictable than a free-roaming agent.

No change without evaluation

A small prompt edit can lower quality somewhere you didn't expect. You only catch that by measuring:

  • Build a test set of 20 to 100 examples from real usage, with personal data removed.
  • Run it on every prompt or model change, and compare results with the previous version.
  • For structured output (JSON, classification), validate automatically. For free text, scoring with another model (LLM-as-judge) helps but is not enough on its own: look at samples yourself regularly.

Cost and latency

  • Pick the right model. Small, fast models are often enough for classification and short extraction; save large models for steps that truly need reasoning.
  • Use prompt caching. If long, static system instructions and tool definitions can be cached, both cost and latency drop.
  • Stream to improve perceived speed. If users see the first word in 300 ms, even a five-second answer feels fast.
  • Set token budgets. Input and output limits per request prevent surprise invoices.

Security: prompt injection is real

Any content the model reads (a web page, an email, a log line) can contain instructions. Basic defences:

  • Never treat "instructions" found in external content as permission.
  • Limit the tools the model can reach to the least privilege needed.
  • Put critical actions behind human approval.

Conclusion

Taking an LLM to production is less about choosing a model and more about software engineering discipline: versioned prompts, narrow validated tools, bounded loops, measurement and a budget. For the other side of the coin, making your own site visible to AI, read how to make your website AI-agent ready.

All articles →