huggingface / huggingface/smolagents
Need help avoiding agent calling tools with json
- Dominant language
- Python
- Stars
- 29.3k
- Forks
- 3k
- Avg merge
- 17m
- Merged PRs (30d)
- 2
Description
I've noticed that - particularly weaker models - often call tools using json (in addition to writing code).
e.g.:
```
Thought: Let me try to get the sections using more specific search terms and the bm25_retriever to see the actual content first.
Code:
```py
print("=== SEARCHING FOR FIRST THREE SECTIONS CONTENT ===")
sections = bm25_retriever(query="Need for the Proposed Development Economic Benefits Recreational Benefits Wind Farm introduction",
num_snippets=5)
print(sections)
```[{'id': 'call_5', 'type': 'function', 'function': {'name': 'python_interpreter', 'arguments': 'print("=== SEARCHING FOR FIRST THREE SECTIONS
CONTENT ===")\nsections = bm25_retriever(query="Need for the Proposed Development Economic Benefits Recreational Benefits Wind Farm
introduction", num_snippets=5)\nprint(sections)'}}]
```
Are there any tips on avoiding this?
Contributor guide
Research direction
The report provides no repository files or tests; begin with the shown python_interpreter and bm25_retriever tool-call example. Reproduce the JSON-formatted call and trace how tool calls are generated and parsed. Done should be a defined, tested way to prevent or handle this malformed format.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- ai
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100