Skip to main content
1

Install the package

Or, for a local checkout:
2

See it enforce — no API keys needed

Save this policy as policy.yaml. It gives two roles different limits on the same refund_order tool:
Ask Hexgate to decide the same $400 refund for each role. hexgate policy test evaluates a policy offline — no model, no API keys:
Same tool, same request — the caller’s role and the arguments decide. The limits live in the policy, outside the model, so a confused or prompt-injected agent can’t raise its own cap.
3

Enforce it in a live agent

Now put the same policy in front of a real agent. Build one with create_agent, apply the policy with enforce_policy, and run the same request under two roles — the role comes from the HexgateContext scope:
Same agent, same request — under support the model’s refund_order($400) call is blocked by the policy (over the $50 cap) and it receives a [policy_denied] marker it can recover from; under billing it goes through. That’s enforce_policy + the per-call HexgateContext doing the work — no platform, no extra services.
Already have an agent? You don’t rewrite it — you wrap it. An OpenAI Agents SDK / LangChain / Google ADK / Pydantic AI agent is gated with a single adapter call (e.g. HexgateRunner is a drop-in for agents.Runner). See Framework adapters.

Next steps

Wrap your framework's agent

OpenAI Agents, LangChain/LangGraph, Google ADK, Pydantic AI — same one-wrapper pattern.

Author a policy

Roles, tools, modes, argument constraints, inheritance — the full spec.

Request context + roles

How the end user’s identity + role reach the decision at call time.

Try the terminal REPL

hexgate chat --agent example_agent — a local agent with inline decision panels.

Go remote with Hexgate Cloud

Remote policy enforcement + audit with zero infra — get a key, set one env var.

Pick a path

Local hexgate chat vs platform-backed hexgate serve — decide here.