Native-First Replies and AI Fallbacks in Bitcoin Agents
The wallet operation must remain usable when the model is slow or unavailable. This article is part of an experimental series about building Go-based AI agent interfaces on top of WAB ENGINE. The experiments separate wallet execution from model-generated language; they do not establish a production SDK.
The engineering problem
Treat the structured Engine result as the source of truth. A chatbot is useful for explaining intent and presenting results, but a probabilistic response must not become the authority for a payment. The execution boundary should be a small, reviewable Go function with explicit inputs, errors and structured output.
Implementation approach
Generate a native response first; ask AI for optional wording under a bounded deadline. Begin with a mock service and a recorded JSON fixture. Validate network and amount independently of the model. For wallet calls, record the outgoing operation, correlate it with a request ID and preserve the complete Engine response for the caller. If the optional model fails, return the trusted result with a native explanation.
A minimal conceptual flow is:
POST /v1/chat -> deterministic command parser -> authenticated Engine client
-> structured JSON result
-> native reply -> optional AI wording
This is an architectural example, not a claim that every route or field is supported by every deployed Engine release. Verify the current API contract at https://thamer.org/api.
A concrete Testnet exercise
See Repo/reply_formatter.go for a deterministic formatter. For a SEND-related experiment, use a saved response rather than broadcasting another transaction. One observed Testnet result allocated requested_sat=10000 and recipient_sat=9000 under that wallet's signed inclusive fee law. That is a wallet-specific policy, not the default behavior of Bitcoin or of other wallets.
Failure modes and boundaries
Do not retry SEND when AI times out; only retry the wording step. Distinguish compilation from runtime startup, Engine acceptance from blockchain confirmation, and AI availability from payment success. Never infer a transaction confirmation from ok: true alone. In particular, a reply_source: native response may indicate a model fallback while the Engine transaction has already been accepted.
How to verify the experiment
- Run the parser and formatter unit tests before connecting to a real node.
- Confirm the exact service version and listening port; Docker images may build successfully while containers fail to start.
- Feed known Engine JSON into the reply layer and assert that satoshi amounts, addresses and txids are unchanged.
- If using Testnet, inspect the returned txid separately through the deployed status API. Do not repeat SEND merely to troubleshoot the chatbot.
What this experiment does not prove
The examples do not prove production-grade authorization, independent multi-wallet isolation, guaranteed confirmations, safe custody, or a fully supported SDK. They are educational patterns for a self-hosted Bitcoin agent layer. Production deployment requires additional security, reliability and operational validation.
WAB ENGINE developer resources
- API reference: https://thamer.org/api
- Engine overview: https://thamer.org/engine
- Code repository index: https://thamer.org/repo/
Scope: This article documents experimental Testnet SDK patterns and prototypes, not production-ready payment software. Endpoint names and JSON contracts must be checked against the deployed Engine version before use. No example grants an AI model authority to sign or broadcast a transaction.
