Compute
Add Covenant Compute to LangChain.
Give your agent an inference tool it can choose when a task needs it. Your application sets the spending limits. Covenant handles the USDC purchase and returns a signed Compute receipt.
The agent chooses. Your application sets the limits.
01
Select the tool
The model receives the task and the tool definition. It decides whether to call Covenant and supplies the prompt.
02
Check and pay
The client checks the quote against your configured limits and payment identities before the wallet signs. The model cannot change the wallet, model or spending ceiling.
03
Verify and continue
The client verifies the signed result and payment, then returns the output to the agent. Keep the purchase journal to recover the same request after a restart.
A support ticket, from triage to a draft reply
In the accepted run, a live model chose the Covenant tool for a sample support ticket. The graph saved its checkpoint before payment, received the verified result, and continued with a summary for a human agent.
- Customer payment
- 0.05 USDC
- Restart replay
- No additional payment
- Completed
- 18 Oct 2026 · 15:07 UTC
Returned draft · sample ticket
Billing / High priority
The result requests screenshots of both charges, the time of the plan change, and details of the invoice download error. It prepares a reply asking for that evidence.
Read the exact returned text ↗The same saved tool call returned the identical purchase in a fresh process, with zero wallet signatures, gateway requests, RPC calls or planner calls. The original payment was independently checked as finalized on Solana.
The example prepares a draft for review. It does not send a customer message or modify a support system.
Install and register the tool
Requires Node.js 24 or later, a funded Solana USDC wallet and a persistent purchase journal. Use your existing Covenant client and planner. Configure the client with the approved service identities and your spending limits before exposing the tool to the model.
curl --fail --location --output covenant-compute-x402-client-0.2.0.tgz \
https://github.com/open-covenant/covenant/releases/download/codex-compute-x402-client-v0.2.0/covenant-compute-x402-client-0.2.0.tgz &&
echo "77ef86146f982432f75a83d227afb8c7a8f36049bb23d4eba29ae0da0cb606cf covenant-compute-x402-client-0.2.0.tgz" | shasum -a 256 -c - &&
npm install --ignore-scripts ./covenant-compute-x402-client-0.2.0.tgzThe configuration example allows 0.05 USDC per purchase and 0.50 USDC cumulatively across reserved and completed purchases. Set your own limits and retain the same journal. Planner calls have separate credentials, costs and spending controls.
import { readFile } from 'node:fs/promises';
import { covenantInferenceTool }
from '@covenant/compute-x402-client/langchain';
// Your application saves both IDs before the first run.
// Load the same file after a restart; never generate a new ID to retry.
const { requestId, threadId } = JSON.parse(
await readFile('./state/run.json', 'utf8'),
);
const compute = covenantInferenceTool({
client, // Configured CovenantX402Client: wallet, journal and spending limits.
requestId, // One saved UUID for this logical purchase.
model: 'claude-haiku-4.5',
maxTokens: 2048,
temperature: 0.2,
systemPrompt: 'Draft only. Do not claim account actions or promise refunds.',
});
// The model can supply only { prompt: string }.
// Wallet, model, price limits and request identity stay in application code.import { createAgent } from 'langchain';
// Use your existing planner and a persistent graph checkpointer.
const agent = createAgent({
model: planner,
tools: [compute],
checkpointer,
});
const result = await agent.invoke({ messages: [{
role: 'user',
content: 'Sample ticket: my plan change shows two charges and I cannot '
+ 'download the invoice. Triage it and draft a reply for review.',
}] }, { configurable: { thread_id: threadId } });
const purchase = result.messages
.findLast(message => message.name === 'covenant_inference')?.artifact;
if (purchase?.status === 'completed') {
console.log(purchase.text); // Full signed evidence is retained in purchase.
}Save one request UUID per logical purchase and retain the graph thread ID, persistent checkpointer and payment journal. Reuse the exact tool call when resuming. Changing the prompt, system prompt or generation settings under the same UUID is refused.
A pending purchase is not a completed answer. Resume the saved tool call with its original identity and authorization. The complete LangGraph example handles this with separate plan, purchase, replay and finish phases and an official SQLite checkpointer.
Optional dependencies for the complete example
The packaged support workflow uses SQLite checkpoints. The example planner uses the OpenAI adapter; your application can keep its own compatible planner. These dependencies are optional for the basic tool registration.
npm install @langchain/openai@1.6.2 \
@langchain/langgraph-checkpoint-sqlite@1.1.0
# If native install scripts were disabled:
npm rebuild better-sqlite3 --ignore-scripts=falseQualified with LangChain 1.5.18, LangGraph 1.5.1 and LangChain Core 1.2.18: 32 source tests and 32 installed-package tests passed.
Model, price and limits
- Model
- claude-haiku-4.5
- Customer price
- 0.05 USDC per completed request
- Maximum output
- 2,048 tokens
- Input limit
- 4,096 UTF-8 bytes across the JSON messages array
- Payment
- Solana USDC through x402
The receipt identifies the operator and binds the job to its exact output. Review generated answers before using them; a signature does not establish their accuracy.
This is an independent integration using the open-source LangChain and LangGraph frameworks.