Skip to content

Commit e475956

Browse files
committed
fix: align LLM switch example with SDK API
1 parent ec87cfe commit e475956

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

examples/01_standalone_sdk/26_runtime_llm_switch.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@
2626
os.environ.setdefault("OPENHANDS_INLINE_CONVERSATIONS", "false")
2727

2828
# 3. Profiles live under ~/.openhands/llm-profiles by default. We create two
29-
# variants that share the same service_id so they can be swapped at runtime.
29+
# variants that share the same usage_id so they can be swapped at runtime.
3030
registry = LLMRegistry()
31-
service_id = "support-agent"
31+
usage_id = "support-agent"
3232

3333
base_profile_id = "support-mini"
3434
alt_profile_id = "support-pro"
3535

3636
base_llm = LLM(
37-
service_id=service_id,
37+
usage_id=usage_id,
3838
model="litellm_proxy/anthropic/claude-sonnet-4-5-20250929",
3939
base_url="https://llm-proxy.eval.all-hands.dev",
4040
api_key=SecretStr(api_key),
@@ -65,7 +65,7 @@
6565
workspace=str(workspace_dir),
6666
persistence_dir=str(persistence_dir),
6767
conversation_id=conversation_id,
68-
visualize=False,
68+
visualizer=None,
6969
)
7070

7171
conversation.send_message(
@@ -111,7 +111,7 @@
111111
workspace=str(workspace_dir),
112112
persistence_dir=str(persistence_dir),
113113
conversation_id=conversation_id,
114-
visualize=False,
114+
visualizer=None,
115115
)
116116

117117
print("Reloaded conversation is using profile:", reloaded.state.agent.llm.profile_id)
@@ -140,7 +140,7 @@
140140
workspace=str(workspace_dir),
141141
persistence_dir=str(inline_persistence_dir),
142142
conversation_id=uuid.uuid4(),
143-
visualize=False,
143+
visualizer=None,
144144
)
145145

146146
try:

tests/sdk/conversation/local/test_state_serialization.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ def test_local_conversation_switch_llm_persists_profile(tmp_path, monkeypatch):
674674
agent=agent,
675675
workspace=str(workspace_dir),
676676
persistence_dir=str(persistence_dir),
677-
visualize=False,
677+
visualizer=None,
678678
)
679679
assert isinstance(conversation, LocalConversation)
680680

@@ -697,7 +697,7 @@ def test_local_conversation_switch_llm_persists_profile(tmp_path, monkeypatch):
697697
workspace=str(workspace_dir),
698698
persistence_dir=str(persistence_dir),
699699
conversation_id=conversation.id,
700-
visualize=False,
700+
visualizer=None,
701701
)
702702
assert isinstance(reloaded, LocalConversation)
703703
assert reloaded.state.agent.llm.profile_id == "alt"
@@ -719,7 +719,7 @@ def test_local_conversation_switch_llm_inline_mode_rejected(tmp_path, monkeypatc
719719
agent=agent,
720720
workspace=str(tmp_path / "workspace"),
721721
persistence_dir=str(tmp_path / "persist"),
722-
visualize=False,
722+
visualizer=None,
723723
)
724724
assert isinstance(conversation, LocalConversation)
725725

@@ -743,7 +743,7 @@ def test_local_conversation_switch_llm_requires_idle(tmp_path, monkeypatch):
743743
agent=agent,
744744
workspace=str(tmp_path / "workspace"),
745745
persistence_dir=str(tmp_path / "persist"),
746-
visualize=False,
746+
visualizer=None,
747747
)
748748
assert isinstance(conversation, LocalConversation)
749749

tests/sdk/llm/test_llm_registry_profiles.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ def test_profile_serialization_mode_reference_only(tmp_path):
344344
assert "model" not in ref_data
345345
assert "usage_id" not in ref_data
346346

347+
347348
def test_switch_profile_replaces_active_llm(tmp_path):
348349
registry = LLMRegistry(profile_dir=tmp_path)
349350
base_llm = LLM(model="gpt-4o-mini", usage_id="primary")

0 commit comments

Comments
 (0)