Back to Guides & Cookbooks
Guide

Tool Calling with /completions

Cadreen's tool calling is hybrid: some tools execute server-side with governance, others pass through to the client.

1

How tools work

You send tool definitions in the request. The model proposes tool calls. Cadreen evaluates governance on every call — both client and Cadreen tools. After governance approves, Cadreen tools execute server-side while client tools are returned to you for local execution.

Send01Model proposes02Cadreen splits03Merge & respond04
Click a step for details
2

The hybrid execution flow

When you ask "read main.go and email a summary to john@example.com", Cadreen splits the work:

YOUCADREENOUTCOMEread("main.go")send_email(...)create_invoice(...)Governance checkTool executionMemory writeExecuteBlockClarifyClient tools(bash, read, write)Server-side(governed: all tools)3 possible outcomes(auto / block / clarify)
Note
You don't see server-side tool executions. You don't see governance evaluations. The model describes what it did in the response.
3

Tool chaining

When the model proposes tool calls, you execute them and send results back:

Python
# First request — model proposes tools
response = client.chat.completions.create(
model="cadreen",
messages=[{"role": "user", "content": "List my connectors and summarize them"}],
tools=[...]
)

# Get tool calls
tool_calls = response.choices[0].message.tool_calls

# Execute tools locally, then send results back
messages = [
{"role": "user", "content": "List my connectors and summarize them"},
response.choices[0].message,
{
"role": "tool",
"tool_call_id": tool_calls[0].id,
"content": '{"connectors": ["stripe", "salesforce", "github"]}'
}
]

# Second request — model sees tool results
response2 = client.chat.completions.create(
model="cadreen",
messages=messages,
tools=[...]
)
Note
Use conversation_id to track conversations across requests. Tool call confirmations (when governance blocks a call) are matched to the correct conversation via this ID.
4

Self-healing

When a tool call fails, Cadreen diagnoses the failure and retries:

Tool execution fails (network error, invalid arguments, etc.)
Cadreen analyzes the error
If recoverable, the model is prompted to fix the arguments
The tool call is retried with corrected parameters
Note
This happens automatically. You don't need to implement retry logic for Cadreen tools. For client tools, you handle failures yourself.
5

Governance on tool calls

When governance blocks a tool call, the response contains text asking for confirmation instead of a tool call:

Blocked response
{
"choices": [{
"message": {
"role": "assistant",
"content": "I need your approval before I can process_refund.\n\nSay \"yes\" to proceed or \"no\" to skip."
},
"finish_reason": "stop"
}]
}
Note
See the Governance guide for the full approval flow.
6

Discovering available tools

Cadreen's tools are discovered from the capability graph. Use GET /api/v1/cadreen/tools to list all available tools for your workspace.

GET/api/v1/cadreen/tools
curl
curl https://accomplishanything.today/api/v1/cadreen/tools \
-H "Authorization: Bearer sk_cadreen_..."

Returns OpenAI function definitions ready to use in your request.

7

Limitations

Every tool call goes through governance — both client and Cadreen tools. The difference is where they execute, not whether they're governed.
If a client tool has the same name as a Cadreen tool, Cadreen's tool takes precedence.
Tool calls are buffered during streaming (no incremental deltas).
Cadreen tools execute server-side — you can't inspect the execution directly.