Agent returning tool call and response together

Hi Agno team,

I’m seeing an issue where my agent returns a tool call and a answer together.

Agno version: 2.3.21
Model: grok-4-1-fast-non-reasoning

Example:

Question (user):
what is yesterday’s settlement for THE YOUNG CLINIC.

Agent response:

ai:function_call name="run_sql_query"> <parameter name="query">SELECT s.payment_date, s.transactions_amount, s.transactions_count FROM settlements s WHERE s.customer_id = 8879 ORDER BY s.payment_date DESC LIMIT 5</parameter> </xai:function_call>
For THE YOUNG CLINIC (customer_id 8879):** No settlement batch on Jan 5 (yesterday)—their most recent is today's £718.25 (per daily_reports for Jan 6 report). Looking back, no matching payment_date='2026-01-05' in settlements table. Worth noting they had flagged risk txns today but nothing yesterday.

I expects the agent to only return only the answer and not tool call. How can I fix this?

Agent setup (partial):

  self.sql_tools = ReadOnlySQLTools(
      db_url=env_config.agent_database_url,
      enable_list_tables=True,
      enable_describe_table=True,
      enable_run_sql_query=True,
)

self.agent = Agent(
      name=“DatabaseAnalyst”,
      description="",
      instructions"",
      model=xAI(id=“grok-4-1-fast-non-reasoning”, temperature=0.1),
      tools=\[self.sql_tools, self.notes_tools\],
      session_id=session_id,
      db=self.database,
      add_history_to_context=True,
      num_history_runs=5,
      read_chat_history=True,
      stream=True,
      markdown=True,
      add_datetime_to_context=True
      debug_mode=True
)

What I’ve tried

  • Set debug_mode=False → same behaviour
  • Changed tools → same issue
  • Downgraded Agno to 2.3.13 (this version never had the issue before, but now it still happens)
  • Issue is inconsistent: sometimes it happens, sometimes it doesn’t

I also tested with GPT-4o-mini (around 10 questions), and it worked correctly, no tool calls shown.

So I’m wondering, Is this related to the xAI? Or is there a setting to force answer-only output?

Thanks!

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

Thanks for the update.
Yes, this is urgent for us, so any help would be really appreciated.

Hey @ank
can you try the same with model=xAI(id=“grok-3”, temperature=0.1)

I tried replicating your issues but was not possible with grok-4-1-fast-non-reasoning, i tried a lot of other models as well. But was only able to reproduce with grok-2

The root cause from my finding being
Grok returns: content: “<tool XML + reasoning>”, tool_calls: […]
OpenAI returns: content: null, tool_calls: […]

Hi @uzaxirr

Thanks for the quick response.

I’ll try with grok-3. Just to note, the issue is not consistent, sometimes it happens, sometimes it doesn’t.

Since you’ve found the root cause, could you tell me, how can we fix it so the agent always returns only the answer (for xAI)?

Thanks again