Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 33

Tool-Use Conceptual Model Design

Recommended resources

Hello! Welcome to the next lesson in our module, "Architecting Agentic Systems."

In our last lesson, we looked at the high-level structure of a capability manifest, comparing it to an agent's "job description." We identified its three main parts: Identity (who the agent is), Functions (what it can do), and Constraints (its rules of engagement).

Today, we're zooming in on the most dynamic of these components: the Functions. Your goal for this lesson is to learn how to design a conceptual model for an agent's tool-use function by defining its name, purpose, parameters, and return values.

From your perspective as a UI/UX designer, this is analogous to defining the properties and interactions of a reusable component in Figma. You're not building the final, coded component, but you are creating the precise specification that determines what it's called, what it does, what information it needs (its properties), and how it responds (its state changes). This specification is the contract that allows an AI agent to use a tool effectively.

The Anatomy of a Tool-Use Function

At its core, a "tool-use function" is a capability that you grant to an AI agent, allowing it to interact with the world beyond its internal knowledge. To make a function usable by a Large Language Model (LLM), we must describe it in a structured way.

This structure, or conceptual model, consists of four key parts.

The Role of Tool Definitions

To start, let's get a crisp definition of the core components from the 'Function Calling in AI Agents' guide on PromptingGuide.ai.

Read the short section titled 'The Role of Tool Definitions'. It clearly lists the essential parts of a tool definition. We will add one more component, 'return values', to complete our model.

As the resource outlines, a function definition includes a name, a description, and parameters. We will add return values to complete our conceptual model:

  1. Name: A unique, machine-readable identifier (e.g., get_user_preferences).
  2. Purpose (Description): A clear, natural language explanation of what the function does and, crucially, when the LLM should use it.
  3. Parameters: The inputs the function requires to do its job, including their data types and whether they are required.
  4. Return Values: The structured output the function sends back to the agent after execution.

This diagram shows how a chatbot agent might use several functions, each with its own purpose, parameters, and return values, to serve a user.

Chatbot Application with Function Calling
A chatbot agent for an e-commerce platform uses distinct functions like `get_items` (which might take a `category` parameter) and `purchase_item` (which might take `item_id` and `quantity` as parameters) to interact with external databases and fulfill user requests.

Designing the Function's "Contract"

Let's break down how to design each part of this contract. We'll use a practical example: designing a function to get the weather.

1. Name and Purpose (Description)

The function's name should be concise and programmatic. The description, however, is written for the LLM. It is the single most important piece of information the model uses to decide which tool to use and why. A vague description leads to errors.

The Google AI documentation provides excellent guidance on how to structure this using standard programming conventions like docstrings.

Function tools - Google

Let's read Google's documentation on 'Function tools' to see how a function's signature and its documentation (docstring) directly create the name and description for the agent.

Please read two sections from this page: Start with 'How it Works' to understand how the framework automatically generates a schema from a function's signature. Then, read the section on 'Docstrings' to see why this description is so critical for the LLM. Focus on the principle that what a developer writes as documentation becomes the agent's guide for using the tool.

As you read, the key insight is that the function's description isn't just for human developers; it is a direct instruction to the AI.

2. Parameters (Inputs)

Parameters are the data fields the function needs to execute. For each parameter, you must define:

  • Name: e.g., location.
  • Type: e.g., string, integer, boolean.
  • Description: A clear explanation for the LLM, e.g., "The city and state, such as 'San Francisco, CA'".
  • Required/Optional: Is this parameter mandatory for the function to run?

This next video gives a concrete walkthrough of how these parameter definitions look in the JSON format that is actually sent to the OpenAI API.

OpenAI Function Calling - Full Beginner Tutorial

The 'OpenAI Function Calling - Full Beginner Tutorial' video by Dave Ebbelaar provides a clear, step-by-step breakdown of a function description in JSON.

Watch the clip from 07:37 to 09:14. Pay close attention to the parameters object. Notice how it defines properties like location_origin, each with a type and a description. This structure is the direct implementation of our conceptual parameter design.

A crucial design decision is whether to make a parameter required or optional. The "Function tools - Google" page you reviewed earlier has a great section on this. An optional parameter usually has a default value (e.g., a search radius defaulting to 10 miles).

3. Return Values (Outputs)

The return value is the data the function passes back to the agent. This isn't for the end-user directly; it's for the LLM to process and use in its final response. Therefore, the return value should be structured and descriptive.

Function tools - Google

Let's return to the Google 'Function tools' documentation for best practices on return values.

