agentscope-ai / agentscope-ai/agentscope

[Bug]:tool use not success in ReActAgent

Ouverte
#1,282 2 commentaires 0 réactions 1 personne assignée Réclamée par @qbc2016 Voir sur GitHub
Langage dominant
Python
Étoiles
31.5k
Forks
3.5k
Merge moyen
1 j 23 h
PR mergées (30 j)
95

Description

**Describe the bug**
I follow the official docs [here](https://doc.agentscope.io/tutorial/quickstart_agent.html)
but it failed to `fomat msg` and `use tool` as expected when the mentioned code run

**To Reproduce**
Steps to reproduce the behavior:

1. You code
I put the code into test.py, the only difference is I change the model and formatter into opai style as follow:
```python
from agentscope.agent import ReActAgent
from agentscope.formatter import OpenAIChatFormatter, OpenAIMultiAgentFormatter
from agentscope.memory import InMemoryMemory
from agentscope.message import Msg
from agentscope.model import OpenAIChatModel
import asyncio
from agentscope.tool import Toolkit, execute_python_code

async def creating_react_agent() -> None:
"""Create a ReAct agent and run a simple task."""
# Prepare tools
toolkit = Toolkit()
toolkit.register_tool_function(execute_python_code)
jarvis = ReActAgent(
name="Jarvis",
sys_prompt="You're a helpful assistant named Jarvis",
model=OpenAIChatModel(
model_name="Qwen3-14B",
api_key="xxx",
client_kwargs={"base_url": "https://antchat.alipay.com/v1"}
),
formatter=OpenAIChatFormatter(),
toolkit=toolkit,
memory=InMemoryMemory(),
)

msg = Msg(
name="user",
content="Hi! Jarvis, run Hello World in Python.",
role="user",
)

await jarvis(msg)

asyncio.run(creating_react_agent())

```
2. How to execute

```shell
python test.py
```

3. See error**Expected behavior**

A clear and concise description of what you expected to happen.

**Error messages**
```groovy
Jarvis:
Okay, the user asked me to run "Hello World" in Python. Let me think about how to approach this.

First, I need to make sure I understand the request. They want a Python script that prints "Hello World". That's straightforward. The basic syntax in Python is using the print() function. So the code would be print("Hello World").

Wait, but maybe they want to see the output as well. Since I can't execute code here, I should explain the steps they need to take. I should provide the code and then guide them on how to run it. Let me check if there are any common issues they might face. For example, making sure Python is installed, the correct file extension (.py), and using the right command in the terminal.

I should also mention that if they're using an online compiler or an IDE like IDLE, the process might be slightly different. But the core code remains the same. Let me structure the response clearly: first provide the code, then the steps to run it, and maybe add a note about checking for errors. That should cover their needs.

Sure! Here's how you can run "Hello World" in Python:

Python Code:
python
print("Hello World")

### Steps to Run:
1. **Save the code**: Open a text editor (like Notepad, VS Code, or any IDE), type the code above, and save it as `hello.py`.
2. **Run the script**:
- Open your terminal or command prompt.
- Navigate to the directory where `hello.py` is saved.
- Type `python hello.py` and press Enter.

You'll see the output:

Hello World

Let me know if you need further assistance! 😊

```

as shown above, there is no tool use and reserved special token \

**Environment (please complete the following information):**
```groovy
agentscope 1.0.16
python 3.10.15
```

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.