anomalyco / anomalyco/opencode

glob.path description can trigger unstable tool-calling behavior with llama.cpp/Qwen3-Coder

Open
#44,489 1 comment 0 reactions 1 assignee View on GitHub

@neriousy is already working on this.

Since Aug 23, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

I found that the current description of the optional path parameter in the
built-in glob tool can trigger unstable tool-calling behavior when using
OpenCode with Qwen3-Coder through llama.cpp.

The current description is:

The directory to search in. If not specified, the current working directory will be used. IMPORTANT: Omit this field to use the default directory. DO NOT enter "undefined" or "null" - simply omit it for the default behavior. Must be a valid directory path if provided.

I confirmed this description is currently defined in:

packages/opencode/src/tool/glob.ts
Observed behavior

With Qwen3-Coder running through llama.cpp, the tool-calling behavior became
unstable when this description was present.

Depending on the model output, I observed:

  • valid glob tool calls
  • repeated text instead of a tool call
  • malformed tool-call-like text
  • degenerate arguments containing repeated ?
  • in one case, llama.cpp aborted the request with:
Unexpected empty grammar stack after accepting piece: ? (30)

The underlying grammar crash appears to be a llama.cpp issue and I am reporting
that separately.

However, I found that simplifying the OpenCode tool description avoids the
problem in practice.

Workaround tested

I used OpenCode's tool.definition hook to rewrite only the glob.path
description to:

The directory to search in. If omitted, the current working directory is used. Must be a valid directory path if provided.

No behavior or schema structure was changed.

After applying this patch, OpenCode successfully executed the glob tool with
the same local model/backend.

Example:

> build · hermes-coder

✱ Glob "src/**/*.ts" 10 matches

1. /home/aaronmunguia/Code/hermes-agent-runtime/src/index.ts
2. /home/aaronmunguia/Code/hermes-agent-runtime/src/tools/weather.ts
3. /home/aaronmunguia/Code/hermes-agent-runtime/src/graph/agent.ts
Proposed change

I suggest simplifying the current description from:

The directory to search in. If not specified, the current working directory will be used. IMPORTANT: Omit this field to use the default directory. DO NOT enter "undefined" or "null" - simply omit it for the default behavior. Must be a valid directory path if provided.

to something like:

The directory to search in. If omitted, the current working directory is used. Must be a valid directory path if provided.

This keeps the same semantics while:

  • reducing schema prompt length
  • removing redundant negative instructions
  • improving compatibility with local/open-source tool-calling models
  • avoiding a generation pattern that exposed a llama.cpp grammar failure in my setup
Environment

OpenCode:

  • 1.18.21

Model:

  • Qwen3-Coder-30B-A3B-Instruct
  • Q4_K_M GGUF

Backend:

  • llama.cpp OpenAI-compatible /v1/chat/completions
  • --jinja
  • HIP / ROCm

llama.cpp:

  • build b10587
  • commit 3f545becc

OS:

  • Fedora Linux
Additional note

The llama.cpp failure is output-dependent and not deterministic.

I do not think the OpenCode description itself is the root cause of the grammar
bug. Rather, the wording appears to influence the model's generated token path,
and some of those paths can expose the backend grammar issue.

The reason I am reporting this to OpenCode is that the description can be
simplified without losing any useful information, and the simpler version worked
reliably in my setup.

Plugins

No response

OpenCode version

1.18.21

Steps to reproduce
  1. Configure OpenCode to use a local OpenAI-compatible backend served by llama.cpp.

  2. Use Qwen3-Coder-30B-A3B-Instruct as the model.

  3. Make sure the built-in glob tool is enabled with the current path parameter description:

The directory to search in. If not specified, the current working directory will be used. IMPORTANT: Omit this field to use the default directory. DO NOT enter "undefined" or "null" - simply omit it for the default behavior. Must be a valid directory path if provided.
  1. Run a prompt that forces a glob tool call, for example:
Use glob exactly once to find TypeScript files under src/.

After the tool returns, respond with only the first 3 file paths.
Do not use any other tool.
  1. Repeat the request several times.

  2. Observe that tool-calling can become unstable depending on the generated output. I observed different behaviors across runs, including:

  • valid glob tool calls
  • repeated plain-text output instead of a tool call
  • malformed tool-call-like text
  • degenerate tool arguments containing repeated ?
  • one llama.cpp request abort with:
    Unexpected empty grammar stack after accepting piece: ? (30)
  1. Patch only the glob.path description using OpenCode's tool.definition hook to:
The directory to search in. If omitted, the current working directory is used. Must be a valid directory path if provided.
  1. Restart OpenCode and run the same prompt again.

  2. With the simplified description, glob tool calling works correctly in my setup.

Reproducibility note

The llama.cpp grammar failure is output-dependent and not deterministic, so the issue may not reproduce on every request.

The main reproducible observation on my setup is that simplifying only the glob.path description removes the unstable behavior without changing the tool schema or semantics.

Screenshot and/or share link

No response

Operating System

Fedora 44 Linux

Terminal

Kitty

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.