Skip to content

LM tool loop treats max_tool_iterations=1 as immediate failure #61

@darinkishore

Description

@darinkishore

Summary

LM::execute_tool_loop currently executes the initial tool call, then iterates with for iteration in 1..max_iterations.

When max_tool_iterations is set to 1, that follow-up loop runs zero times and the function always returns Max tool iterations reached, even though one iteration was explicitly allowed.

Why this matters

This makes max_tool_iterations=1 unusable for valid single-iteration tool workflows and can surface as an unexpected hard failure.

Reproduction

  1. Configure an LM with max_tool_iterations = 1.
  2. Make a request that triggers a tool call.
  3. Observe that the initial tool is executed, then the call fails with Max tool iterations reached.

Expected

With max_tool_iterations=1, one follow-up completion turn should be attempted after the initial tool result is appended, or the setting semantics should be clarified and enforced consistently.

Actual

No follow-up completion turn is attempted; the function exits with a max-iterations error.

Candidate fixes

  • Adjust loop bounds (for example 1..=max_iterations) if the current setting represents allowed completion iterations after the initial tool call.
  • Or redefine semantics so max_tool_iterations is total tool-call budget and update logic/docs accordingly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions