huggingface / huggingface/smolagents

`Tool.to_code_prompt()` method does not extract `Returns: ...` from the function docstring

Open Beginner friendly
#2,437 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
29.3k
Forks
3k
Avg merge
17m
Merged PRs (30d)
2

Description

Example:

```python
@tool
def get_temperature(city: str) -> float:
"""
get the temperature of any city in the world

Args:
city: the city name

Returns:
float: temperature in Celsius
```
return 19.2

print(get_temperature.to_code_prompt()) # this call does not print 'Returns:\n float: temperature in Celsius'
```

Contributor guide

Open the contributing guide

Research direction

Start at the Tool.to_code_prompt() entry point and reproduce the get_temperature example from the issue. Trace how the function docstring's Args section is extracted, then verify that the Returns section is included with its float description. Done means the printed prompt contains “Returns:\n float: temperature in Celsius”.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.