Skip to content
This repository was archived by the owner on Sep 21, 2026. It is now read-only.

About

CodeRifts integration example for OpenAI Functions

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

CodeRifts — OpenAI Function Calling Example

Demonstrates how to add CodeRifts enforcement to OpenAI function calling, blocking unsafe API calls before execution.

Quick Start

pip install requests
python main.py

How It Works

The handle_tool_call function wraps every tool execution with a CodeRifts preflight check:

def handle_tool_call(tool_call):
    args = json.loads(tool_call["arguments"])
    decision = coderifts_preflight(args["spec_url"])

    if decision["decision"] == "BLOCK":
        return json.dumps({"error": "blocked_by_coderifts"})

    # Safe to proceed
    return execute_api_call(args)

The model receives the block result as a tool response and can explain to the user why the call was blocked.

Example Output

[OPENAI] Model wants to call API at https://petstore3.swagger.io/api/v3/openapi.json
[CODERIFTS] decision=ALLOW risk=12
[OPENAI] Executing /orders/123 on https://petstore3.swagger.io/api/v3/openapi.json
[OPENAI] Tool call succeeded: {"status": "success", "data": {"order_id": "12345"}}

Links

About

CodeRifts integration example for OpenAI Functions

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages