Aller au contenu principal
Bêta non calibrée
StrikeStrike

OpenAI decision tool

Chat Completions and Responses API formats for strike_decision.

Register the tool

Chat Completions tools array:

Python
import strikeflow as strike

tool = strike.strike_decision_tool()
definition = tool.openai(strict=False)
assert definition["function"]["name"] == "strike_decision"

Strict JSON schema (OpenAI structured outputs / Agents SDK):

Python
strict_def = tool.openai(strict=True)

Responses API:

Python
responses_def = tool.openai_responses(strict=False)

Pass the returned dict to your OpenAI client alongside your existing chat model. Strike only defines the tool; it does not choose your chat model.

Handle a tool call

When the model returns a strike_decision tool call, run strike-1 and append the tool message:

Python
import json
import strikeflow as strike

tool = strike.strike_decision_tool()
history = [
    {"role": "system", "content": "You are a support triage agent."},
    {"role": "user", "content": "The app crashes on startup since the last update."},
]

tool_call = {
    "id": "call_1",
    "type": "function",
    "function": {
        "name": "strike_decision",
        "arguments": json.dumps({
            "question": "Which team should own this ticket?",
            "kind": "choice",
            "options": ["billing", "tech", "sales"],
            "context": None,
        }),
    },
}

tool_message = tool.handle_openai_tool_call(tool_call, messages=history, run_id="run-1")
history.append(tool_message)
out = json.loads(tool_message["content"])
print(out["answer"], out["probabilities"])

Responses API function_call item

Python
import json
import strikeflow as strike

tool = strike.strike_decision_tool()
item = {
    "type": "function_call",
    "call_id": "fc_1",
    "name": "strike_decision",
    "arguments": json.dumps({
        "question": "Is this spam?",
        "kind": "yes_no",
        "options": None,
        "context": "WIN A FREE IPHONE!!! click now",
    }),
}
output_item = tool.handle_responses_function_call(item, run_id="resp-1")
print(output_item["type"], json.loads(output_item["output"])["answer"])

OpenAI Agents SDK

Install strikeflow[agents]:

Python
import json
import strikeflow as strike

ft = strike.strike_decision_tool().openai_agents()
# Register ft with your Agent; on invoke:
payload = json.dumps({
    "question": "Is this spam?",
    "kind": "yes_no",
    "options": None,
    "context": "WIN A FREE IPHONE!!! click now",
})

Use await ft.on_invoke_tool(ctx, payload) inside an Agents SDK run.

OpenAI decision tool: Strike docs