Skip to main content
Start with the language SDK quickstart first, then move to LangChain once the pact-to-execution flow works without an agent loop.

Before you start

Complete the CLI quickstart first so your runtime already has a paired wallet, API key, and wallet UUID.

5-minute outcome

  1. Build LangChain tools from CoboAgentWalletToolkit
  2. Submit a pact and wait for owner approval
  3. Run an allowed contract-call request
  4. Trigger policy denial from a non-compliant contract call
  5. Retry using denial guidance
  6. Track by request_id and query audit logs

Step 1: Install

Step 2: Configure environment

Step 3: Wire toolkit and agent

langchain_quickstart.py
If you want a tighter first integration, start with a smaller tool subset:

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_id over 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 @tool functions alongside CAW’s adapter; in TypeScript, wrap the CAW SDK in tool(...) definitions with zod schemas.
  • Add CLI tools — call caw via 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.

Python SDK

Use WalletAPIClient directly for custom tool functions.