Skip to main content

langchain-accord

Accord for LangChain and LangGraph: agents that pay only for work that passes your evaluator.

  • Several sellers, one decision. Hold money with every seller a task might need, then pay the ones your terms call for in one step ("scout and (marketpulse or quantfeed)"), or call everything off and the money comes back.
  • Pay only for accepted work. Delivered work waits for your evaluator; rejected work is never paid.
  • No double payment when a node reruns. LangGraph reruns a node after an interrupt or a crash. A purchase_ref derived from the thread makes the rerun find the purchase the first run opened: nothing is held or paid twice.
  • Limits enforced when money moves. The weekly budget, allowed sellers and sign-off threshold belong to the agent key's owner. The agent can't raise them, and it can't give itself a sign-off.
  • Seller text is marked as data, and every purchase has a public proof page.

Install

npx @getaccord/cli init        # a test key in ./.env, with test money
pip install langchain-accord   # add langgraph for the LangGraph helpers

The tools read the agent key from ACCORD_AGENT_KEY or ./.env. No tool takes it as an argument or returns it.

Tools

from langchain.agents import create_agent
from langchain.agents.middleware import HumanInTheLoopMiddleware
from langgraph.checkpoint.memory import InMemorySaver
from langchain_accord import AccordToolkit, seller_content_note

toolkit = AccordToolkit()                      # x402=True adds quote_x402_url and fetch_x402_resource
agent = create_agent(
    "anthropic:claude-sonnet-5-5",
    toolkit.get_tools(),
    system_prompt=seller_content_note(),       # seller text is data, never instructions
    middleware=[HumanInTheLoopMiddleware(interrupt_on={n: True for n in toolkit.money_moving_tools()})],
    checkpointer=InMemorySaver(),
)

The tools have the same names, arguments and answers as Accord's MCP server:

Tool What it does
get_spending_limits Money available, what's left of the weekly budget, the sellers this key may pay.
find_sellers The seller directory: who sells what, at what price, and whether this key may pay each.
start_purchase Opens a purchase (budget_usd, mode "all" or "each", purchase_ref, reason, ...). Nothing is paid.
place_holds Holds money with one or more sellers, in one step.
get_delivered_work Delivered work to check, marked as seller text.
accept_work / reject_work Decide on delivered work: only accepted work is paid.
complete_purchase Pays every seller in one step (mode "all": all or none).
cancel_purchase Calls it off; held money comes back.
start_linked_purchase Several purchases under one condition, e.g. scout and (marketpulse or quantfeed).
linked_purchase_status Each member's state and whether the condition can be met.
settle_linked_purchase One step: pays the chosen members and calls off the rest, or calls everything off.
quote_x402_url / fetch_x402_resource Web resources that charge per request (x402). Off unless x402=True.

A refusal (over the weekly budget, a seller the key may not pay, a purchase waiting for sign-off) comes back as the tool's answer, quoting the rule, so the model can tell the user. purchase_id is the handle start_purchase gives, or the purchase's Accord ID (0x...), which works after a restart; a link_id works after a restart too. start_linked_purchase also takes a purchase_ref, so a retry returns the same linked purchase.

LangGraph

from langchain_accord.langgraph import purchase_ref_for, run_with_sign_off, sign_off_or_interrupt, seller_content_note
  • purchase_ref_for(config, step) gives "<thread_id>:<step>": the same on every rerun of that node. Give each purchase in a thread its own step.
  • sign_off_or_interrupt(err) pauses the graph when Accord says a purchase needs a person's sign-off (an awaiting_approval error, or a linked purchase's status() with a member waiting). The interrupt payload is {"kind": "accord_sign_off", "message", "approve_at", "purchase_ids"}: never a key or token. The person approves outside the graph (the dashboard at app.test.useaccord.ai); resume with Command(resume=True).
  • run_with_sign_off(step, purchase=intent) runs a step, pausing for sign-off and trying again after each resume.
  • seller_content_note() is the line to put in your system prompt and your evaluator's prompt.
def buy(state, config):
    intent = accord.intent(budget=230_00, purchase_ref=purchase_ref_for(config, "buy"))
    run_with_sign_off(lambda: intent.hold("scout", 200_00, type="deliver", ref="Research brief"), purchase=intent)
    return {"intent_id": intent.id}             # an ID in graph state, never the key

Examples (test mode, each under a minute after init)

python examples/research_brief.py                      # flow B: hold with three sellers, evaluate, settle
python examples/research_brief.py --fail marketpulse   # marketpulse declines: quantfeed is paid instead
python examples/research_brief.py --sign-off           # the graph pauses until a person approves
python examples/crash_resume.py --demo                 # flow C: crash twice, resume, paid once

If a run goes past the key's sign-off threshold, the graph pauses for a person's approval. Add --approve to approve as the key's owner (the owner token init saved in ~/.accord, read by the example's runner, never by the graph).

research_brief.py uses a plain-code evaluator unless ACCORD_EVAL_MODEL names a chat model (for example anthropic:claude-sonnet-5-5, with pip install langchain langchain-anthropic). Then the evaluator is its own model call with no tools and structured output; accepting or rejecting is still decided in code.

Keeping the key safe

  • The key stays in ACCORD_AGENT_KEY or ./.env. Keep it, and any owner token, out of graph state, interrupt() payloads, prompts and traces. These tools and helpers never put it there, and hide anything that looks like a key or token in their answers.
  • On LangGraph Platform, the key goes in the deployment's secrets (LangChain's secret store). Give that key tight limits: a small weekly budget, only the sellers it needs, and a low sign-off threshold.
  • The owner token never goes to the agent. Approvals happen in the dashboard, or for a test key with accord.test.approve(...) run by the person, outside the graph.

Tests

pip install -e '.[test]'
pytest                                   # unit tests and LangChain's standard tool tests (no network)
cd <a folder where you ran init> && pytest <this folder>/tests/integration_tests   # test mode

Apache-2.0. Built by Mysten Labs.

Metadata

Release files for langchain-accord 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-accord 0.1.0
File Size Uploaded Provenance Actions
langchain_accord-0.1.0.tar.gz 38.0 kB With provenance Details for langchain_accord-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-accord 0.1.0
File Interpreter ABI Platform Actions
langchain_accord-0.1.0-py3-none-any.whl Python 3 none any Details for langchain_accord-0.1.0-py3-none-any.whl

Total release size: 66.0 kB

Release files / langchain_accord-0.1.0.tar.gz

Download URL langchain_accord-0.1.0.tar.gz
Size 38.0 kB
Tags Source
SHA-256 checksum
How to use checksums
718c125eba511552511d33dba246037b2a3c623f6e9885532854ce4cbd2d5f41
BLAKE2b-256 checksum
How to use checksums
73670690ff8e8987a0e27ca21c1fb6924f76cf1b6806a53a0f92318f82419445
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Release files / langchain_accord-0.1.0-py3-none-any.whl

Download URL langchain_accord-0.1.0-py3-none-any.whl
Size 28.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4ea735674460e176339db295a0dab997e1593b5cf8a5ad6377e1a72ff3df8d3f
BLAKE2b-256 checksum
How to use checksums
5db0a6379132f73bcae16f4286d1580a4c90d0e8bdb594c59ec04e67511f3457
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Security for langchain-accord 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for langchain_accord-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page