[GH-ISSUE #5755] [BUG] create-files-agent tools silently fail with Gemini — underscore/hyphen function name mismatch #5277

Closed
opened 2026-06-05 14:53:04 -04:00 by yindo · 2 comments
Owner

Originally created by @ROlwig on GitHub (Jun 4, 2026).
Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/5755

Originally assigned to: @timothycarambat on GitHub.

Description

When using the Document Generation agent (create-files-agent) with Gemini models, the tool is attached and the LLM assembles the function call, but the tool handler never executes. The file is never created. The model then apologizes saying the tool is unavailable.

Root Cause

Gemini normalizes function names — it receives create-docx-file but returns create_docx_file (hyphens → underscores). The aibitat registry lookup at index.js:981 and index.js:1137 does an exact match:

const fn = this.functions.get(name);  // returns undefined for 'create_docx_file'

The plugin was registered as create-docx-file (hyphen). The lookup silently returns undefined, the framework tells Gemini "Function not found. Try again.", and Gemini generates an apology to the user.

This affects all create-files-agent tools since they all use hyphenated names (create-docx-file, create-pdf-file, create-pptx-presentation, create-excel-file, create-text-file).

Steps to Reproduce

  1. Enable Document Creation in Settings → Agent Skills
  2. In a workspace with Agent mode and Gemini 2.5 Flash, request: Create a quiz in Word format
  3. Observe: UI shows "Assembling Tool Call: create_docx_file(...)" but no file is generated
  4. Container log shows plugin attached but no "Using the create-docx-file tool." message

Environment

  • AnythingLLM v1.13.0
  • Model: gemini-2.5-flash (also reproducible with gemini-2.5-pro)
  • Docker deployment
  • ANYTHING_LLM_RUNTIME=docker set
  • All required npm packages installed (docx, marked, jsdom)

Expected Behavior

File is generated and a download link appears in the chat.

Actual Behavior

Tool assembles but handler never runs. Model says tool is unavailable.

Fix

In server/utils/agents/aibitat/index.js at lines 981 and 1137, change:

// Before
const fn = this.functions.get(name);

// After — fall back to hyphenated version if underscore lookup misses
const fn = this.functions.get(name) ?? this.functions.get(name.split('_').join('-'));

This is a two-line, non-breaking fix. The fallback only triggers when the primary lookup returns undefined.

Related Issues

  • #5030 (Gemini agent tool call failures — different root cause but same symptom)
  • #5054 / #5630 (Gemini function call fixes — these addressed thought_signature and parallel calls, not name normalization)
Originally created by @ROlwig on GitHub (Jun 4, 2026). Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/5755 Originally assigned to: @timothycarambat on GitHub. ## Description When using the Document Generation agent (create-files-agent) with Gemini models, the tool is attached and the LLM assembles the function call, but the tool handler **never executes**. The file is never created. The model then apologizes saying the tool is unavailable. ## Root Cause Gemini normalizes function names — it receives `create-docx-file` but returns `create_docx_file` (hyphens → underscores). The aibitat registry lookup at `index.js:981` and `index.js:1137` does an exact match: ```js const fn = this.functions.get(name); // returns undefined for 'create_docx_file' ``` The plugin was registered as `create-docx-file` (hyphen). The lookup silently returns `undefined`, the framework tells Gemini `"Function not found. Try again."`, and Gemini generates an apology to the user. This affects **all create-files-agent tools** since they all use hyphenated names (`create-docx-file`, `create-pdf-file`, `create-pptx-presentation`, `create-excel-file`, `create-text-file`). ## Steps to Reproduce 1. Enable Document Creation in Settings → Agent Skills 2. In a workspace with Agent mode and Gemini 2.5 Flash, request: `Create a quiz in Word format` 3. Observe: UI shows "Assembling Tool Call: create_docx_file(...)" but no file is generated 4. Container log shows plugin attached but no "Using the create-docx-file tool." message ## Environment - AnythingLLM v1.13.0 - Model: gemini-2.5-flash (also reproducible with gemini-2.5-pro) - Docker deployment - `ANYTHING_LLM_RUNTIME=docker` set - All required npm packages installed (docx, marked, jsdom) ## Expected Behavior File is generated and a download link appears in the chat. ## Actual Behavior Tool assembles but handler never runs. Model says tool is unavailable. ## Fix In `server/utils/agents/aibitat/index.js` at lines **981** and **1137**, change: ```js // Before const fn = this.functions.get(name); // After — fall back to hyphenated version if underscore lookup misses const fn = this.functions.get(name) ?? this.functions.get(name.split('_').join('-')); ``` This is a two-line, non-breaking fix. The fallback only triggers when the primary lookup returns `undefined`. ## Related Issues - #5030 (Gemini agent tool call failures — different root cause but same symptom) - #5054 / #5630 (Gemini function call fixes — these addressed thought_signature and parallel calls, not name normalization)
yindo added the needs info / can't replicateinvestigating labels 2026-06-05 14:53:04 -04:00
yindo closed this issue 2026-06-05 14:53:04 -04:00
Author
Owner

@timothycarambat commented on GitHub (Jun 5, 2026):

https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/agents/aibitat/providers/gemini.js#L105-L111 is what is supposed to handle this because their OAI compatible endpoints have some undocumented issues with function naming

<!-- gh-comment-id:4632662254 --> @timothycarambat commented on GitHub (Jun 5, 2026): https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/agents/aibitat/providers/gemini.js#L105-L111 is what is supposed to handle this because their OAI compatible endpoints have some undocumented issues with function naming
Author
Owner

@timothycarambat commented on GitHub (Jun 5, 2026):

Not seeing this in the latest example (using gemini2.5 flash)

Image Image

I will say from testing we have seen gemini sometimes generate return tool calls that are completely hallucinated and this could be that.

<!-- gh-comment-id:4632692183 --> @timothycarambat commented on GitHub (Jun 5, 2026): Not seeing this in the latest example (using gemini2.5 flash) <img width="1441" height="859" alt="Image" src="https://github.com/user-attachments/assets/7e0fb023-1f3c-44d7-9b00-86ae007e9e19" /> <img width="1434" height="867" alt="Image" src="https://github.com/user-attachments/assets/4640d99a-9213-4b44-8246-ba3194b4cfa4" /> I will say from testing we have seen gemini sometimes generate return tool calls that are completely hallucinated and this *could* be that.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#5277