Skip to content

fix: MAX_STEPS does not actually disable tools when step limit reached #24505

Closed as not planned

Description

@alfredocristofano

In packages/opencode/src/session/prompt.ts, when isLastStep is true (i.e., the agent has reached the MAX_STEPS limit), a prefilled assistant message claims that tools are disabled. However, the full tools object is still passed to handle.process(), which allows the model to continue making tool calls even though it should be forced to return a final answer.\n\nThe fix is to pass an empty object/array for tools when isLastStep is true, so the model cannot invoke any further tools.

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 26, 2026
  2. github-actions commented on Apr 26, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • No issue template was used. Please use one of the three required templates: Bug Report, Feature Request, or Question. Since this describes incorrect behavior, a Bug Report template would be most appropriate and should include reproduction steps/context.

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


    This issue may be related to an existing issue. Please check:

    If you believe this was flagged incorrectly, please let a maintainer know.

  3. github-actions commented on Apr 26, 2026

    @github-actions
    Contributor

    This issue has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

    Feel free to open a new issue that follows our issue templates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions