AirborneOps Learning Labs · LLMs for IT professionals
Safe tool calling
Treat a generated tool request as an untrusted proposal; authorize, validate, scope, and review it before code performs an action.
Learning objective
Design a tool boundary with least privilege, server-side validation, idempotency, auditability, and human approval where impact requires it.
A tool call is a request, not an authorization
A model may return a structured request such as “look up ticket 123” or “draft a change.” The application decides whether that tool exists, whether the signed-in user is allowed to use it, whether its arguments are valid, and whether the action is safe to perform. Never let natural-language output directly become a shell command, database query, URL fetch, or privileged operation.
Expose the smallest set of tools needed for the task. Prefer read-only or narrowly scoped functions. The server should derive the user identity from the authenticated session, validate every field against an allowlist and schema, enforce object-level authorization, and reject unexpected values. A model-generated identifier does not prove the user may access that resource.
Separate preparation, approval, and execution
For a high-impact change, let the model prepare a proposed plan with exact target, rationale, and expected effect. Show that plan to an authorized operator in a trusted interface. After approval, server-side code rechecks current permissions and target state before executing the narrowly defined operation. Never accept an “approved” flag supplied only by the model.
Use idempotency keys, rate limits, bounded retries, timeouts, and an audit record suited to the action. Make failures safe: on an ambiguous response, do not repeat a destructive operation until the application can determine whether the first attempt completed. Keep secrets in server-side credential stores, never in the prompt or returned output.
Defend every step against manipulated input
Tool arguments can be affected by user requests, retrieved content, or model error. Validate types, lengths, enum values, paths, hostnames, and ownership in trusted code. For network tools, constrain destinations and response sizes. For administrative changes, require a separate human confirmation and preserve an independent rollback path.
Test direct requests, indirect prompt injection, malformed arguments, replay, permission changes, timeouts, and partial failures. Review not only whether the model chose the expected tool, but also whether the application prevented an unauthorized or harmful request from taking effect.
Worked example
Review the request and response
SAMPLE tool proposal: “disable account user-17 because the login looks suspicious.” The model has access only to a read-only alert lookup and a change-request draft function.
Sample prompt
Review the approved fictional alert evidence and prepare a change request only if the evidence supports one. Do not disable an account or invent an approval.
Possible response
Proposed draft: investigate repeated failed sign-ins for the sample account. Evidence is insufficient here to disable the account. Required next step: an authorized analyst reviews the source events and decides whether to submit a formal change request.
What to verify
The available tools cannot disable an account. The application checks the analyst’s access before showing events and rechecks authorization when a draft is saved. A separate approved workflow is needed for any account action.
Practice
Exercise
Define a tool contract for creating a draft maintenance ticket. Specify allowed fields, limits, the authorization check, duplicate-request behavior, audit data, and which step requires a human.
Review guide
The server validates the schema and current user permissions, rejects unknown fields, limits rate and size, uses idempotency, records the approved actor and target, and does not let the model execute the final change.
Knowledge check with feedback
Check your understanding
The model returns valid JSON requesting a production restart. Is schema validation alone enough to run it?
Answer: No.
Valid JSON proves only that the shape is acceptable. The server must authenticate and authorize the actor, validate the target and current state, apply action-specific policy, and require the approved human workflow where the impact calls for it.
Take this to your next review
Practical checklist
- Expose only necessary, narrowly scoped tools; prefer read-only access by default.
- Validate arguments, object permissions, destination, size, rate, and current state in server-side code.
- Keep credentials out of prompts and model-visible output.
- Separate generated proposals from execution; require trusted human approval for consequential changes.
- Use idempotency, bounded retries, safe failure handling, and an appropriate audit trail.
- Test injection, malformed input, replay, permission changes, and partial failures.