Before you start
Complete the CLI quickstart first so your runtime already has a paired wallet, API key, and wallet UUID.5-minute outcome
- Build LangChain tools from
CoboAgentWalletToolkit - Submit a pact and wait for owner approval
- Run an allowed contract-call request
- Trigger policy denial from a non-compliant contract call
- Retry using denial guidance
- Track by
request_idand query audit logs
Step 1: Install
- Python
- TypeScript
Step 2: Configure environment
Step 3: Wire toolkit and agent
- Python
- TypeScript
langchain_quickstart.py
Step 4: Confirm denial loop happened
Verify agent output includes:- a pact submission and activation confirmation
- a successful contract call
- a policy denial payload/text
- a corrected retry
- a transaction lookup by
request_id - audit log summary
Keep the LangChain layer thin
LangChain should wrap the canonical CAW flow, not replace it with a different mental model.- keep CAW tools limited to the exact runtime role
- keep pact drafting separate from broad wallet management
- prefer
get_transaction_record_by_request_idover ad hoc polling patterns - move deterministic business logic outside the model loop when possible
Go further
In Python,CoboAgentWalletToolkit gives you the widened CAW runtime toolkit directly. In TypeScript, the usual pattern is to wrap @cobo/agentic-wallet calls in LangChain tools and expose only the subset your runtime needs.
- Define custom LangChain tools — in Python, register
@toolfunctions alongside CAW’s adapter; in TypeScript, wrap the CAW SDK intool(...)definitions withzodschemas. - Add CLI tools — call
cawvia subprocess for operations you want to handle as shell commands rather than Python calls. - Use direct SDK calls when determinism matters — for pact lifecycle management, audit queries, or recovery flows, keep the CAW call outside the agent loop.
- Use role-based presets — a good default split is Pact Drafting, Execution, and Observer. Start narrow and only add more tools when the runtime proves it needs them.
LangChain Integration Details
Error mapping and tool schema behavior.
Python SDK
Use WalletAPIClient directly for custom tool functions.