Skip to content

fix(sdk): disable switch_llm by default (#16442) - #4436

Open
KHARSHAVARDHAN-eng wants to merge 1 commit into
OpenHands:mainfrom
KHARSHAVARDHAN-eng:fix/disable-switch-llm-tool-default-16442
Open

fix(sdk): disable switch_llm by default (#16442)#4436
KHARSHAVARDHAN-eng wants to merge 1 commit into
OpenHands:mainfrom
KHARSHAVARDHAN-eng:fix/disable-switch-llm-tool-default-16442

Conversation

@KHARSHAVARDHAN-eng

Copy link
Copy Markdown

HUMAN:

  • A human has tested these changes.

AGENT:


Why

Fixes #16442 by disabling switch_llm by default in the SDK agent settings and profiles, and annotating SwitchLLMTool with destructiveHint=True to require user confirmation when enabled.

Summary

  • Changed enable_switch_llm_tool default value from True to False in OpenHandsAgentSettings and AgentProfile.
  • Annotated SwitchLLMTool with destructiveHint=True so model switching operations trigger confirmation flows under policies requiring user approval.
  • Updated SDK unit tests in test_switch_llm.py, test_settings.py, test_resolver.py, and test_agent_profile.py.

Issue Number

Fixes #16442

How to Test

Run SDK unit tests:

poetry run pytest software-agent-sdk/tests/sdk/tool/test_switch_llm.py software-agent-sdk/tests/sdk/test_settings.py software-agent-sdk/tests/sdk/profiles/test_resolver.py software-agent-sdk/tests/sdk/profiles/test_agent_profile.py

GitCommandError: If the git command fails
"""
if args and args[0] == "git" and not any("core.quotePath" in a for a in args):
args = ["git", "-c", "core.quotePath=false", *args[1:]]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

All the git changes don't seem related to the PR, was this unintentional?

@enyst

enyst commented Aug 9, 2026

Copy link
Copy Markdown
Member

Hey, thank you for the proposal! I'm not sure that this is the root cause, or the right fix.
Also please see inline a little comment on the extraneous changes.

Could you show logs where the agent switches LLM and that caused a problem?

@KHARSHAVARDHAN-eng
KHARSHAVARDHAN-eng force-pushed the fix/disable-switch-llm-tool-default-16442 branch from da7e079 to b90cd5e Compare August 10, 2026 02:47
@KHARSHAVARDHAN-eng

Copy link
Copy Markdown
Author

Hi @enyst, thank you for the review!

Here is a summary of the updates made to address your feedback:

  1. Removed Extraneous Git Changes:

    • Rebased fix/disable-switch-llm-tool-default-16442 onto latest main and dropped the unrelated commit (84df1d5), removing all /api/git/diff files from this PR.
    • Pushed the updated branch so the PR now strictly contains only the 7 files relevant to enable_switch_llm_tool.
  2. LLM Switching Rationale (#16442):

    • When enable_switch_llm_tool defaulted to True, any environment with saved LLM profiles automatically exposed SwitchLLMTool to the agent.
    • During task execution, models occasionally invoke switch_llm unprompted when encountering difficult steps, changing the active model/credentials mid-conversation without user intent.
    • Setting enable_switch_llm_tool default to False ensures model-switching remains an explicit user opt-in, while destructiveHint=True guarantees user confirmation is prompted when enabled under active verification policies.

All 207 unit tests (test_switch_llm.py, test_settings.py, test_resolver.py, test_agent_profile.py) and ruff linter/formatter checks pass cleanly.

Let me know if any other required changes has to be made!! Thanks!!!

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.

2 participants