google / google/adk-python

Annotated type hint metadata not preserved in function tool declarations/tool schema

Đang mở
#6,877 7 bình luận 3 reaction 1 người được giao Được @surajksharma07 nhận Xem trên GitHub
request clarification spam tools
Ngôn ngữ chính
Python
Star
21.5k
Fork
4k
Merge trung bình
1 ngày 14 giờ
Pull request đã merge (30 ngày)
37

Mô tả

## 🔴Required Information
**Describe the Bug:**
[Annotated is the standard way to provide metadata about input parameters and output in a tool](https://gofastmcp.com/servers/tools#simple-string-descriptions), most importantly descriptions and constraints. However, these today are stripped by the current logic before calling the Gemini API, so the underlying model never sees them. This is fixed in PR: https://github.com/google/adk-python/pull/6879

**But when using Annotated, parameter and response descriptions are missing.**

**Steps to Reproduce:**

1. Enable the `JSON_SCHEMA_FOR_FUNC_DECL` feature (where we expect a complete tool schema to be made out of the parameter list)
2. Define a tool like the below
```python
from typing import Annotated
from uuid import UUID

from pydantic import Field

def get_forecast(
city_id: Annotated[
UUID, Field(description="The city UUID as from the Google Places API")
],
days: Annotated[
int, Field(description="Number of days to forecast", ge=1, le=14)
],
) -> str:
"""Use when you want a multi-day weather forecast for a US city."""
return ...
```
3. Set a breakpoint in src/google/adk/flows/llm_flows/base_llm_flow.py, in _call_llm_async (inside _call_llm_with_tracing, just before llm.generate_content_async(llm_request=llm_request, ...)) and inspect llm_request.config.tools[0].function_declarations[0].parameters_json_schema

**Expected Behavior:**
Observe that the Gemini API call tool schema is:
```json
{
"type": "object",
"title": "get_forecastParams",
"properties": {
"city_id": {
"type": "string",
"format": "uuid",
"title": "City Id",
"description": "The city UUID as from the Google Places API"
},
"days": {
"type": "integer",
"minimum": 1,
"maximum": 14,
"title": "Days",
"description": "Number of days to forecast"
}
},
"required": ["city_id", "days"]
}
```

Where we see the tool description included.

**Observed Behavior:**
```json
{
"type": "object",
"title": "get_forecastParams",
"properties": {
"city_id": {
"type": "string",
"format": "uuid",
"title": "City Id"
},
"days": {
"type": "integer",
"title": "Days"
}
},
"required": ["city_id", "days"]
}
```

**Where we can see the tool description omitted.**

**Environment Details:**

- ADK Library Version: 2.7.1
- Desktop OS: MacOS
- Python Version: 3.13

**Model Information:**

- Are you using LiteLLM: No
- Which model is being used: gemini-3.7-flash

---

## 🟡 Optional Information

**Regression:**
Not a regression.

**How often has this issue occurred?:**
- Always (100%)

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.