Session 11 Slides: Tool Calling & Actions

--:-- --
↓ Scroll for more

Session 11

Tool Calling & Actions

AI Product Engineering

Block 3: Agents, Evaluation & Deployment

Giving AI Hands

A language model only produces text. Tool calling lets it request execution of real functions — and use the results.

The model decides to call the tool. Your code executes it.

The Function Calling Protocol

User: "What is 15% of £2,340?"
Model → emits: calculate("0.15 * 2340")
Your code → executes → returns "351"
Model → "15% of £2,340 is £351"

Defining a Tool Schema

name: 'calculate'
description: 'Evaluate a mathematical expression.'
parameters:
  expression:
    type: string
    description: 'Expression to evaluate, e.g. "2 + 2" or "sqrt(16)"'
    required: true

The model reads the description to decide when to use this tool. Write it clearly.

⚠️ Security Warning

  • Never expose unrestricted eval() to AI-driven tool calls
  • Restrict tool scope: math only, read-only file access, no system commands
  • Log all tool calls and their arguments
  • Validate and sanitise all tool inputs before execution

Tool + RAG Together

Your RAG retrieval function from Session 9 becomes a tool the agent can call.

User asks a question → agent decides to search knowledge base → retrieves relevant chunks → generates grounded answer.

Sessions 9 + 11 = a complete agentic knowledge assistant.

Session 11 Summary

  • Tool calling: model requests → your code executes
  • Tool descriptions decide when tools are used — write them clearly
  • Security: restrict scope, validate inputs, log calls
  • RAG + tools = complete agentic application

Next Session: Multimodal AI & Data Pipelines