Valta for LangChain

LangChain gives you the primitives to build an agent — chains, tools, memory, agent executors. It doesn't give you a way to stop that agent from spending more than it should, or a way to prove after the fact exactly what it did and why. That's the layer Valta adds, without requiring you to restructure how your chains are built.

Where the gap shows up in a typical LangChain agent

A LangChain agent calling tools in a loop (an AgentExecutor, a custom while loop around a chain, or a LangGraph node graph) has no built-in ceiling on how many times it re-invokes the model or calls a paid tool. If a chain gets stuck re-reasoning, if a tool call keeps failing and retrying without backoff, or if a task simply takes more steps than expected, the only thing standing between that and a large bill is whatever ad hoc step-count or timeout logic you added yourself — and those are usually loose, because setting them too tight breaks legitimate long-running tasks.

Cost tracking tools built into the LangChain ecosystem (like LangSmith) show you what a run cost after it happened. They're valuable for observability, but they don't stop the spend before it occurs — by the time a dashboard shows an expensive run, the money is already spent. See Valta vs. LangSmith for how the two actually differ.

What Valta adds

A pre-call spend gate in front of your tool calls. Every paid action your LangChain agent takes — a tool invocation, an API call, a transaction — passes through a policy check before it executes. If the agent is about to exceed its configured spend limit, the call is blocked, not flagged after the fact.

A kill switch scoped to the specific agent. If a chain is misbehaving, freezing it is one call (freeze_agent), enforced at the gateway rather than inside your LangChain process — so it takes effect immediately regardless of what your chain's own error handling does or doesn't catch.

A tamper-evident audit trail of every action. Every request, approval, and denial is written to a hash-chained ledger independent of your application code, so you have a provable record of what the agent did — not just what your own logs happened to capture.

How it fits into a LangChain stack

Valta doesn't require restructuring your chains or agent executors. It sits as a layer in front of the tools and APIs your agent already calls — you point outbound calls at a Valta-guarded endpoint instead of calling the API directly, and the policy check happens transparently. For agents already using MCP-style tool definitions, the same enforcement ships as an MCP server (Valta-MCP), which drops in cleanly if your LangChain agent's tools are exposed that way.

Before you integrate: scan what you already have

If you want to know whether your existing LangChain agents already have this failure mode before adding any new infrastructure, valta-leak is a standalone, open-source static analysis CLI that scans your codebase for exactly these patterns — unbounded loops calling an LLM, retry logic with no backoff, system prompts re-declared inside a loop body — and estimates real dollar-per-hour exposure from actual model pricing. It's local-only, makes no network calls, and works as a CI gate (npx valta-leak ./src, exit code 1 on a FAIL finding).

Getting started

The core spend-gate and audit-chain logic is open source and MIT licensed: valta-audit-chain on GitHub. It's designed to be inspected, not taken on faith — the enforcement and hash-chaining logic is all readable, not a black box sitting between your agent and your budget.