Agents and harnesses

Local model on Tether QVAC

Run an agent whose model, Qwen3 1.7B Instruct, is served on your own machine by Tether QVAC. The model chooses Abazi's MCP tools; Abazi holds the keys and makes every policy decision.

View as .mdUpdated

The model stays on your machine. Tether QVAC serves Qwen3 1.7B Instruct through an OpenAI-compatible API, with outbound network access denied. A small agent program sits between the model and Abazi: it shows the model three slim tools, forwards the model's choices to Abazi's MCP server with the agent credential, and fills in everything the model should not decide. The model chooses what to buy. Abazi decides whether it may, and pays.

How the pieces sit

PieceRuns whereHolds
Qwen3 1.7B Instruct (4-bit)Your machine, served by QVAC, outbound network deniedNothing: no key, no credential, no limits
Agent programYour machineThe agent credential (ABAZI_AGENT_KEY)
Abazi MCP serverAbaziNothing the agent can extract: it checks the credential and calls the policy engine
Policy engine, budget and signerAbaziThe mandate, the limits, the wallet keys
Agent loop
task ─► model (QVAC, on device) ─► tool choice ─► agent program ─► Abazi MCP server ─► policy ─► pay
              ▲                                        │
              └──────────── tool result ◄──────────────┘

Only the agent program's call to Abazi leaves the machine.

Before you start

You needWhy
An agent credential (agk_test_...)Created in the Console under Agents > New agent. Shown once. Replace YOUR_AGENT_KEY with it. See Get an agent credential.
A signed mandate for that agentWithout one every purchase is denied with MANDATE_MISSING.
Node.js and npmTo install and run the QVAC command-line tool.
Python 3.10 or laterFor the agent program, with mcp and httpx.
About 1 GB of diskThe model is downloaded once.

Connect

Serve the model with QVAC

Install the QVAC command-line tool and give the model an alias, local-agent, with tool calling on.

Terminal
npm install @qvac/cli@0.18.0
qvac.config.json
{
  "serve": {
    "models": {
      "local-agent": {
        "model": "QWEN3_1_7B_INST_Q4",
        "default": true,
        "preload": true,
        "config": { "ctx_size": 8192, "tools": true }
      }
    }
  }
}
Terminal
npx qvac serve --openai -p 11434 -c qvac.config.json

The first start downloads the model. After that, run the server with outbound network access denied. On macOS, Abazi's reference agent starts it under sandbox-exec with a profile that denies every network connection except those that stay on the machine, so the model cannot send your task anywhere.

With -p 11434, QVAC's local OpenAI-compatible endpoint is http://localhost:11434/v1 on your machine.

Check the model

Terminal
curl -s http://localhost:11434/v1/models

The list contains local-agent, owned by qvac, with state ready once the model has loaded.

Run the agent loop

The program connects to https://api.52-28-238-205.sslip.io/mcp with the agent credential, offers the model three tools with the smallest possible inputs, and sends the model's tool calls to Abazi. When the model asks to buy, the program adds the task id, a fresh idempotency key and the wait time itself.

Terminal
pip install mcp httpx
export ABAZI_AGENT_KEY="YOUR_AGENT_KEY"
python local_agent.py
local_agent.py
import asyncio, json, os, uuid

import httpx
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client

MCP_URL = "https://api.52-28-238-205.sslip.io/mcp"
QVAC_URL = "http://localhost:11434/v1"  # QVAC's local OpenAI-compatible endpoint
MODEL = "local-agent"
SYSTEM = ("You are a shopping agent with a small budget. Use the tools to find the service the user asks for and "
          "buy it once. Call search_catalog first, then request_purchase with the service_id you found. /no_think")

# The model sees only what it decides: which tool, the search text, the service.
SLIM = {
    "search_catalog": {"type": "object", "properties": {"query": {"type": "string"}}, "required": ["query"]},
    "request_purchase": {"type": "object", "properties": {"service_id": {"type": "string"}}, "required": ["service_id"]},
    "get_spending_status": {"type": "object", "properties": {}},
}


async def call(s, tool, args):
    r = await s.call_tool(tool, args)
    return not r.isError, json.loads("".join(c.text for c in r.content if c.type == "text"))


