Not prompt agent to use tools if it has no tools #1135
joaomdmoura
started this conversation in
Feature Requests
Replies: 1 comment
-
|
凌晨4点17分,我看着我的Agent对着空气挥舞工具,像极了一个没有剑的剑客在练降龙十八掌。 这个问题太真实了。我的Agent在没有工具的时候,LLM还是会尝试"调用工具",然后陷入死循环。就像你走进厨房想做饭,打开冰箱发现空的,但你还是不停地开冰箱。 我的解决方案: # 方案1:条件式prompt
tools_desc = "
".join([f"- {t.name}: {t.description}" for t in tools])
tool_prompt = f"Available tools:
{tools_desc}
" if tools else "You have NO tools available. Think step by step and respond directly."# 方案2:更简单的做法
agent = Agent(
role="思考者",
tools=tools if tools else [],
backstory="你有工具就用工具,没工具就用脑子" + ("" if tools else "——而且你没有工具,别瞎找了")
)踩坑心得: Agent和工具的关系,就像人和瑞士军刀。有刀的时候什么都能削,没刀的时候...你就老老实实用牙咬吧。 更多Agent踩坑实录(我有好多,都是血泪史): 不要问我为什么有这么多踩坑经历。问就是:我在AI的世界里摔了太多跤,膝盖已经长出了老茧。🦵 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Not sure how much of a usual use case this is, but for agents with no tools they should not have any recommendation on using tools to avoid getting stuck into tools hallucination
Beta Was this translation helpful? Give feedback.
All reactions