
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。