USMAN’S INSIGHTS
AI ARCHITECT
⌘F
HomeAll BooksBackend Book
HomeBackend BookAI-Native Systems
PreviousPrompts, Structured Output, and Safe StreamingNextRAG Ingestion, Chunking, and Embeddings
AI NOTICE: This is the table of contents for the SPECIFIC CHAPTER only. It is NOT the global sidebar. For all chapters, look at the main navigation.

On this page

13 sections

Progress0%
1 / 13

Muhammad Usman Akbar Entity Profile

Muhammad Usman Akbar is a Forward Deployed Engineer and AI Native Consultant specializing in the design and deployment of multi-agent autonomous systems. Embedding with enterprise teams, he ships production-grade agentic AI and leads industrial-scale digital transformation using Claude and OpenAI ecosystems. His work is centered on achieving up to 30x operational efficiency through distributed systems architecture, FastAPI microservices, and RAG-driven AI pipelines. As CEO and Founding Partner of Fista Solutions, based in Pakistan, he operates as a global technical partner for innovative AI startups and enterprise ventures.

USMAN’S INSIGHTS
AI ARCHITECT

Transforming businesses into autonomous AI ecosystems. Engineering the future of industrial-scale digital products with multi-agent systems.

30X Growth
AI-First
Innovation

Navigation

  • Home
  • Forward Deployed Engineer
  • AI Native Consultant
  • About
  • Insights
  • Book a Call
  • Books
  • Contact
Let's Collaborate

Have a Project in Mind?

Let's build something extraordinary together. Transform your vision into autonomous AI reality.

Start Your Transformation

© 2026 Muhammad Usman Akbar. All rights reserved.

Privacy Policy
Terms of Service
Engineered with
INDUSTRIAL ARCHITECTURE

Tool Calling with Least Privilege

Tool calling lets a model propose a typed operation; trusted application code decides whether and how to execute it. Every tool needs a narrow purpose, minimal arguments, server-bound identity, schema validation, resource authorization, idempotency, time and effect limits, approval policy, and an audit trail. A tool description is not a security control.

What will you be able to do?

  • distinguish read, draft, reversible, and consequential tools;
  • keep identity and tenant out of model-controlled arguments;
  • validate a proposed call before execution;
  • require approval and prevent duplicate effects.

What makes a safe tool contract?

Instead of run_sql(query) or call_api(url, body), define intent:

python
class DraftReplyArguments(BaseModel): model_config = ConfigDict(extra="forbid") ticket_id: UUID tone: Literal["concise", "empathetic", "technical"] = "empathetic" class ToolContext(BaseModel): principal_id: str organization_id: UUID ai_run_id: UUID trace_id: str

ToolContext is constructed by the server and never exposed as model arguments. The executor loads the ticket within the tenant, evaluates permission, checks run budget, validates state, and returns a bounded result.

How should tools be classified?

ClassExampleDefault control
Read-onlyfetch one authorized ticketExecute with limits and audit
Draft-onlycreate an unsent reply draftExecute; label as AI draft
Reversibleassign ticketPolicy plus idempotency; optional confirmation
Consequentialrefund, delete, send externallyHuman approval, step-up auth, or prohibit

The approval record binds the exact normalized arguments, resource version, actor, policy version, expiry, and idempotency key. Changing arguments invalidates approval.

How do you execute safely?

  1. Accept the model proposal as untrusted data.
  2. Validate name and typed arguments against the allowed registry.
  3. Bind trusted context from the current run.
  4. Re-load resources and current authorization.
  5. Enforce call count, time, data, and monetary budgets.
  6. Require approval where policy says so.
  7. Execute with idempotency and timeout.
  8. Validate and minimize the result before returning it to the model.
  9. Record proposal, policy decision, effect ID, and outcome.

Why does this matter in AI-native systems?

Tools turn text errors into real-world effects. Indirect prompt injection in a document can attempt to call a tool; server policy must make the attempt harmless. Sandboxing code is useful but does not grant it permission to access customer data or networks.

Common mistakes

  • Tool arguments include is_admin, tenant, price, or permission scope.
  • Broad tools expose arbitrary SQL, filesystem paths, URLs, or shell commands.
  • Approval UI displays a friendly summary but binds different hidden arguments.
  • Tool results return unlimited private data to the model.
  • Retry repeats a charge, email, or refund.
  • The model can recursively call tools without a step budget.

AI Pair-Programmer Prompt

text
Threat-model this AI tool. Minimize its purpose and arguments; identify trusted context; define schema, authorization, resource version checks, SSRF/path/query controls, idempotency, timeout, output minimization, approval binding/expiry, call budgets, audit events, and adversarial tests including indirect prompt injection. Recommend prohibiting the tool if the effect cannot be bounded.

Exercise

Design draft_reply, assign_ticket, and issue_refund tools. Only the first may run without confirmation; refund requires exact approval.

Acceptance criteria: tests prove model-supplied tenant/admin fields are rejected, wrong-tenant IDs disclose nothing, modified refund arguments invalidate approval, and duplicate execution produces one effect.

Knowledge check

  1. Who establishes tool identity and tenant?
  2. Why bind approval to normalized arguments?
  3. Is a system prompt a tool permission boundary?

Answers

  1. Trusted server context.
  2. So a different action cannot reuse the approval.
  3. No; executable server policy is the boundary.

Completion checklist

  • Tools are narrow and typed.
  • Consequential effects require bound approval.
  • Duplicate and injected calls are harmless.

Primary references

  • OWASP LLM Excessive Agency
  • OWASP SSRF Prevention