Skip to main content

BehaviorWeave

Behavioral policy and intervention framework for LangGraph and LangChain agents.

BehaviorWeave observes normalized execution events, detects deterministic behavioral patterns, evaluates explicit policies, and emits intervention decisions. It does not execute interventions, replace LangGraph, capture chain-of-thought, or require LangSmith.

Why BehaviorWeave?

Agent frameworks are designed to execute models, tools, routing, and graph transitions. They intentionally leave application-specific behavioral governance to the host system. That creates a gap when an otherwise capable agent starts repeating a tool call, cycling through retries, repeatedly delegating work, or continuing after a failure streak.

BehaviorWeave fills that gap with a small, deterministic policy layer:

  • Make recurring behavior explicit. Normalize observable tool calls, node execution, outcomes, retries, and delegations into events that can be evaluated consistently.
  • Keep decisions explainable. Policies map known patterns and thresholds to a structured intervention with the pattern, count, scope, reason, and policy ID.
  • Preserve framework ownership. LangChain and LangGraph still own agent execution, tool invocation, routing, persistence, and interrupts. Your application decides how to apply a nudge, pause, human_review, or stop decision.
  • Avoid prompt-only guardrails. A prompt can ask an agent not to repeat itself, but it cannot provide deterministic, scope-isolated behavioral history at the runtime boundary.
  • Support progressive intervention. Start with a nudge, escalate after continued behavior, or require human review without embedding policy logic into every tool or graph node.

Use BehaviorWeave when you need deterministic operational controls around observable agent behavior. It is not a replacement for model safety controls, authorization, schema validation, LangGraph persistence, or a general-purpose event-processing system.

Architecture

LangGraph/LangChain -> langgraph-xai context -> BehaviorEvent
  -> fingerprint -> pattern state -> policy -> InterventionDecision -> host runtime

The core is framework-neutral internally. Adapters at behaviorweave.integrations translate framework callbacks and preserve provenance references supplied by langgraph-xai.

Quickstart

from behaviorweave import BehaviorEngine, BehaviorEvent, EventType, PolicyRule, InterventionType

engine = BehaviorEngine(
    policies=[PolicyRule("repeat-tool", "repeated_tool_call", 3, InterventionType.NUDGE)]
)
for i in range(3):
    decision = engine.process(BehaviorEvent.tool_call("get_alarm", {"machine": "ETCH-3"},
                                                     scope="thread-1"))
assert decision.intervention.kind is InterventionType.NUDGE

Install with uv sync; see docs for the full architecture and integrations.

Live integrations

The checked-in tests are deterministic. The real execution examples construct LangChain v1 agents, call actual LangChain tools, and apply BehaviorWeave at the tool/delegation boundary. See live examples for the opt-in real model setup; provider credentials are read only from the environment.

License

Apache License 2.0. See LICENSE.

Release files for behaviorweave 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 behaviorweave 0.1.0
File Size Uploaded
behaviorweave-0.1.0.tar.gz 109.0 kB Details

Built distribution (wheel)

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

Total release size: 124.5 kB

Release files / behaviorweave-0.1.0.tar.gz

Download URL behaviorweave-0.1.0.tar.gz
Size 109.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b12da2d255c28122594fe84840b76eccd4454c567430f8f411e2ef7d92b5d241
BLAKE2b-256 checksum
How to use checksums
22bdf12122f3591059b77d04ed1fe89a4837e9600f9da95e5331369eba4f3bfc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

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

Download URL behaviorweave-0.1.0-py3-none-any.whl
Size 15.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1af52b047a2ebf201d1063b13641599c54f7ff770e08f571ae6d0c0f0e38d06e
BLAKE2b-256 checksum
How to use checksums
c290424f4798f7d865822c41e68b97dee90b2dff643b59571cfd41cd1978bd73
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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