Skip to content

Enable/Disable thinking on reasoning models #1768

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 30, 2025

Conversation

rhatdan
Copy link
Member

@rhatdan rhatdan commented Jul 29, 2025

Fixes: #1509

Summary by Sourcery

Add support for toggling thinking mode in reasoning models via a new CLI flag and configuration setting, defaulting to enabled and mapping disabled mode to a zero reasoning budget

New Features:

  • Introduce a --thinking CLI flag and corresponding config option to enable or disable thinking mode

Enhancements:

  • Pass --reasoning-budget 0 when thinking mode is disabled during model invocation

Documentation:

  • Update ramalama.conf examples and man pages to document the thinking setting and --thinking flag

Tests:

  • Add system tests to verify --thinking flag behavior in the serve command

Copy link
Contributor

sourcery-ai bot commented Jul 29, 2025

Reviewer's Guide

This PR introduces a new “thinking” flag throughout the stack to control reasoning-mode behavior, wiring it from default configuration into the CLI, propagating it into the model invocation (by setting a zero reasoning budget when disabled), and updating tests and documentation accordingly.

Sequence diagram for CLI propagation of the 'thinking' flag to model invocation

sequenceDiagram
    actor User
    participant CLI as CLI (ramalama/cli.py)
    participant Config as BaseConfig
    participant Model as llama_serve (ramalama/model.py)

    User->>CLI: run command with --thinking flag
    CLI->>Config: Read default thinking value
    CLI->>Model: Call llama_serve(args)
    Model->>Model: if not args.thinking, add --reasoning-budget 0
    Model-->>CLI: Model invoked with/without reasoning budget
Loading

Class diagram for updated configuration and CLI argument handling

classDiagram
    class BaseConfig {
        +bool thinking = True
        ...
    }
    class RamalamaSettings {
        ...
    }
    class UserConfig {
        ...
    }
    BaseConfig --> RamalamaSettings : settings
    BaseConfig --> UserConfig : user

    class CoerceToBool {
        ...
    }

    class argparse.ArgumentParser {
        add_argument()
        ...
    }
    argparse.ArgumentParser <.. CoerceToBool : uses
    argparse.ArgumentParser <.. BaseConfig : uses (default)
Loading

File-Level Changes

Change Details Files
Add ‘thinking’ option to CLI and config
  • Add --thinking argument with CoerceToBool in runtime_options
  • Use CONFIG.thinking as default value for the new flag
  • Add thinking field to BaseConfig with default true
ramalama/cli.py
ramalama/config.py
Propagate thinking flag into model execution
  • Check args.thinking in llama_serve
  • Append --reasoning-budget 0 when thinking is disabled
ramalama/model.py
Extend system tests for thinking behavior
  • Add bats cases for --thinking False invoking --reasoning-budget 0
  • Verify default invocation omits reasoning-budget
test/system/040-serve.bats
Update configuration file examples
  • Add thinking setting in ralamala.conf sample
  • Annotate enabled/disabled behavior in config manifest
docs/ramalama.conf
docs/ramalama.conf.5.md
Document --thinking in man pages
  • Add thinking option description to bench, perplexity, run, and serve pages
docs/ramalama-bench.1.md
docs/ramalama-perplexity.1.md
docs/ramalama-run.1.md
docs/ramalama-serve.1.md

Possibly linked issues

  • Reasoning flag #1509: The PR adds a --thinking flag to RamaLama, which sets --reasoning-budget 0 when disabled, directly addressing the issue's request for a reasoning flag.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @rhatdan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new capability to explicitly enable or disable a 'thinking mode' for reasoning models within the ramalama application. This provides users with more granular control over model behavior, allowing them to optimize for either deterministic or more exploratory outputs. The changes involve updates to the command-line interface, configuration files, core model execution logic, and comprehensive documentation.

Highlights

  • New Command-Line Option: Introduced a new --thinking command-line option for ramalama commands (bench, perplexity, run, serve) to control the 'thinking mode' of reasoning models. This option defaults to True.
  • Configuration Support: Added a thinking configuration option to ramalama.conf and its corresponding documentation, allowing users to set the default behavior for thinking mode.
  • Model Execution Logic: Implemented logic within ramalama/model.py to translate --thinking False into the --reasoning-budget 0 argument for the underlying llama_serve process, effectively disabling the model's reasoning budget.
  • System Tests: Added new system tests in test/system/040-serve.bats to verify that the --thinking option correctly influences the arguments passed to the model runtime, ensuring the feature behaves as expected.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @rhatdan - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a --thinking flag to enable or disable "thinking mode" in reasoning models, which translates to setting the --reasoning-budget. The changes include adding the command-line argument, configuration option, implementation logic, tests, and documentation updates.

