Skip to content

[BUG] Ollama model infinite loop with "ask_followup_question" #511

Closed

Description

@BlankDev117

Error Log:

Extension version: 3.58.0 
Provider: ollama (proxy) 
Model: qwen3-coder-next:latest Roo tried to use ask_followup_question without value for required parameter 'follow_up'. Retrying... assist with code

Reproduction Steps:

  • Setup Ollama as provider
  • Choose Qwen model
  • Ask questio in any mode (architect, code, ask, etc.)
  • Infinite loop because it never completes the follow_up question

I'm not exactly sure what to file this as and it could simply be a bug in the way the model is trained vs. how Zoo-Code interacts with it. Just trying a new extension setup and running into an issue where the model never finishes because Zoo keeps attempting to make API requests, despite seemingly the model being done with its response and waiting on a next prompt from me.

Is this an issue with the integration model (Qwen) or that Zoo is expecting it to ask a question when it was simply done and waiting for the next prompt so it thought to ask a follow up question the model didn't intend to make?

If this is user error on my part (i.e. bad model setup) then I can close. I know there's a warning that says Zoo is expected to work with Claude models, so it's quite possibly an issue there.

Activity

  1. added
    bug
    on Jun 6, 2026
  2. added theissue type on Jun 6, 2026
  3. nh2 commented on Jun 19, 2026

    @nh2
    Contributor

    I have the same problem with Version: 3.60.0 (a62a652c) on AWS Bedrock Opus 4.8. It often gets the ask_followup_question calls wrong and cannot manage to fix them.

    But I managed to get a full reproducer! Screenshot of it:

    Image

    You can reproduce it by running this prompt with the below file:

    Read @/zoo-code-issue-ask_followup_question-nonarray-follow_up.md . Reproduce the issue in this chat.
    

    zoo-code-issue-ask_followup_question-nonarray-follow_up.md

    I'll copy the contents of the file into the next comment so people can read/google it easily here.

    I did the code analysis on commit 0306f2b.

  4. nh2 commented on Jun 19, 2026

    @nh2
    Contributor

    ask_followup_question fails with misleading "Missing value for required parameter 'follow_up'" when follow_up is present but not a JSON array

    Summary

    When a native tool call for ask_followup_question arrives with a follow_up
    argument that is present but is not a JSON array (e.g. a JSON object, string, or
    number), the tool fails with:

    Missing value for required parameter 'follow_up'. Please retry with complete response.
    

    The error message is misleading: the value is not missing, it is the wrong
    type. The finalize parse path accepts the non-array value, and the tool then
    rejects it with a "missing" error, sending the model into a confusing retry loop
    (the model believes it already supplied follow_up).

    Steps to reproduce

    Call ask_followup_question with a valid question and a follow_up that is a
    JSON object instead of an array:

    {
      "question": "How should I handle the intensity_only guard removal?",
      "follow_up": {
        "0": { "mode": null, "text": "Keep the guard" },
        "1": { "mode": null, "text": "Remove the guard" }
      }
    }

    This deterministically reproduces the error every time.

    For comparison:

    • A valid non-empty array follow_up works.
    • An empty array follow_up: [] does NOT produce this error; it passes the
      array check but then hangs the UI with no buttons and no error (a likely
      separate bug, noted below).
    • Only a non-array (object/string/number) value triggers the "Missing value"
      error.

    Expected behavior

    • A non-array follow_up should produce a clear, accurate error (e.g.
      "follow_up must be an array of {text, mode?} items"), not "Missing value".
    • The finalize parse path should validate follow_up the same way the streaming
      partial path does, so both paths agree.

    Root cause

    There are two parse paths in
    src/core/assistant-message/NativeToolCallParser.ts and they disagree on
    follow_up:

    • The streaming PARTIAL path (createPartialToolUse) guards with
      Array.isArray(...):

      case "ask_followup_question":
        nativeArgs = {
          question: partialArgs.question,
          follow_up: Array.isArray(partialArgs.follow_up) ? partialArgs.follow_up : undefined,
        }
        break
    • The FINALIZE path (parseToolCall) does NOT; it only checks for
      !== undefined and passes the raw value through:

      case "ask_followup_question":
        if (args.question !== undefined && args.follow_up !== undefined) {
          nativeArgs = {
            question: args.question,
            follow_up: args.follow_up,
          } as NativeArgsFor<TName>
        }
        break

    The non-array value then flows through BaseTool.handle (which executes using
    block.nativeArgs) into AskFollowupQuestionTool.execute, which rejects it:

    if (!follow_up || !Array.isArray(follow_up)) {
      await recordMissingParamError("follow_up") // -> "Missing value for required parameter 'follow_up'"
      return
    }

    Because recordMissingParamError always reports "Missing value", the type
    mismatch is reported as a missing parameter.

    Why this appears intermittently in practice

    The bug is not limited to a model literally emitting an object. With native
    streaming, the tool-call arguments are accumulated and parsed incrementally by
    partial-json. When follow_up items are serialized compactly (e.g.
    text-first {"text":"...","mode":null}), the value bound to follow_up can
    resolve to a non-array intermediate depending on where chunk boundaries fall.
    Those boundaries shift with question length, punctuation, and follow_up
    key order/whitespace. Since the finalize path does not enforce Array.isArray,
    any such non-array value reaches execute and triggers the error. This is why
    the failure flips between FAIL and WORKED with seemingly cosmetic changes to the
    question or the follow_up serialization, while a clean single-blob array always
    succeeds.

    Suggested fix

    Make the finalize path consistent with the partial path by requiring an array:

    case "ask_followup_question":
      if (args.question !== undefined && Array.isArray(args.follow_up)) {
        nativeArgs = {
          question: args.question,
          follow_up: args.follow_up,
        } as NativeArgsFor<TName>
      }
      break

    Additionally:

    • Improve the error so that a present-but-non-array follow_up reports a
      type/shape error rather than "Missing value", so the model can correct it.
    • Handle the empty-array case so it does not hang the UI (see below).

    Affected files

    • src/core/assistant-message/NativeToolCallParser.ts
      (parseToolCall vs createPartialToolUse)
    • src/core/tools/AskFollowupQuestionTool.ts (execute)
    • src/core/tools/BaseTool.ts (handle, executes via nativeArgs)
  5. added a commit that references this issue on Jun 22, 2026
    37008b7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions