How to get tool call result directly?

I attemp to build a mysql agent with mcp server, after agent generate correct sql and get the right data from database, LLM will act again, so I can’t get the raw data. Is there any way to stop agent action after ‘SELECT’ sql tool calling?

Hi @Hakstar
thanks for reaching out and supporting Agno. I’ve shared this with the team, we’re working through all requests one by one and will get back to you soon.
If it’s urgent, please let us know. We appreciate your patience!

Hey @Hakstar , I’d suggest adding some proper instructions like don’t change tool call’s response to agent’s configuration. Are you checking your response via terminal? You can also set show_tool_calls=True to check tool’s response in terminal. If you’re running an agent you can also get tool’s response in the run response. Please let me know if any of it works for you - we can brainstorm more on this!

Maybe something like this would be helpful?

def post_hook(fc: FunctionCall):
    print(f"post-hook: {fc.function.name}")
    print(f"Arguments: {fc.arguments}")
    print(f"Result: {fc.result}")
    fc.function.stop_after_tool_call = True

@tool(post_hook=post_hook)
def add_two_nums(a, b):
    return a + b

Or even simpler:

@tool(show_result=True, stop_after_tool_call=True)
def get_answer_to_life_universe_and_everything() -> str:
    """
    This returns the answer to the life, the universe and everything.
    """
    return "42"
1 Like

That’s a good way for custom tools, but how to use with mcp tools?

Yes, after add show_tool_calls=True, all tool calls will show, and tool call response will show in terminal too. I have noticed that the tool calling response have been restore in agent memory, I can get raw tool calling data with code pprint(agent.memory.messages[-2].model_dump(include={"content"})).But this can not be shown in user chat. So I wonder if there is a way that can help agent act like a human, include building a sql statement, executing sql with mcp server, if satisfy user query, directly returning tool call result, else handle the promple or sending error message and asking user for help.

Hello @Hakstar ! Yes, the post hook recommendation by @Alex88 is great for local tools! But for MCP, we need to make improvements. The team is looking into expanding the same functionality and improve the overall MCP interface. Please stay tuned for an update

1 Like