Skip to content

Sondera Harness

Deterministic guardrails for AI agents.

Open-source. Works with LangGraph, ADK, Strands, or any custom agent.

PyPI version Python 3.12+ License: MIT

Get Started Try in Colab


What is Sondera Harness?

Sondera Harness evaluates Cedar policies before your agent's actions execute. When a policy denies an action, the agent gets a reason why and can try a different approach. Same input, same verdict. Deterministic, not probabilistic.

Example policy:

@id("forbid-risky-fs-shell")
forbid(
  principal,
  action == Action::"Bash",
  resource
)
when {
  context has parameters &&
  (context.parameters.command like "*rm -rf /*" ||
   context.parameters.command like "*mkfs*" ||
   context.parameters.command like "*dd if=/dev/zero*" ||
   context.parameters.command like "*> /dev/sda*")
};

This policy stops your agent from running rm -rf, every time.


Why Use Sondera Harness?

  • Steer, don't block. Denied actions include a reason. Return it to the model, and it tries something else.
  • Deterministic. Stop debugging prompts. Rules are predictable.
  • Drop-in integration. Native middleware for LangGraph, Google ADK, and Strands.
  • Full observability. Every action, every decision, every reason. Audit-ready.

Learn about decisions

Explore trajectories


See Everything in Real-Time

The TUI shows trajectories, adjudications, and policy decisions as your agent runs.

Sondera TUI
uv run sondera   # or just `sondera` if installed globally via pip

Platform only

The TUI requires Sondera Platform (SonderaRemoteHarness). The local CedarPolicyHarness doesn't persist trajectory data.


Installation

Python 3.12+ required.

uv add sondera-harness

With framework extras:

uv add "sondera-harness[langgraph]"   # LangGraph
uv add "sondera-harness[adk]"         # Google ADK
uv add "sondera-harness[strands]"     # Strands
uv add "sondera-harness[ai]"          # AI Assist

pip install sondera-harness

With framework extras:

pip install "sondera-harness[langgraph]"   # LangGraph
pip install "sondera-harness[adk]"         # Google ADK
pip install "sondera-harness[strands]"     # Strands
pip install "sondera-harness[ai]"          # AI Assist


Add Sondera Harness to Your Agent

from langchain.agents import create_agent
from sondera import CedarPolicyHarness
from sondera.langgraph import SonderaHarnessMiddleware, Strategy

harness = CedarPolicyHarness(policy_set=policy, schema=schema)
middleware = SonderaHarnessMiddleware(harness=harness, strategy=Strategy.STEER)

agent = create_agent(model, tools=tools, middleware=[middleware])

Full LangGraph guide

from google.adk import Agent, Runner
from sondera import SonderaRemoteHarness
from sondera.adk import SonderaHarnessPlugin

harness = SonderaRemoteHarness()
plugin = SonderaHarnessPlugin(harness=harness)

runner = Runner(
    agent=agent,
    app_name="my-app",
    plugins=[plugin],
)

Full ADK guide

from strands import Agent
from sondera import SonderaRemoteHarness
from sondera.strands import SonderaHarnessHook

harness = SonderaRemoteHarness()
hook = SonderaHarnessHook(harness=harness)

agent = Agent(
    model="anthropic.claude-3-5-sonnet-20241022-v2:0",
    hooks=[hook],
)

Full Strands guide

from sondera import CedarPolicyHarness, Stage, Role, ToolRequestContent

harness = CedarPolicyHarness(policy_set=policy, schema=schema)
await harness.initialize(agent=agent)

result = await harness.adjudicate(
    Stage.PRE_TOOL, Role.MODEL,
    ToolRequestContent(tool_id="Bash", args={"command": cmd})
)

Full custom integration guide


Local or Platform

CedarPolicyHarness evaluates policies locally with no network calls or external dependencies. Good for development and simple deployments.

SonderaRemoteHarness connects to Sondera Platform for team policy management, dashboards, and centralized audit logs.

Both implement the same interface. Switch by changing one line.

Deployment options


Need Help?