Please read the section titled 'Return Type'. Note the recommendation to return a structured dictionary (or object) and to include a 'status' key (e.g., 'success', 'error'). This is a key principle of robust system design.

For example, a weather function shouldn't just return "25". It should return a structured object like:

{
  "status": "success",
  "location": "Paris, FR",
  "temperature": 25,
  "unit": "celsius",
  "condition": "Sunny"
}

If something goes wrong, it could return:

{
  "status": "error",
  "error_message": "Location not found."
}

This structured response gives the agent everything it needs to formulate a helpful reply.


Your Turn: Design a Function Model

Now, let's apply these concepts. Your task is to design a conceptual model for a function that would be useful in a product you're familiar with from your UI/UX work—managing user settings.

Scenario: An AI assistant helps users manage their profile on an e-commerce app. You need to design the update_user_profile function.

Instructions: Based on the four components we've discussed, create a conceptual model for this function. Think about what information is absolutely necessary and what is optional.

Fill out the following structure:

  • Name: update_user_profile
  • Purpose (Description): (Write a clear description for the LLM. What does this do and when should it be used?)
  • Parameters:
    • Parameter 1:
      • Name: user_id
      • Type: string
      • Description: The unique identifier for the user whose profile is being updated.
      • Required: Yes
    • Parameter 2:
      • Name: (e.g., email)
      • Type: (e.g., string)
      • Description: (Explain this parameter)
      • Required: (Yes or No?)
    • Add at least two more optional parameters relevant to a user profile (e.g., preferred_theme, newsletter_subscription).
  • Return Values:
    • Describe the structure of a successful return object.
    • Describe the structure of an error return object.

Take about 10-15 minutes to complete this. There's no single right answer; this exercise is about applying the design principles of clarity, structure, and intent.

Click to see an example solution
  • Name: update_user_profile
  • Purpose (Description): Updates a user's profile information in the system. Use this when a user wants to change their email address, display name, notification preferences, or visual theme.
  • Parameters:
    • Parameter 1:
      • Name: user_id
      • Type: string
      • Description: The unique identifier for the user whose profile is being updated.
      • Required: Yes
    • Parameter 2:
      • Name: email
      • Type: string
      • Description: The user's new email address.
      • Required: No
    • Parameter 3:
      • Name: display_name
      • Type: string
      • Description: The user's new public display name.
      • Required: No
    • Parameter 4:
      • Name: preferred_theme
      • Type: string
      • Description: The desired UI theme. Must be one of 'light', 'dark', or 'system'.
      • Required: No
  • Return Values:
    • On Success: A JSON object confirming the update. Example:
      {
        "status": "success",
        "user_id": "u-12345",
        "updated_fields": ["email", "preferred_theme"]
      }
      
    • On Error: A JSON object explaining the failure. Example:
      {
        "status": "error",
        "user_id": "u-12345",
        "error_code": "INVALID_EMAIL",
        "error_message": "The provided email address is not valid."
      }
      

How the Agent Uses Your Model

You've designed the "contract." The final step is to see how the agent uses it. The LLM's magic is its ability to translate unstructured natural language into the structured JSON that matches your function's model.

OpenAI Function Calling - Full Beginner Tutorial

Let's watch the 'OpenAI Function Calling' video again to see this translation in action. This shows how your design connects to the agent's reasoning process.

Watch the clip from 09:23 to 13:57. The video shows two key steps: The LLM's Output: The model receives a user's question and outputs a JSON object with the function name and the arguments it extracted. Calling the Function: The application code then parses this JSON and uses it to call the actual Python function. This demonstrates the end-to-end flow from user query to tool execution, all guided by the function model you designed.


Conclusion

Today, you've moved from understanding what a function is to designing one yourself. This is a fundamental skill for any system architect working with AI. By defining a clear and robust contract for each tool, you enable agents to perform complex, real-world tasks reliably.

Key Takeaways:

  • A conceptual model for a tool-use function has four parts: Name, Purpose (Description), Parameters, and Return Values.
  • The Description is a critical instruction for the LLM, guiding its decision-making.
  • Parameters form a contract defining the required and optional inputs for the function.
  • Return Values should be structured (e.g., JSON objects) and informative, providing the agent with clear feedback on the outcome of the tool's execution.

Next Lesson Preview

Now that you can design an individual tool, we need to think about how an agent manages its toolkit and handles situations where the tools aren't enough. In the next lesson, we will address the learning outcome: Diagram a human-agent-human escalation path with defined triggers for handoff. This will explore the critical design patterns for collaboration between AI agents and human experts.