Function calling in code
Set release boundaries for the order-status tool caller
Page 7 defines what the order-status function-calling assistant must refuse before release—security here is not a pasted happy path.
1Learn the idea
Read
Threats for this artifact only
Operational risks for the order-status function-calling assistant center on allowing a write tool (refund/cancel) in the same registry, plus the earlier failure mode (executing a hallucinated tool name, or answering status without a tool call). Safety lives in executable gates, allowlists, redaction, and a named owner—not in a warning paragraph under an unsafe function.
Read
Run the release gate
function authorize(ctx: Context, action: Action) {
if (!ctx.permissions.has(action.permission)) {
throw new SafeError("forbidden");
}
if (action.risk === "write" && !ctx.approvalToken) {
throw new SafeError("approval_required");
}
}
Expected evidence: A request for ord_123 produces one validated lookup and a reply based only on its result.. A failed assertion means stop, investigate, and do not publish the order-status tool caller.
Read
Owner, retention, rollback
Name who can disable the feature, what data is retained, and how to roll back to the last known good artifact. Pin the reviewed configuration (versions, thresholds, allowlists) so “what shipped” is reconstructable for function-calling-code.
Read
Lab notebook: release blocker
Write the release blocker as a predicate, not a feeling: “Do not ship the order-status tool caller if allowing a write tool (refund/cancel) in the same registry.” Pair it with a passing control that shows the reviewed configuration still works for orders map + tool schema for get_order_status. Name an owner and a rollback handle (git tag, docs_version, previous image).
Security pages must not paste the happy-path demo. If your gate code looks like the implementation page, replace it with a deny/allow check aimed at allowing a write tool (refund/cancel) in the same registry.
Read
Worked judgment
State the data retention rule in one line (what is stored, for how long, who can read it). Then state the kill switch (env flag, config pin, or feature owner). The order-status tool caller is not shippable without both, even when tool-call validity rate; grounded status answers vs fabricated ones looks healthy.
Read
Why this stage matters for the order-status tool caller
At the safety and operations stage for function-calling-code, the job is narrower than finishing a product demo. You are creating one progressive evidence piece about orders map + tool schema for get_order_status that later pages inherit without redefining success. Keep that fixture small enough to inspect by hand, keep outputs copy-pasteable as text, and refuse to narrate this baseline as if it were a production SLA: assistant that answers without tools on the same prompts.
For this page specifically, success looks like an executable deny gate for the lab-specific threat while still centering the user decision to let the model request a read-only get_order_status tool, then answer from the tool result. If you cannot point to a file, command, or assertion that proves that for the order-status tool caller, stay on this page instead of advancing.
Glossary: tool · Glossary: structured output · Cheatsheet: production ops signals
Go deeper
Before you start
Why this matters
Write an attack or unsafe misuse specific to this lab: allowing a write tool (refund/cancel) in the same registry. Predict whether your current code blocks it. Then run the gate below and compare.
In the wild
See how this idea shows up as a product and a company — then come back to the lesson. Skills transfer across vendors.
Related lessons
Check your understanding
Page assessment
Answer from memory. Completion is saved from this evidence, not from opening the next page.
All responses are required.