behaviorweave 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- behaviorweave-0.1.0/.env.example +2 -0
- behaviorweave-0.1.0/.github/workflows/ci.yml +19 -0
- behaviorweave-0.1.0/.gitignore +13 -0
- behaviorweave-0.1.0/.readthedocs.yaml +12 -0
- behaviorweave-0.1.0/CHANGELOG.md +5 -0
- behaviorweave-0.1.0/CONTRIBUTING.md +17 -0
- behaviorweave-0.1.0/LICENSE +89 -0
- behaviorweave-0.1.0/PKG-INFO +107 -0
- behaviorweave-0.1.0/README.md +72 -0
- behaviorweave-0.1.0/SECURITY.md +8 -0
- behaviorweave-0.1.0/docs/PRODUCTION_READINESS.md +20 -0
- behaviorweave-0.1.0/docs/PROJECT_STRUCTURE.md +18 -0
- behaviorweave-0.1.0/docs/VALIDATION_REPORT.md +45 -0
- behaviorweave-0.1.0/docs/api-reference.md +394 -0
- behaviorweave-0.1.0/docs/architecture/decisions.md +213 -0
- behaviorweave-0.1.0/docs/architecture/failure-strategy.md +7 -0
- behaviorweave-0.1.0/docs/architecture/goals.md +8 -0
- behaviorweave-0.1.0/docs/architecture/intervention-model.md +7 -0
- behaviorweave-0.1.0/docs/architecture/langchain.md +7 -0
- behaviorweave-0.1.0/docs/architecture/langgraph-xai.md +9 -0
- behaviorweave-0.1.0/docs/architecture/langgraph.md +5 -0
- behaviorweave-0.1.0/docs/architecture/non-goals.md +7 -0
- behaviorweave-0.1.0/docs/architecture/overview.md +21 -0
- behaviorweave-0.1.0/docs/architecture/pattern-model.md +7 -0
- behaviorweave-0.1.0/docs/architecture/policy-model.md +7 -0
- behaviorweave-0.1.0/docs/architecture/problem-statement.md +7 -0
- behaviorweave-0.1.0/docs/architecture/responsibility-matrix.md +9 -0
- behaviorweave-0.1.0/docs/architecture/state-model.md +11 -0
- behaviorweave-0.1.0/docs/architecture/testing.md +7 -0
- behaviorweave-0.1.0/docs/assets/behavior-lifecycle.svg +38 -0
- behaviorweave-0.1.0/docs/concurrency.md +10 -0
- behaviorweave-0.1.0/docs/conf.py +2 -0
- behaviorweave-0.1.0/docs/index.md +18 -0
- behaviorweave-0.1.0/docs/integrations/compatibility.md +7 -0
- behaviorweave-0.1.0/docs/live-examples.md +239 -0
- behaviorweave-0.1.0/docs/patterns.md +9 -0
- behaviorweave-0.1.0/docs/policies.md +9 -0
- behaviorweave-0.1.0/docs/quickstart.md +155 -0
- behaviorweave-0.1.0/examples/01_langchain_agent.py +16 -0
- behaviorweave-0.1.0/examples/02_langchain_mcp_live.py +44 -0
- behaviorweave-0.1.0/examples/03_langgraph_custom_graph.py +36 -0
- behaviorweave-0.1.0/examples/04_langgraph_multi_agent.py +106 -0
- behaviorweave-0.1.0/examples/05_langgraph_swarm.py +46 -0
- behaviorweave-0.1.0/examples/06_deepagents.py +30 -0
- behaviorweave-0.1.0/examples/07_deepagents_subagents.py +51 -0
- behaviorweave-0.1.0/examples/08_failure_streak.py +17 -0
- behaviorweave-0.1.0/examples/09_retry_loop.py +20 -0
- behaviorweave-0.1.0/examples/10_oscillation.py +16 -0
- behaviorweave-0.1.0/examples/11_cooldown.py +26 -0
- behaviorweave-0.1.0/examples/12_policy_escalation.py +21 -0
- behaviorweave-0.1.0/examples/13_multi_scope.py +15 -0
- behaviorweave-0.1.0/examples/14_concurrency.py +49 -0
- behaviorweave-0.1.0/examples/15_complete_agent_guard.py +45 -0
- behaviorweave-0.1.0/examples/common.py +195 -0
- behaviorweave-0.1.0/examples/local_alarm_mcp.py +62 -0
- behaviorweave-0.1.0/examples/real_explabs_chat.py +12 -0
- behaviorweave-0.1.0/mkdocs.yml +39 -0
- behaviorweave-0.1.0/pyproject.toml +61 -0
- behaviorweave-0.1.0/src/behaviorweave/__init__.py +27 -0
- behaviorweave-0.1.0/src/behaviorweave/engine.py +55 -0
- behaviorweave-0.1.0/src/behaviorweave/events.py +118 -0
- behaviorweave-0.1.0/src/behaviorweave/integrations/__init__.py +1 -0
- behaviorweave-0.1.0/src/behaviorweave/integrations/langchain/__init__.py +3 -0
- behaviorweave-0.1.0/src/behaviorweave/integrations/langchain/adapter.py +22 -0
- behaviorweave-0.1.0/src/behaviorweave/integrations/langgraph/__init__.py +3 -0
- behaviorweave-0.1.0/src/behaviorweave/integrations/langgraph/adapter.py +27 -0
- behaviorweave-0.1.0/src/behaviorweave/integrations/langgraph_xai/__init__.py +3 -0
- behaviorweave-0.1.0/src/behaviorweave/integrations/langgraph_xai/adapter.py +46 -0
- behaviorweave-0.1.0/src/behaviorweave/interventions.py +61 -0
- behaviorweave-0.1.0/src/behaviorweave/patterns.py +116 -0
- behaviorweave-0.1.0/src/behaviorweave/policies.py +81 -0
- behaviorweave-0.1.0/src/behaviorweave/py.typed +0 -0
- behaviorweave-0.1.0/src/behaviorweave/state.py +130 -0
- behaviorweave-0.1.0/tests/test_core.py +90 -0
- behaviorweave-0.1.0/tests/test_mcp_integration.py +20 -0
- behaviorweave-0.1.0/uv.lock +2170 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
pull_request:
|
|
5
|
+
jobs:
|
|
6
|
+
quality:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
steps:
|
|
9
|
+
- uses: actions/checkout@v4
|
|
10
|
+
- uses: astral-sh/setup-uv@v6
|
|
11
|
+
with:
|
|
12
|
+
python-version: "3.12"
|
|
13
|
+
- run: uv sync --extra dev
|
|
14
|
+
- run: uv run pytest
|
|
15
|
+
- run: uv run ruff check .
|
|
16
|
+
- run: uv run black --check .
|
|
17
|
+
- run: uv run pyrefly check
|
|
18
|
+
- run: uv run mkdocs build --strict
|
|
19
|
+
- run: uv build
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Use Python 3.12 and uv. Run:
|
|
4
|
+
|
|
5
|
+
```text
|
|
6
|
+
uv sync
|
|
7
|
+
uv run pytest
|
|
8
|
+
uv run ruff check .
|
|
9
|
+
uv run black --check .
|
|
10
|
+
uv run pyrefly check
|
|
11
|
+
uv run mkdocs build --strict
|
|
12
|
+
uv build
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Keep pattern detection, policy selection, and intervention execution separate. Add
|
|
16
|
+
tests for scope, duplicate delivery, concurrency, and serialization when changing
|
|
17
|
+
state behavior.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
"You" shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
67
|
+
|
|
68
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
69
|
+
|
|
70
|
+
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work.
|
|
71
|
+
|
|
72
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, provided that You meet the following conditions:
|
|
73
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
74
|
+
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
75
|
+
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices.
|
|
76
|
+
|
|
77
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You shall be under the terms and conditions of this License.
|
|
78
|
+
|
|
79
|
+
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor.
|
|
80
|
+
|
|
81
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
|
|
82
|
+
|
|
83
|
+
8. Limitation of Liability. In no event and under no legal theory shall any Contributor be liable to You for damages arising from this License.
|
|
84
|
+
|
|
85
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work, You may offer and charge for support, warranty, indemnity, or other liability obligations.
|
|
86
|
+
|
|
87
|
+
END OF TERMS AND CONDITIONS
|
|
88
|
+
|
|
89
|
+
Copyright 2026 Muni Harish
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: behaviorweave
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Behavioral policy and intervention framework for LangGraph and LangChain agents.
|
|
5
|
+
Author: S Muni Harish
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Keywords: agents,behavior,intervention,langchain,langgraph,policy
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Classifier: Typing :: Typed
|
|
13
|
+
Requires-Python: <3.13,>=3.12
|
|
14
|
+
Requires-Dist: langchain>=1.0
|
|
15
|
+
Requires-Dist: langgraph-xai>=0.1.0
|
|
16
|
+
Requires-Dist: langgraph>=1.0
|
|
17
|
+
Provides-Extra: dev
|
|
18
|
+
Requires-Dist: black>=25.0; extra == 'dev'
|
|
19
|
+
Requires-Dist: hypothesis>=6.0; extra == 'dev'
|
|
20
|
+
Requires-Dist: langchain[mcp]>=1.4; extra == 'dev'
|
|
21
|
+
Requires-Dist: mkdocs-material>=9.0; extra == 'dev'
|
|
22
|
+
Requires-Dist: mkdocs>=1.6; extra == 'dev'
|
|
23
|
+
Requires-Dist: pyrefly>=0.18; extra == 'dev'
|
|
24
|
+
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
|
|
25
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
26
|
+
Requires-Dist: ruff>=0.9; extra == 'dev'
|
|
27
|
+
Provides-Extra: examples
|
|
28
|
+
Requires-Dist: deepagents; extra == 'examples'
|
|
29
|
+
Requires-Dist: langgraph-swarm; extra == 'examples'
|
|
30
|
+
Provides-Extra: mcp
|
|
31
|
+
Requires-Dist: langchain[mcp]>=1.4; extra == 'mcp'
|
|
32
|
+
Provides-Extra: real-model
|
|
33
|
+
Requires-Dist: langchain-openai>=1.0; extra == 'real-model'
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
# BehaviorWeave
|
|
37
|
+
|
|
38
|
+
Behavioral policy and intervention framework for LangGraph and LangChain agents.
|
|
39
|
+
|
|
40
|
+
BehaviorWeave observes normalized execution events, detects deterministic behavioral
|
|
41
|
+
patterns, evaluates explicit policies, and emits intervention decisions. It does not
|
|
42
|
+
execute interventions, replace LangGraph, capture chain-of-thought, or require LangSmith.
|
|
43
|
+
|
|
44
|
+
## Why BehaviorWeave?
|
|
45
|
+
|
|
46
|
+
Agent frameworks are designed to execute models, tools, routing, and graph transitions.
|
|
47
|
+
They intentionally leave application-specific behavioral governance to the host system.
|
|
48
|
+
That creates a gap when an otherwise capable agent starts repeating a tool call, cycling
|
|
49
|
+
through retries, repeatedly delegating work, or continuing after a failure streak.
|
|
50
|
+
|
|
51
|
+
BehaviorWeave fills that gap with a small, deterministic policy layer:
|
|
52
|
+
|
|
53
|
+
- **Make recurring behavior explicit.** Normalize observable tool calls, node execution,
|
|
54
|
+
outcomes, retries, and delegations into events that can be evaluated consistently.
|
|
55
|
+
- **Keep decisions explainable.** Policies map known patterns and thresholds to a
|
|
56
|
+
structured intervention with the pattern, count, scope, reason, and policy ID.
|
|
57
|
+
- **Preserve framework ownership.** LangChain and LangGraph still own agent execution,
|
|
58
|
+
tool invocation, routing, persistence, and interrupts. Your application decides how
|
|
59
|
+
to apply a `nudge`, `pause`, `human_review`, or `stop` decision.
|
|
60
|
+
- **Avoid prompt-only guardrails.** A prompt can ask an agent not to repeat itself, but
|
|
61
|
+
it cannot provide deterministic, scope-isolated behavioral history at the runtime
|
|
62
|
+
boundary.
|
|
63
|
+
- **Support progressive intervention.** Start with a nudge, escalate after continued
|
|
64
|
+
behavior, or require human review without embedding policy logic into every tool or
|
|
65
|
+
graph node.
|
|
66
|
+
|
|
67
|
+
Use BehaviorWeave when you need deterministic operational controls around observable
|
|
68
|
+
agent behavior. It is not a replacement for model safety controls, authorization,
|
|
69
|
+
schema validation, LangGraph persistence, or a general-purpose event-processing system.
|
|
70
|
+
|
|
71
|
+
## Architecture
|
|
72
|
+
|
|
73
|
+
```text
|
|
74
|
+
LangGraph/LangChain -> langgraph-xai context -> BehaviorEvent
|
|
75
|
+
-> fingerprint -> pattern state -> policy -> InterventionDecision -> host runtime
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The core is framework-neutral internally. Adapters at `behaviorweave.integrations`
|
|
79
|
+
translate framework callbacks and preserve provenance references supplied by
|
|
80
|
+
`langgraph-xai`.
|
|
81
|
+
|
|
82
|
+
## Quickstart
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
from behaviorweave import BehaviorEngine, BehaviorEvent, EventType, PolicyRule, InterventionType
|
|
86
|
+
|
|
87
|
+
engine = BehaviorEngine(
|
|
88
|
+
policies=[PolicyRule("repeat-tool", "repeated_tool_call", 3, InterventionType.NUDGE)]
|
|
89
|
+
)
|
|
90
|
+
for i in range(3):
|
|
91
|
+
decision = engine.process(BehaviorEvent.tool_call("get_alarm", {"machine": "ETCH-3"},
|
|
92
|
+
scope="thread-1"))
|
|
93
|
+
assert decision.intervention.kind is InterventionType.NUDGE
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Install with `uv sync`; see [docs](docs/index.md) for the full architecture and integrations.
|
|
97
|
+
|
|
98
|
+
## Live integrations
|
|
99
|
+
|
|
100
|
+
The checked-in tests are deterministic. The real execution examples construct LangChain
|
|
101
|
+
v1 agents, call actual LangChain tools, and apply BehaviorWeave at the tool/delegation
|
|
102
|
+
boundary. See [live examples](docs/live-examples.md) for the opt-in real model setup;
|
|
103
|
+
provider credentials are read only from the environment.
|
|
104
|
+
|
|
105
|
+
## License
|
|
106
|
+
|
|
107
|
+
Apache License 2.0. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# BehaviorWeave
|
|
2
|
+
|
|
3
|
+
Behavioral policy and intervention framework for LangGraph and LangChain agents.
|
|
4
|
+
|
|
5
|
+
BehaviorWeave observes normalized execution events, detects deterministic behavioral
|
|
6
|
+
patterns, evaluates explicit policies, and emits intervention decisions. It does not
|
|
7
|
+
execute interventions, replace LangGraph, capture chain-of-thought, or require LangSmith.
|
|
8
|
+
|
|
9
|
+
## Why BehaviorWeave?
|
|
10
|
+
|
|
11
|
+
Agent frameworks are designed to execute models, tools, routing, and graph transitions.
|
|
12
|
+
They intentionally leave application-specific behavioral governance to the host system.
|
|
13
|
+
That creates a gap when an otherwise capable agent starts repeating a tool call, cycling
|
|
14
|
+
through retries, repeatedly delegating work, or continuing after a failure streak.
|
|
15
|
+
|
|
16
|
+
BehaviorWeave fills that gap with a small, deterministic policy layer:
|
|
17
|
+
|
|
18
|
+
- **Make recurring behavior explicit.** Normalize observable tool calls, node execution,
|
|
19
|
+
outcomes, retries, and delegations into events that can be evaluated consistently.
|
|
20
|
+
- **Keep decisions explainable.** Policies map known patterns and thresholds to a
|
|
21
|
+
structured intervention with the pattern, count, scope, reason, and policy ID.
|
|
22
|
+
- **Preserve framework ownership.** LangChain and LangGraph still own agent execution,
|
|
23
|
+
tool invocation, routing, persistence, and interrupts. Your application decides how
|
|
24
|
+
to apply a `nudge`, `pause`, `human_review`, or `stop` decision.
|
|
25
|
+
- **Avoid prompt-only guardrails.** A prompt can ask an agent not to repeat itself, but
|
|
26
|
+
it cannot provide deterministic, scope-isolated behavioral history at the runtime
|
|
27
|
+
boundary.
|
|
28
|
+
- **Support progressive intervention.** Start with a nudge, escalate after continued
|
|
29
|
+
behavior, or require human review without embedding policy logic into every tool or
|
|
30
|
+
graph node.
|
|
31
|
+
|
|
32
|
+
Use BehaviorWeave when you need deterministic operational controls around observable
|
|
33
|
+
agent behavior. It is not a replacement for model safety controls, authorization,
|
|
34
|
+
schema validation, LangGraph persistence, or a general-purpose event-processing system.
|
|
35
|
+
|
|
36
|
+
## Architecture
|
|
37
|
+
|
|
38
|
+
```text
|
|
39
|
+
LangGraph/LangChain -> langgraph-xai context -> BehaviorEvent
|
|
40
|
+
-> fingerprint -> pattern state -> policy -> InterventionDecision -> host runtime
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The core is framework-neutral internally. Adapters at `behaviorweave.integrations`
|
|
44
|
+
translate framework callbacks and preserve provenance references supplied by
|
|
45
|
+
`langgraph-xai`.
|
|
46
|
+
|
|
47
|
+
## Quickstart
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from behaviorweave import BehaviorEngine, BehaviorEvent, EventType, PolicyRule, InterventionType
|
|
51
|
+
|
|
52
|
+
engine = BehaviorEngine(
|
|
53
|
+
policies=[PolicyRule("repeat-tool", "repeated_tool_call", 3, InterventionType.NUDGE)]
|
|
54
|
+
)
|
|
55
|
+
for i in range(3):
|
|
56
|
+
decision = engine.process(BehaviorEvent.tool_call("get_alarm", {"machine": "ETCH-3"},
|
|
57
|
+
scope="thread-1"))
|
|
58
|
+
assert decision.intervention.kind is InterventionType.NUDGE
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Install with `uv sync`; see [docs](docs/index.md) for the full architecture and integrations.
|
|
62
|
+
|
|
63
|
+
## Live integrations
|
|
64
|
+
|
|
65
|
+
The checked-in tests are deterministic. The real execution examples construct LangChain
|
|
66
|
+
v1 agents, call actual LangChain tools, and apply BehaviorWeave at the tool/delegation
|
|
67
|
+
boundary. See [live examples](docs/live-examples.md) for the opt-in real model setup;
|
|
68
|
+
provider credentials are read only from the environment.
|
|
69
|
+
|
|
70
|
+
## License
|
|
71
|
+
|
|
72
|
+
Apache License 2.0. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Security
|
|
2
|
+
|
|
3
|
+
BehaviorWeave records observable execution metadata only. Do not put secrets, tokens,
|
|
4
|
+
prompts containing credentials, or private model reasoning in event metadata. State
|
|
5
|
+
serialization uses JSON and never evaluates policy strings or arbitrary code.
|
|
6
|
+
|
|
7
|
+
In-memory state is process-local and should not be treated as a durable security
|
|
8
|
+
boundary. Validate and redact payloads at the integration boundary.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Production readiness
|
|
2
|
+
|
|
3
|
+
| Area | Classification |
|
|
4
|
+
|---|---|
|
|
5
|
+
| Event/pattern/policy boundaries | Implemented and tested |
|
|
6
|
+
| Scope isolation and engine isolation | Implemented and tested |
|
|
7
|
+
| In-process concurrency | Implemented and tested |
|
|
8
|
+
| Idempotency | Implemented and tested |
|
|
9
|
+
| LangGraph-xAI public integration | Implemented; upstream API compatibility validated |
|
|
10
|
+
| LangGraph/LangChain adapters | Implemented; local MCP tool execution tested |
|
|
11
|
+
| Real provider execution | Flagship smoke scenarios validated manually; remains credential-dependent and opt-in |
|
|
12
|
+
| Durable/distributed persistence | Future |
|
|
13
|
+
| Swarm and Deep Agents adapters | Experimental examples |
|
|
14
|
+
| Semantic detection | Future |
|
|
15
|
+
| Security and privacy guidance | Implemented |
|
|
16
|
+
| Package/docs/CI quality gates | Implemented and locally validated |
|
|
17
|
+
|
|
18
|
+
The alpha release does not claim distributed state safety or stable upstream adapter
|
|
19
|
+
contracts. Future roadmap items include Redis/PostgreSQL stores, richer temporal
|
|
20
|
+
expressions, and OpenTelemetry hooks.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Project structure
|
|
2
|
+
|
|
3
|
+
```text
|
|
4
|
+
src/behaviorweave/
|
|
5
|
+
events.py immutable normalized events
|
|
6
|
+
state.py scoped atomic state store
|
|
7
|
+
patterns.py composable behavioral detectors
|
|
8
|
+
policies.py deterministic policy rules
|
|
9
|
+
interventions.py decision and explanation models
|
|
10
|
+
engine.py orchestration boundary
|
|
11
|
+
integrations/ LangGraph, LangChain, and xAI adapters
|
|
12
|
+
tests/ deterministic unit and concurrency coverage
|
|
13
|
+
examples/ provider-free runnable demonstrations as single files
|
|
14
|
+
docs/ user, architecture, and compatibility documentation
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Framework integrations translate observations only. Core modules never import private
|
|
18
|
+
LangGraph or LangChain internals.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Validation report
|
|
2
|
+
|
|
3
|
+
Executed in the repository on 2026-09-23:
|
|
4
|
+
|
|
5
|
+
| Check | Result |
|
|
6
|
+
|---|---|
|
|
7
|
+
| Python | PASS — uv-managed CPython 3.12.14 |
|
|
8
|
+
| uv | PASS — 0.12.15 |
|
|
9
|
+
| BehaviorWeave | PASS — 0.1.0 |
|
|
10
|
+
| langgraph | PASS — 1.2.12 |
|
|
11
|
+
| langchain | PASS — 1.4.2; public `create_agent` signature inspected |
|
|
12
|
+
| langgraph-xai | PASS — 0.1.0 |
|
|
13
|
+
| langgraph-swarm | NOT TESTED — example extra not installed |
|
|
14
|
+
| deepagents | NOT TESTED — example extra not installed |
|
|
15
|
+
| pytest | PASS — 7 tests (including local stdio MCP discovery and execution) |
|
|
16
|
+
| ruff | PASS |
|
|
17
|
+
| black | PASS |
|
|
18
|
+
| pyrefly | PASS |
|
|
19
|
+
| MkDocs | PASS — strict build |
|
|
20
|
+
| ReadTheDocs | NOT TESTED — configuration supplied |
|
|
21
|
+
| wheel/sdist | PASS — `uv build` |
|
|
22
|
+
| clean install | PASS — wheel built and editable environment imported |
|
|
23
|
+
| real provider smoke test | PASS — owner executed provider-backed flagship examples on 2026-09-23 using an environment-local credential; see execution evidence below |
|
|
24
|
+
| local stdio MCP discovery/execution | PASS — tool discovery and three guarded calls verified |
|
|
25
|
+
| remote MCP/live provider execution | NOT TESTED — requires an endpoint and a credential |
|
|
26
|
+
|
|
27
|
+
Commands used: `uv lock`, `uv sync --extra dev`, `uv run pytest -q`,
|
|
28
|
+
`uv run ruff check .`, `uv run black --check .`, `uv run pyrefly check`,
|
|
29
|
+
`uv run mkdocs build --strict`, and `uv build`.
|
|
30
|
+
|
|
31
|
+
## Provider-backed smoke evidence
|
|
32
|
+
|
|
33
|
+
The package owner executed the following opt-in examples locally on 2026-09-23. The
|
|
34
|
+
credential remained in the owner's environment and was not copied into this report.
|
|
35
|
+
|
|
36
|
+
| Example | Result |
|
|
37
|
+
|---|---|
|
|
38
|
+
| `examples/01_langchain_agent.py` | PASS — the live agent returned an alarm result, observed a repeated tool call, and received an instruction to reuse the existing result. |
|
|
39
|
+
| `examples/03_langgraph_custom_graph.py` | PASS — the compiled LangGraph workflow returned a structured operational incident report. |
|
|
40
|
+
| `examples/04_langgraph_multi_agent.py` | PASS — the live supervisor/specialist workflow returned a preliminary pressure-incident report with containment and investigation actions. |
|
|
41
|
+
| `examples/15_complete_agent_guard.py` | PASS — the LangGraph plus `langgraph-xai` guarded-agent workflow returned a pressure warning, historical context, and recommended action. |
|
|
42
|
+
|
|
43
|
+
Provider-generated prose is not asserted byte-for-byte because model responses are
|
|
44
|
+
non-deterministic. The deterministic suite remains the source of behavioral
|
|
45
|
+
regression assertions.
|