Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add rules/altaidevorg/rules-for-ai/function_calling_utilitiesgit clone --depth 1 https://github.com/altaidevorg/rules-for-aiWhat it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00026 | $0.04432 |
| Opus 5 | $0.00013 | $0.02216 |
| Sonnet 5 | $0.00005 | $0.00886 |
| Haiku 4.5 | $0.00003 | $0.00443 |
Grade A, and why
function_calling_utilities scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 311 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Chapter 5: Function Calling Utilities
In Chapter 4: Chat / AsyncChat, we explored how to manage conversational history using the Chat object. However, many advanced AI applications require the model to interact with the external world—fetching real-time data, accessing databases, or calling other APIs. This chapter delves into the Function Calling Utilities, a set of features designed to seamlessly integrate external tools and functions with the generative model.
Motivation and Use Case
Generative models are powerful but inherently limited to the information they were trained on and the context provided in the prompt. Function calling allows the model to request the execution of predefined functions (tools) when it determines they are needed to fulfill a user's request. This bridges the gap between the model's knowledge and real-time or proprietary information.
Manually handling this process involves:
- Defining the function's interface (name, description, parameters, types) in a specific JSON schema format.
- Passing this schema to the model.
- Parsing the model's response to detect a function call request.
- Extracting the function name and arguments.
- Validating and potentially coercing arguments from JSON types to Python types.
- Executing the corresponding Python function.
- Formatting the function's return value into a specific JSON response format.
- Sending this response back to the model to continue the generation.
This cycle is complex and repetitive. The Function Calling Utilities in google-genai abstract away much of this complexity, especially through automatic schema generation and invocation handling.
Central Use Case: You want the model to answer questions about current weather conditions. Since the model's training data is not real-time, you need to provide it with a tool (a Python function) that can fetch live weather data.
# Assuming 'client' is configured
from google.genai import types
# Define the Python function the model can call
def get_current_weather(location: str) -> str:
"""Returns the current weather for a specified location.
Args:
location: The city and state, e.g., "Boston, MA".
"""
# In a real application, this would call a weather API
print(f"--- Tool: Called get_current_weather(location='{location}') ---")
if "boston" in location.lower():
return "The weather in Boston is sunny and 75°F."
else:
return f"Sorry, I don't have weather information for {location}."
# Pass the function directly as a tool
# The SDK automatically generates the schema and handles the call cycle
response = client.models.generate_content(
model='gemini-1.5-flash', # Use a model supporting function calling
contents="What's the weather like in Boston right now?",
config=types.GenerateContentConfig(
tools=[get_current_weather] # Pass the function object
)
)
# The response contains the final text after the function call
print(f"\nAI: {response.text}")
In this example, the SDK inspects get_current_weather, creates the necessary FunctionDeclaration schema, sends it to the model, detects the FunctionCall in the model's intermediate response, executes get_current_weather with the arguments provided by the model, sends the result back as a FunctionResponse, and returns the final, user-facing text generated by the model based on the weather information.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- yesterday First seen · 311 lines · 26 tokens per session scan A 03e37eb48c55
function_calling_utilities is a cursor rule published in the GitHub repository altaidevorg/rules-for-ai (2 stars, last pushed 1y ago), licensed MIT. It adds 26 tokens to every session and 4,432 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other cursor rules, from other repositories
angular-20
This rule provides comprehensive best practices and coding standards for Angular development, focusing on modern TypeScript, standalone components, signals, and performance optimizations.
dev-standard
Apache Superset development standards and guidelines for Cursor IDE.
typescript
Changes to these high-fan-out internals can affect every message, delta, element, or rerun. Keep work in them minimal, and benchmark changes with representative stress-test apps.
coolify-ai-docs
Master reference to all Coolify AI documentation in .ai/ directory.
python_lib
Tips and guidelines specific to the development of the Streamlit Python library, not applicable to scripts and e2e tests.
specs
This directory contains product and tech specs for Streamlit features.