Set tool annotations by decorating the tool function, not in `chat.register_tool()`
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- python
- Domain
- backend-api-design
Research direction
Start by reading the implementation of chat.register_tool() and the existing tool annotation handling, then review the related concerns in issue #169. The change is complete when annotations can be declared on the tool function with a decorator and register_tool() can use the decorated function without separately supplied annotations.
Written by the indexing model from the issue text.
Description
Tool annotations should be attached to the tool definition as closely as possible. It's currently awkward to create to a tool function that has annotations because those annotations need to be passed to chat.register_tool() at registration, which might be in a different place than where the tool is defined. (The tool could be in packaged code and the registration in user code.)
Instead of this
import faicons
from chatlas import ChatOpenAI
def get_weather_forecast(
lat: float, lon: float, location_name: str
) -> ContentToolResult:
"""Get the weather forecast for a location."""
# Mocked weather data for demonstration purposes
return {"temperature_2m": 18, "condition": "Partly Cloudy"}
# Create chat client and register tool
chat_client = ChatOpenAI(model="gpt-4.1-nano")
chat_client.register_tool(
get_weather_forecast,
annotations={ # << THIS COULD HAPPEN FAR FROM TOOL DEL
"title": "Weather Forecast",
"icon": faicons.icon_svg("cloud"),
},
)
Maybe this
import faicons
from chatlas import ChatOpenAI, add_tool_annotations
@add_tool_annotations(
title="Weather Forecast",
icon=faicons.icon_svg("cloud")
)
def get_weather_forecast(
lat: float, lon: float, location_name: str
) -> ContentToolResult:
"""Get the weather forecast for a location."""
# Mocked weather data for demonstration purposes
return {"temperature_2m": 18, "condition": "Partly Cloudy"}
# Create chat client and register tool
chat_client = ChatOpenAI(model="gpt-4.1-nano")
chat_client.register_tool(get_weather_forecast)
Advantages
This would also resolve some of the underlying issue in #169 where known standard MCP Tool Annotation properties could be named arguments that are documented, but additional kwargs are just added as tool annotations.
- Dominant language
- Python
- Stars
- 179
- Forks
- 32
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 10
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from posit-dev/chatlas
-
A streaming text delta that repeats everything streamed so far is missing from the recorded turnPossibly taken @cpsievert claimed this 81 days ago. Openai-triage:done Priority: Medium
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
ai-triage:needs-review documentation
Difficulty 2/5 1-2 days Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 1-2 days Newbie friendliness 35/100
Maintainers usually reply within 1 day
-
ai-triage:done Priority: Low
Difficulty 3/5 1-2 days Newbie friendliness 55/100
Maintainers usually reply within 1 day
All issues in posit-dev/chatlas
Similar issues
-
jira: an unquoted JQL number of more than 4300 digits is a plain-text 500, where real answers 200Openfidelity
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
A JSON chat answer blocks the backend event loop for the whole RAG runPossibly taken @NopeCharon claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
The-OpenROAD-Project/ORAssistant#656 ·
Maintainers usually reply within 1 day
-
bug(operator): VolterraOperator built inside jax.jit with a concrete decay raises TracerBoolConversionErrorPossibly taken @jejjohnson claimed this today. Opentype:bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
jejjohnson/integrix#144 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
finos/ai-governance-framework#459 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
autowarefoundation/autoware_carla_scenario#2963 ·
Maintainers usually reply within 1 day