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
| Framework | Tool name CAIN sees | Plugs into |
|---|---|---|
| Python (any function) | merge_pull_request | the function that acts |
| LangChain | merge_pull_request | your agent's tool list |
| LangGraph | merge_pull_request | the tools your graph's nodes call |
| OpenAI Agents SDK | merge_pull_request | function tools |
| CrewAI | merge_pull_request | CrewAI's before-tool-call hooks |
| LlamaIndex | merge_pull_request | FunctionTool |
| Pydantic AI | merge_pull_request | an agent capability |
| AutoGen (agentchat) | merge_pull_request | the callables you give AssistantAgent |
| Google ADK | merge_pull_request | the functions in an agent's tools |
| Claude Agent SDK | mcp__ops__merge_pull_request | PreToolUse hooks |
| MCP client (Python) | merge_pull_request | any MCP client session |
| OpenTelemetry | merge_pull_request | your existing tracing |
| Any other framework | merge_pull_request | any Python callable |
| TypeScript / JavaScript | merge_pull_request | any async function |
| HTTP (any language) | merge_pull_request | your 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