My review focuses on improving the clarity of the new option for users. The descriptions in the documentation and help texts are a bit vague, and I've suggested more descriptive text. I also found a minor formatting issue.

Comment on lines 138 to 139
#### **--thinking**=*true*
Enable thinking mode in reasoning models
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The description for the --thinking flag is a bit vague. To improve clarity for users, consider explaining what "thinking mode" entails or what happens when it's disabled. Based on the implementation, disabling it sets the --reasoning-budget to 0.

Suggested change
#### **--thinking**=*true*
Enable thinking mode in reasoning models
#### **--thinking**=*true*
Enable or disable thinking mode in reasoning models. When disabled, this sets the reasoning budget to 0.

Comment on lines 146 to 147
#### **--thinking**=*true*
Enable thinking mode in reasoning models
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The description for the --thinking flag is a bit vague. To improve clarity for users, consider explaining what "thinking mode" entails or what happens when it's disabled. Based on the implementation, disabling it sets the --reasoning-budget to 0.

Suggested change
#### **--thinking**=*true*
Enable thinking mode in reasoning models
#### **--thinking**=*true*
Enable or disable thinking mode in reasoning models. When disabled, this sets the reasoning budget to 0.

Comment on lines 164 to 165
#### **--thinking**=*true*
Enable thinking mode in reasoning models
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The description for the --thinking flag is a bit vague. To improve clarity for users, please consider explaining what "thinking mode" entails or what happens when it's disabled. Based on the implementation, disabling it sets the --reasoning-budget to 0.

Suggested change
#### **--thinking**=*true*
Enable thinking mode in reasoning models
#### **--thinking**=*true*
Enable or disable thinking mode in reasoning models. When disabled, this sets the reasoning budget to 0.

Comment on lines 207 to 208
#### **--thinking**=*true*
Enable thinking mode in reasoning models
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The description for the --thinking flag is a bit vague. To improve clarity for users, please consider explaining what "thinking mode" entails or what happens when it's disabled. Based on the implementation, disabling it sets the --reasoning-budget to 0.

Suggested change
#### **--thinking**=*true*
Enable thinking mode in reasoning models
#### **--thinking**=*true*
Enable or disable thinking mode in reasoning models. When disabled, this sets the reasoning budget to 0.

Comment on lines +127 to +129
# Enable thinking mode on reasoning models
#
#thinking = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The description for the thinking option is a bit vague. To improve clarity for users, please consider explaining what "thinking mode" entails or what happens when it's disabled. Based on the implementation, disabling it sets the --reasoning-budget to 0.

# Enable thinking mode on reasoning models
#
#thinking = true
# Enable or disable thinking mode on reasoning models. When disabled, this sets the reasoning budget to 0.

Comment on lines +172 to +174
**thinking**=true

Enable thinking mode on reasoning models
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The description for the thinking option is a bit vague. To improve clarity for users, please consider explaining what "thinking mode" entails or what happens when it's disabled. Based on the implementation, disabling it sets the --reasoning-budget to 0.

Suggested change
**thinking**=true
Enable thinking mode on reasoning models
**thinking**=true
Enable or disable thinking mode on reasoning models. When disabled, this sets the reasoning budget to 0.

Comment on lines +832 to +834
default=CONFIG.thinking,
help="enable/disable thinking mode in reasoning models",
action=CoerceToBool,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The help text for --thinking is a bit vague. To improve clarity for users, please consider explaining what "thinking mode" entails or what happens when it's disabled. Based on the implementation, disabling it sets the --reasoning-budget to 0.

Suggested change
default=CONFIG.thinking,
help="enable/disable thinking mode in reasoning models",
action=CoerceToBool,
help="enable/disable thinking mode in reasoning models. When disabled, this sets the reasoning budget to 0.",

ramalama/cli.py Outdated
Comment on lines 1005 to 1006


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This extra newline appears to be unintentional. Please remove it to maintain consistent code formatting.

@rhatdan rhatdan changed the title Enable/Disable thinking on resoning models Enable/Disable thinking on reasoning models Jul 29, 2025
@rhatdan rhatdan force-pushed the reasoning branch 3 times, most recently from e3831fc to 4baba11 Compare July 29, 2025 17:01
@rhatdan rhatdan merged commit fd86b56 into containers:main Jul 30, 2025
54 of 61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reasoning flag
2 participants