CAIN-42 CAIN Studio

Recipes

Guard code merges

For an agent that merges pull requests, in 15 frameworks.

Last reviewed 2026-10-02

Merges into feature branches run; merges into main wait for a person.

The rule

{
  "name": "code-merge-guard",
  "effect": "require_approval",
  "priority": 10,
  "match_path": "/tools/merge_pull_request",
  "conditions": [
    {
      "field": "base",
      "op": "eq",
      "value": "main"
    }
  ]
}

Measured on production (2026-10-02, rule tester): the risky call below matches this rule and the safe one does not.

Risky{"repo": "acme/app", "number": 812, "base": "main"}
Safe{"repo": "acme/app", "number": 812, "base": "feature/login"}

Pick your framework

FrameworkTool name CAIN seesPlugs into
Python (any function)merge_pull_requestthe function that acts
LangChainmerge_pull_requestyour agent's tool list
LangGraphmerge_pull_requestthe tools your graph's nodes call
OpenAI Agents SDKmerge_pull_requestfunction tools
CrewAImerge_pull_requestCrewAI's before-tool-call hooks
LlamaIndexmerge_pull_requestFunctionTool
Pydantic AImerge_pull_requestan agent capability
AutoGen (agentchat)merge_pull_requestthe callables you give AssistantAgent
Google ADKmerge_pull_requestthe functions in an agent's tools
Claude Agent SDKmcp__ops__merge_pull_requestPreToolUse hooks
MCP client (Python)merge_pull_requestany MCP client session
OpenTelemetrymerge_pull_requestyour existing tracing
Any other frameworkmerge_pull_requestany Python callable
TypeScript / JavaScriptmerge_pull_requestany async function
HTTP (any language)merge_pull_requestyour own call site

Try CAIN-42 on your own agents

Create a free account and every new account starts with a 7-day trial of the full platform. Or try the sandbox first, with no account at all.

Create a free account →  ·  Try the sandbox  ·  See the whole ecosystem