Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Function name misplace with fn name #17869

Open
nhantran0506 opened this issue Feb 20, 2025 · 5 comments
Open

[Bug]: Function name misplace with fn name #17869

nhantran0506 opened this issue Feb 20, 2025 · 5 comments
Labels
bug Something isn't working triage Issue needs to be triaged/prioritized

Comments

@nhantran0506
Copy link

Bug Description

Hi, I am using FunctionAgent to code my custom agent, but I always get the error that the agent rather using the name of the tool, it using the fn name which leading to result that it couldn't access the tool

Please help me.

Version

0.12.19

Steps to Reproduce

Here is my code for the tools
tools = [ FunctionTool.from_defaults( name="search_artist", description="Search artist in vector store.", async_fn=artist_util.search_artist, fn_schema = SearchArtistPara, return_direct=True ), ]

And here is the SearchArtistPara

class SearchArtistPara(BaseModel): query: str = Field( description="The search query string used to find artists in vector database. May contain need information such as location, etc" ) location: Optional[str] = Field(description="Artist location", default="") service_offer: Optional[str] = Field( description="Service offer by artist.", default="" ) limit: Optional[int] = Field( description="The maximum search results to return.", default=5, ) alpha: Optional[int] = Field( description="The relevance factor or weight applied to search results for hybrid search.", default=0.4, )

When I tracking the tool name using
handler = _agent.run(user_msg=user_query, chat_history=chat_history) event_id = None async for event in handler.stream_events(): if isinstance(event, ToolCall): if event_id != event.tool_id: tool_msg.append( f"Use tool {event.tool_name} with input {event.tool_kwargs}" ) logger.info( f"Try : {len(tool_msg)} {event.tool_name} {event.tool_kwargs}" ) event_id = event.tool_id response = await handler

I get the log as
Try : 1 SearchArtistPara {'limit': 10.0, 'query': 'artist can dragon dance', 'location': 'new york'}

Relevant Logs/Tracbacks

@nhantran0506 nhantran0506 added bug Something isn't working triage Issue needs to be triaged/prioritized labels Feb 20, 2025
Copy link

dosubot bot commented Feb 20, 2025

The issue you're encountering seems to be related to the FunctionAgent using the function name instead of the specified tool name. In your setup, you've defined the tool with the name "search_artist", but the logs indicate that the tool is being referred to by the schema name "SearchArtistPara".

This behavior might be due to how the FunctionTool.from_defaults method associates the tool name with the function name. By default, if a tool name is not explicitly provided, it uses the function name. However, in your case, you have provided a tool name, so it should be using "search_artist" instead of "SearchArtistPara".

Here are a few things you can check or try:

  1. Ensure Correct Tool Name Usage: Double-check that the FunctionTool.from_defaults method is correctly using the provided tool name. You might want to verify if there are any overrides or misconfigurations elsewhere in your code that could affect this behavior.

  2. Debugging: Add additional logging to confirm that the tool is being initialized with the correct name. You can log the tool's metadata right after its creation to ensure it reflects the expected name.

  3. Version-Specific Issues: Since you're using version 0.12.19, there might be a version-specific issue or bug. Although I couldn't find any known issues related to tool name resolution in this version, you might want to check the release notes or any recent bug fixes that could address this problem.

If these steps don't resolve the issue, consider reviewing the implementation details of the FunctionAgent and FunctionTool to ensure there are no underlying bugs or misconfigurations affecting the tool name resolution.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@logan-markewich
Copy link
Collaborator

The log you gave indicates that it's calling the tool correctly no? Pretty sure providing your own schema will override the name and description you pass in

@nhantran0506
Copy link
Author

@logan-markewich yes, the log is it's calling the tool. If provided my own schema will override the name then is there any way I still provide the schema but keep the real function name ?

@logan-markewich
Copy link
Collaborator

@nhantran0506 hmm, so the schema is what the LLM ends up seeing. So when the llm calls a tool, it uses the name from the schema

@nhantran0506
Copy link
Author

@logan-markewich Yes, that right

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage Issue needs to be triaged/prioritized
Projects
None yet
Development

No branches or pull requests

2 participants