Safe tool request
{
"tool": "get_service_status",
"arguments": {"service": "nginx"}
}
request → schema validation → policy → tool → structured result- The application mediates execution.
- Unknown tools and disallowed service names are rejected.
A model can talk about a server, but it cannot inspect that server unless the application gives it a capability. A tool is that capability—and it should be narrow, validated and controlled.
Engineering focus: Tool contracts, validation and least privilege
A model can talk about a server, but it cannot inspect that server unless the application gives it a capability. A tool is that capability—and it should be narrow, validated and controlled.
Framework names come later. First understand what the application is doing and where its control boundaries belong.
Across the course, imagine an assistant that investigates operational problems using narrow tools. The design progressively adds plans, specialist agents, approvals, reliability controls and MCP while keeping model output separate from execution authority.
A useful tool definition includes a name, purpose, input schema, validation rules, side-effect classification and structured result. Production tools also need authorization, timeout and audit behaviour.
A tool such as get_disk_usage() exposes one understandable capability. A generic run_any_shell_command(command) exposes an enormous attack and failure surface. Least privilege applies to agents too.
The model may request get_service_status("nginx"), but application code decides whether the tool exists, whether the argument is valid and whether the caller is allowed to use it. A system prompt is not an authorization system.
Returning fields such as service, status and evidence is easier to validate and trace than returning an unstructured blob. Structured contracts also make evaluation easier.
{
"tool": "get_service_status",
"arguments": {"service": "nginx"}
}
request → schema validation → policy → tool → structured resultdef run_any_shell_command(command):
os.system(command)Goal: Execute allowed tools and observe validation rejecting an unsupported request.
python3 public/labs/agentic-ai/03_safe_tools.pyNotice that only named tools can execute.
The unsupported service must raise a validation error instead of being passed through.
Safe agent platforms expose purpose-built tools with least privilege, schema validation, authorization and observable results rather than unrestricted command execution.
Open every answer only after committing to your own answer. Opening all four answers records knowledge-check activity in My Learning.
get_disk_usage() — A narrow read-only capability minimizes unintended side effects.
Validate the argument against the tool contract/policy — Tool inputs must be validated before execution.
No — Instructions influence behavior; authorization constrains capability.
To make validation and downstream interpretation more reliable — Structured results are easier to validate, inspect and reason over.
Progress is saved in this browser immediately. When you sign in to My Learning, it can also sync across devices.
Attempt the core lab and knowledge checks before marking the module complete.