async def main(task="Buy the forecast service."):
    headers = {"Authorization": f"Bearer {os.environ['ABAZI_AGENT_KEY']}"}
    async with streamablehttp_client(MCP_URL, headers=headers) as (read, write, _), httpx.AsyncClient(timeout=120, headers={"Authorization": "Bearer qvac"}) as llm:
        async with ClientSession(read, write) as s:
            await s.initialize()
            listed = (await s.list_tools()).tools
            tools = [{"type": "function", "function": {"name": t.name, "description": t.description,
                                                       "parameters": SLIM[t.name]}} for t in listed if t.name in SLIM]
            messages = [{"role": "system", "content": SYSTEM}, {"role": "user", "content": task}]
            for _ in range(6):
                r = await llm.post(f"{QVAC_URL}/chat/completions",
                                   json={"model": MODEL, "messages": messages, "tools": tools, "temperature": 0})
                msg = r.json()["choices"][0]["message"]
                calls = msg.get("tool_calls") or []
                if not calls:
                    print("model:", msg.get("content"))
                    return
                messages.append({"role": "assistant", "content": msg.get("content") or "", "tool_calls": calls})
                for tc in calls:
                    name = tc["function"]["name"]
                    args = json.loads(tc["function"].get("arguments") or "{}")
                    print(f"model -> {name}({json.dumps(args)})")
                    if name == "request_purchase":
                        # The program, not the model, owns task id, idempotency and wait time.
                        ok, res = await call(s, name, {"service_id": args.get("service_id"),
                                                       "task_id": f"local-{uuid.uuid4().hex[:8]}",
                                                       "idempotency_key": str(uuid.uuid4()), "wait_seconds": 20})
                        print(json.dumps(res, indent=2))
                        return
                    if name not in SLIM:
                        data = {"error": f"unknown tool {name}"}
                    else:
                        _, data = await call(s, name, {k: v for k, v in args.items() if k in SLIM[name]["properties"]})
                    messages.append({"role": "tool", "tool_call_id": tc.get("id", name), "content": json.dumps(data)})


asyncio.run(main())

Verify

A good run prints the model's choices, then Abazi's answer:

Output
model -> search_catalog({"query": "forecast"})
model -> request_purchase({"service_id": "svc_..."})
{
  "status": "paid",
  "intent_id": "pi_...",
  "decision": "ALLOW",
  "reason_code": "WITHIN_POLICY",
  "receipt_id": "rcpt_...",
  ...
}

What Abazi does with the request

The model's purchase is an ordinary purchase. Abazi runs the same mandate and policy as for any agent and pays on whichever rail and network the mandate allows and the agent has funded. That includes direct USDT from the agent's spending wallet on Ethereum or Tron, built on Tether's Wallet Development Kit, confirmed on chain before the merchant releases the resource.

ResultWhat it meansWhat the program does
paidALLOW. The resource and a receipt_id come back.Call get_receipt for the public verification link.
submittedALLOW, still settling.Poll get_purchase_status after poll_after_ms.
awaiting_approvalREQUIRE_APPROVAL, for example ABOVE_AUTO_THRESHOLD. The approval link goes to the owner's approvers.Poll get_purchase_status with the same intent_id. The link expires after 10 minutes.
Error POLICY_DENIEDDENY, for example HARD_CAP_EXCEEDED or RAIL_NOT_ALLOWED.Report reason_code and next_action. Never retry with a new key.

Why the model gets no wallet

A wallet tool in the model's hands would let it send money outside Abazi's reserve, sign and confirm sequence, and outside the receipt chain. Keeping keys in Abazi's signer means a confused or manipulated local model can, at worst, ask for a purchase the mandate then refuses.

Troubleshooting

SymptomCause and fix
Tool results carry AGENT_CREDENTIAL_INVALIDABAZI_AGENT_KEY is wrong, rotated or revoked (AGENT_CREDENTIAL_INVALID).
/models does not list local-agentThe alias in qvac.config.json must be local-agent, or change MODEL to match. Wait for state ready after the first download.
The model answers in text instead of calling a toolKeep "tools": true in the QVAC config and temperature at 0. Small models follow a short, direct task best.
The purchase stays awaiting_approvalA person has not decided yet. Keep polling the same intent_id.
IDEMPOTENCY_CONFLICTA key was reused with a different request. The program makes a new key per purchase; reuse one only to retry the same purchase.
No funded networkDenied with NO_FUNDED_CHAIN. The owner funds the agent's spending wallet.

Next steps

On this page