
ChainWeaver
io.github.dgenio由 GitHub 账号 dgenio 发布v0.12.1更新于 Oct 24, 2026
Expose deterministic ChainWeaver flows as MCP tools without LLM calls between steps.
发布方自己的服务:Agent.chain.tokyo Address Contracts
概览
ChainWeaver 将已审查的确定性工具流程包装成 MCP 工具,让助手以单次调用执行整条流程,步骤之间无需调用模型。
- 可以做什么
- 将已审查的确定性流程以 MCP 工具形式提供,让助手一次调用整条流程。用 Pydantic 模型对每一步的输入与输出做严格校验,并记录结构化的步骤执行日志。支持从文件加载流程、校验流程文件、以 ASCII、DOT 或 Mermaid 可视化流程结构。提供确定性证明、属性模糊测试、结构漂移检查与成本估算报告。内置一组纯确定性的工具库,可组合出基本流程。
- 适用场景
- 当你已有一条被证明、经审查且完全确定性的工具流程,希望助手以单个工具调用执行,而不在步骤之间插入模型推理时适用。若流程本来就固定,作者自己也建议先考虑普通函数或既有框架。
- 运行要求
- 需在本机以 Python 运行,通过 uvx 或 pip 安装 chainweaver 包。以 MCP 形式提供流程需安装 mcp 额外依赖;读写 .flow.yaml 流程文件需安装 yaml 额外依赖。流程中的工具需以 Python 模块提供。
安装
在 SourceWeft 中
- 打开 控制台中的 ChainWeaver,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
ChainWeaver
Find where your agent no longer needs to reason. Review the evidence. Turn the accepted path into a governed deterministic capability.
[PyPI] [CI] [Python] [License] [Open in Colab] [Read the Weaver Stack overview on Towards AI]
[ChainWeaver quick start: pip install, run a flow, and see the LLM-free step log]
Product thesis under validation — observe → prove → review → compile. ChainWeaver can inspect repeated tool behavior, surface candidates, and execute reviewed deterministic paths with typed contracts. Deterministic execution by itself is not the moat: if you already know the exact workflow, a normal Python function, LangGraph node, or provider-native tool may be simpler. The hypothesis being tested is that trace-derived evidence, useful rejection, governed promotion, security-boundary preservation, and drift detection make ChainWeaver worth adopting. See Product validation & adoption gates and #553.
Remove reasoning boundaries, never security boundaries. Compiling several tool calls into one capability must not silently aggregate privileges or erase child approval requirements. That invariant is tracked explicitly in #554.
Governance for deterministic tool paths. Typed I/O at every step, file-serializable flows, schema-drift detection, determinism attestation, property fuzzing, and structured audit traces provide a disciplined execution substrate for paths that have actually earned deterministic promotion.
Benchmarks are evidence about the executor, not proof of product-market fit. The repo's benchmark report is reproducible — regenerate it yourself with
python benchmarks/report.py— and shows the deterministic core avoiding model-mediated transitions in its synthetic comparison. It does not establish that every repeated path should be compiled, or that ChainWeaver beats the obvious plain-Python implementation. The independent validation program requires that manual baseline explicitly.
See the full example below or run
python examples/simple_linear_flow.py
Installation · Why ChainWeaver? · Is this for me? · Product validation · Quick Start · Architecture · Docs site · Roadmap
See it in 30 seconds
The deterministic executor solves a simple problem: once a path has been shown to need no intermediate reasoning, stop paying a model to re-decide the same plumbing on every run.
Before — a model-mediated path:
After review — the accepted path can run deterministically:
The agent still decides which capability to invoke. The deterministic steps inside it run with strict Pydantic validation and no LLM involvement.
The harder product question comes before this diagram: should this path be compiled at all? A useful ChainWeaver analysis must be able to show why a candidate is recurrent and structurally safe and reject paths where semantic judgment, side effects, authorization, or approval boundaries still matter. That claim is currently being tested on independent traces in #553.
Copy-paste executor path:
The summary below is a condensed view of the real ExecutionResult the script
produces:
Why ChainWeaver?
Why not just write a Python function?
Often, you should.
If your team already knows the workflow is fixed, a normal function or the workflow primitives in your existing framework are usually the lowest-complexity answer. ChainWeaver should earn another dependency only when its lifecycle adds meaningful value—for example:
- discovering non-obvious repeated model-mediated paths from real traces;
- showing evidence for recurrence, dataflow compatibility, and counterexamples;
- rejecting tempting paths that still require semantic judgment;
- preserving approval and authorization constraints during promotion;
- producing reproducible review evidence and artifact identity;
- detecting schema/safety/policy drift after promotion;
- exporting or executing the accepted capability without pretending that fewer model calls automatically means greater correctness.
Whether those advantages are strong enough in real teams is a falsifiable product hypothesis, not a README assumption. See docs/product-validation.md.
When an LLM-powered agent routes tools together — fetch_data → transform → store — a
common pattern is to insert an LLM call between steps so the model can decide
what to do next. For a path that has been demonstrated and reviewed as fully
deterministic, those intermediate calls can add latency, cost, and variability
without adding useful judgment.
ChainWeaver's executor can run an accepted deterministic path without any LLM involvement between steps:
How is this different from LangChain / LangGraph / Prefect / Dagster / Temporal?
Those frameworks can also execute deterministic code. ChainWeaver should not be selected because deterministic execution is impossible elsewhere. Its current product thesis is narrower: start from observed agent/tool behavior, establish which regions no longer need reasoning, make the evidence and rejections reviewable, then promote accepted paths into governed deterministic capabilities.
The execution substrate remains deliberately small and LLM-free between steps, but the project is testing whether the evidence/governance lifecycle—not the mere existence of another workflow runtime—is the part users value.
See docs/comparisons.md for the detailed, versioned comparison and docs/product-validation.md for the criteria that can falsify this positioning.
Is this for me?
ChainWeaver is built for one specific shape of problem. The full fit/non-fit page covers the nuances; the short version:
Use ChainWeaver when
- You have real agent/tool traces and suspect parts of the path are repeated plumbing rather than useful model judgment.
- You want evidence and review around which paths deserve deterministic promotion, not only a runtime for a workflow you already know.
- Determinism, strict schemas, auditability, and drift detection matter once a path is promoted.
- You are prepared to keep security and approval boundaries explicit rather than treating a macro-tool invocation as blanket child authorization.
Don't use ChainWeaver when
- You already know the workflow and a normal Python function or your existing framework expresses it clearly enough.
- Every step requires open-ended reasoning to pick the next one (use an agent framework: LangGraph, the OpenAI / Anthropic SDK tool-use loops).
- You need a general workflow engine for scheduled / durable jobs across time (use Prefect, Dagster, or Temporal).
- You expect the executor to call an LLM. It deliberately doesn't.
- You cannot preserve the authorization/approval semantics of a side-effecting path during compilation.
The product thesis, validation protocol, and kill/pivot criteria are public in docs/product-validation.md.
For the correctness argument behind the deterministic execution design, see docs/data-integrity.md.
Part of the Weaver Stack
ChainWeaver is the deterministic multi-step tool execution layer of the
Weaver Stack — a family of small,
composable SDKs that share weaver-spec's SelectableItem routing contract.
On the request path a router picks which capability to invoke, ChainWeaver
runs the deterministic tool path behind it, and downstream layers gate and
guard the call:
Use standalone or together. Each layer stands on its own — ChainWeaver's
base install has no hard dependency on any sibling and works fully
standalone. Real interop runs through the chainweaver[weaver-stack] extra,
which pins the published weaver-contracts
package: ChainWeaver consumes its SelectableItem / RoutingDecision /
CapabilityToken types directly, so a router can hand a routing decision
straight to resolve_flow_from_routing_decision() for deterministic
execution. See the runnable
Weaver Stack golden path (issue #234).
ChainWeaver does not replace an agent framework. It is meant to be called from one — see the LangGraph recipe (issue #205) and the OpenAI Agents SDK recipe (issue #206) for the canonical integration patterns.
For host-level expectations (when to invoke, how to store traces, side-effect tools, MCP parity), see the Runtime responsibilities page.
Installation
The base install pulls only five runtime dependencies (deepdiff,
packaging, pydantic, tenacity, typer) and has no transitive LLM
SDK pinned. Pick extras for the integrations you actually use:
Maintainer tooling (pytest, ruff, mypy, nbmake, ...) is not a published
extra: it lives in PEP 735 dependency groups, installed with
pip install -e ".[integrations]" --group dev (#550). The [dev] extra no
longer exists.
Package metadata (pyproject.toml) publishes URLs for the
documentation, the
source, the
changelog,
and the
issue tracker, so pip show chainweaver and the PyPI sidebar point users to the right place.
Quick Start
Define tools, build a flow, and execute it
You can also run the bundled examples directly:
The hosted docs also include a cookbook with paired
scripts under examples/cookbook/, plus framework recipes and workflow
templates (LangGraph, OpenAI Agents SDK, release-readiness, policy evaluation).
With the @tool decorator
The @tool decorator eliminates boilerplate by introspecting type hints to
auto-generate input schemas:
Decorated tools are also directly callable:
See examples/decorator_tool.py for a runnable before/after comparison.
With FlowBuilder
FlowBuilder provides a fluent, chainable API as a more Pythonic alternative
to constructing Flow objects directly. It produces an identical Flow — it
is syntax sugar, not a replacement:
.step(tool_name, **mapping)— adds a step; string values are context-key lookups, non-string values are literal constants, no kwargs = full-context passthrough..step_from(flow_step)— appends a pre-builtFlowStepfor interop..with_input_schema(Model)/.with_output_schema(Model)— optional flow-level Pydantic schema declarations..with_trigger(conditions)— optional free-form trigger metadata..build()— returns a validatedFlow; raisesFlowBuilderErrorifnameordescriptionis missing.
Interactive playground
Want to try ChainWeaver without installing anything locally? The
playground/ directory ships a Streamlit app that lets you pick
a pre-loaded flow, edit its JSON input, run it, and watch the step-by-step,
LLM-free execution trace with a Mermaid diagram — the same FlowExecutor
the library ships.
It ships three example flows (arithmetic, a data flow, and an MCP-style
search), produces shareable ?share=<token> links that round-trip a run through
the URL, and is fully stateless so it deploys to Streamlit Community Cloud with
no backend. See playground/README.md for local-run and
deployment instructions.
Architecture
Core abstractions
Tool
A tool wraps a plain Python callable together with Pydantic models for strict input/output validation.
FlowStep
input_mapping maps keys from the accumulated execution context into the
tool's input schema. String values are looked up in the context — a plain key
is a top-level lookup, and a string starting with / is an RFC-6901 JSON
pointer into the nested context (#387) — while non-string values are literal
constants.
output_mapping (#386) optionally renames and prunes a tool's outputs before
they merge into the context: {context_key: output_key} keeps only the listed
output keys, each renamed. Omit it to merge every output key verbatim.
To inject per-request secrets that must never appear in a model-visible schema
(auth tokens, account numbers), pass them at execute-time instead of in
initial_input:
Flow
An ordered sequence of steps. See AGENTS.md §5 for the full
field table (status, tool_schema_hashes, and the input_schema_ref /
output_schema_ref string fields with their resolved-property accessors).
A FlowStep runs either a tool (tool_name) or a registered
sub-flow (flow_name) — exactly one, never both. Referencing a sub-flow lets
you compose reusable flows (issue #75):
The executor runs the sub-flow with the step's resolved inputs, merges its
output back into the parent context, and attaches the sub-flow's
ExecutionResult to the parent StepRecord.sub_result. Sub-flow references
are checked for cycles and a configurable max nesting depth
(FlowExecutor(max_composition_depth=...), default 10) before execution,
raising FlowCompositionError otherwise.
A deadline or CancellationToken passed to execute_flow is forwarded into
composed sub-flows, so cancellation and the wall-clock budget are observed at
the step boundaries inside a sub-flow — a long sub-flow stops between its own
steps rather than only at the parent boundary. The cost report's
steps_executed counts the tool invocations a composed step actually drove
(recursively), so llm_calls_avoided reflects every tool that ran across the
composition.
FlowRegistry
An in-memory catalogue of flows.
FlowExecutor
Runs a flow step-by-step with full schema validation and structured logging. No LLM calls are made at any point.
ChainAnalyzer
Discovers schema-compatible tool combinations offline, before any flow is
registered or executed. compatibility_matrix() checks that every required
input field of a consumer tool appears in the output of the producer with a
matching type. suggest_flows() auto-wires input_mapping by name-matching
and returns Flow objects ready for FlowRegistry.register_flow().
Data flow
MCP Integration Concept
ChainWeaver can sit between agent/tool observation and deterministic execution:
MCP is an interoperability surface, not the product category. The current runtime can expose reviewed flows as MCP tools, while #555 explores whether portable outputs should let the same approved capability execute through other hosts without requiring ChainWeaver to own the runtime.
ChainWeaver is a library you embed, not the runtime that owns your trace
store, identity system, or enterprise authorization control plane. Host authors
should read docs/runtime-responsibilities.md.
Integrations
ChainWeaver plugs into the MCP ecosystem and major agent frameworks. Existing integrations remain supported; new adapter breadth is deliberately lower priority than independent product validation.
Install the extra you need: pip install 'chainweaver[mcp]' (or langgraph,
openai-agents, langchain, llamaindex). Importing any integration without its
extra raises a clear ImportError.
Looking to publish or list ChainWeaver in the MCP registry / awesome-lists / framework
directories? See docs/distribution.md. Broad distribution
is intentionally gated behind the naming decision (#556) and validation evidence
(#553).
Error Handling
All errors are typed and traceable:
All exceptions inherit from ChainWeaverError and carry a stable diagnostic
code (e.g. CW-E006); the CLI prefixes it on error output and failing
StepRecords expose it as error_code. See the full code table in
docs/reference/error-table.md.
Standard tool library
chainweaver.contrib.tools ships a curated set of deterministic
utility tools so that a new user can compose a meaningful flow on the
first afternoon without writing any Tool boilerplate.
The library is deterministic-only: no HTTP, file I/O, database
access, RNG, or clocks. Anything stateful belongs in user code.
Install with pip install 'chainweaver[contrib]'.
Runnable examples: examples/contrib_pluck_and_set.py,
examples/contrib_map_filter.py.
Cost-avoided reporting
Every inter-step transition a naive agent delegates to an LLM is a routing
call ChainWeaver eliminates. CostProfile / CostReport turn that into a
dollar estimate, and the maintained PROVIDER_PRICES table (dated snapshots,
no live HTTP lookup) lets you price it against a real model:
Every report built from the table carries the snapshot's as_of date so
stale prices are visible. Unknown (provider, model) pairs raise
CostProfileError rather than guessing. Pass an explicit
profile=CostProfile(...) when you have better per-call numbers, or set
cost_profile= on FlowExecutor to attach a report to every
ExecutionResult. Prices are refreshed by a maintainer-reviewed PR
(.github/workflows/update-prices.yml) — never auto-merged.
These reports are estimates unless their inputs come from observed trace measurements. They must not be presented as evidence that a candidate should be compiled; #377 tracks calibration of assumed versus measured model mediation.
Export adapters
Hand a compiled flow off to any external agent framework via
chainweaver.export:
flow_to_openai_function emits the
{"type": "function", "function": {…}} shape OpenAI's chat / responses
APIs expect. flow_to_anthropic_tool emits Anthropic's tool_use
shape. flow_to_callable wraps the flow as a Callable[[dict], dict]
suitable for any framework that accepts arbitrary Python callables.
None of these adapters imports openai or anthropic — they emit
dicts and callables only. Runtime integration with those clients is
the caller's job.
Runnable example: examples/export_openai_anthropic.py.
Ecosystem bridges (LangChain, LlamaIndex)
chainweaver.integrations.langchain and
chainweaver.integrations.llamaindex ship thin bidirectional adapters
so existing LangChain BaseTool / LlamaIndex FunctionTool
instances can be pulled into ChainWeaver, and ChainWeaver Tool
instances can be pushed back out.
Install with pip install 'chainweaver[langchain]' /
'chainweaver[llamaindex]'. Importing either module without the
relevant extra raises a clear ImportError.
Plugin discovery
For third-party packages — chainweaver-aws, chainweaver-stripe,
… — ChainWeaver follows the same entry-point convention used by
pytest, Sphinx, MkDocs, and friends.
Publisher (pyproject.toml):
Consumer:
Discovery is opt-in — importing chainweaver does not trigger
plugin imports. Misbehaving plugins (raise on import, return the
wrong type) are logged at WARNING and skipped; pass
strict=True to discover_tools() / discover_flows() for the loud
form.
Runnable example: examples/plugin_discovery.py.
Runtime learning
ChainWeaver can watch what an agent does and propose deterministic-flow candidates for repeated paths. A repeated sequence is not proof that the path is safe or valuable to compile; proposals require review, and the product validation program is explicitly measuring false positives, false negatives, and useful rejections.
ChainObserver(#78) mines repeated tool sequences from runtime traces and emits rankedFlowSuggestions — never auto-registered.chainweaver record(#226) mines recorded JSONL traces and writes candidate flow files for explicit review/promotion.ChainWeaverService(#101) ties observation, static analysis, and optional offline proposals into an analyze → propose → govern → promote loop.
See Product validation & adoption gates before interpreting a suggestion as proof that a path should become deterministic.
Roadmap
The current roadmap is validation-first, not feature-count-first. The latest
published release is v0.14.1; newer work on main remains unreleased until a
subsequent release is cut.
Broad directory submissions, hosted-playground investment, and additional framework-adapter breadth are deliberately lower priority until these gates produce evidence.
v1.0.0 is also evidence-gated: independent workloads/adopters, a manual
baseline, an external security review, repeated use, a downstream integration,
and a 30-day RC compatibility soak are required by
docs/v1-release-criteria.md.
Command-line interface
ChainWeaver ships a chainweaver console script with the following subcommands.
Reading .flow.yaml files needs the YAML extra
(pip install 'chainweaver[yaml]' — also listed in Installation).
The run example below uses a flow shipped under examples/, so it should be
invoked from the repository root.
run is the fastest path from a fresh install to seeing a flow execute:
point it at a .flow.yaml/.flow.json file, pass --tools <module> (the
import path of a Python module that exposes Tool instances at top
level), and supply the initial input as JSON. Hand-authored flow files must
declare a type: Flow (or type: DAGFlow) discriminator at the top — see
the flow file format reference. Most
reporting subcommands also accept --format json for machine consumption
(inspect, validate, check, run, profile, diff, attest,
suggest, doctor); the exceptions are viz, which uses
--format ascii|dot|mermaid, explain, which uses --format md|text, and
dump-schema, which writes a raw JSON Schema and has no --format flag. The result-producing commands (inspect,
validate, check, profile, diff, attest) wrap their --format json
output in a stable, versioned envelope
({"schema_version", "status", "data", "errors"}) so automation can branch on
status / error codes — see
machine-readable output.
All subcommands share the same exit-code contract (0 success, 1
business-logic error, 2 file-not-found / argument error), and the CLI ships
tab-completion (chainweaver --install-completion).
inspect and viz resolve flows from disk or a registry.
Pass --file <path>, --discover-dir <dir>, or --discover-entry-points to
resolve a flow without writing any Python (issue #381); chainweaver flows list previews what is discoverable. With no discovery flag they fall back to a
process-scoped, in-memory registry installed programmatically — running
chainweaver inspect my_flow with neither a flag nor a configured registry
exits 1 with No registry configured. Call chainweaver.cli.set_default_registry(...) before invoking the CLI.. To wire
the default-registry path, use a small entry script:
See docs/cli.md § Programmatic registration
for the full pattern, including why the split exists (file-oriented
commands stay zero-config, registry-oriented commands stay
introspection-friendly).
Development
New contributors: see Your first contribution
in CONTRIBUTING.md for the good-first-issue / good-first-ai-issue onramp
and the step-by-step path to your first PR.
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
来源:README.md,提交 08be8da
工具
0版本历史
1- v0.12.1最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分
其他 Chain 集成
Agent.chain.tokyo Address Contracts
tokyo.chain.agent官方发布者
让助手为 AI 代理租用日本真实邮寄地址:浏览地点与楼层、创建 55 USDC 支付意图,并查看合约与事件。

DeviceChain
io.devicechain
面向自托管 DeviceChain IoT 实例的只读 MCP 工具,让助手查看设备、遥测数据和告警。

BridgePilot — cross-chain route quotes
由 GitHub 账号 ert1981 发布
Best cross-chain route via LI.FI + Across with net USD value. Non-custodial, x402-paid.
BrainChain
com.usebrainchain
让助手把任务交给由 AI 代理挑选并评分的顶尖模型,仅当成果达到你设定的质量标准时才以 USDG 或 USDC 付款。

Agent Data Tools: Chain data
由 GitHub 账号 Nutshell2000 发布
按次付费的远程 MCP 服务器,提供实时链上数据读取:五条 EVM 链及比特币的钱包余额、Gas、交易、日志与 NFT。