Skip to content

Commit 0e254ea

Browse files
committed
fix some small issue
1 parent fbec87a commit 0e254ea

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

openhands-sdk/openhands/sdk/conversation/impl/local_conversation.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from collections.abc import Mapping
44
from pathlib import Path
55

6+
from propcache import cached_property
7+
68
from openhands.sdk.agent.base import AgentBase
79
from openhands.sdk.context.prompts.prompt import render_template
810
from openhands.sdk.conversation.base import BaseConversation
@@ -292,6 +294,11 @@ def resolved_plugins(self) -> list[ResolvedPluginSource] | None:
292294
"""
293295
return self._resolved_plugins
294296

297+
@cached_property
298+
def profile_store(self) -> LLMProfileStore:
299+
"""Get the profile store associated with this conversation."""
300+
return LLMProfileStore()
301+
295302
def _ensure_plugins_loaded(self) -> None:
296303
"""Lazy load plugins and set up hooks on first use.
297304
@@ -463,13 +470,11 @@ def _switch_model_profile(self, profile_name: str) -> None:
463470
FileNotFoundError: If the profile does not exist.
464471
ValueError: If the profile is corrupted or invalid.
465472
"""
466-
store = LLMProfileStore()
467-
new_llm = store.load(profile_name)
468-
469473
usage_id = f"model-profile-{profile_name}"
470474
try:
471475
new_llm = self.llm_registry.get(usage_id)
472476
except KeyError:
477+
new_llm = self.profile_store.load(profile_name)
473478
new_llm = new_llm.model_copy(update={"usage_id": usage_id})
474479
self.llm_registry.add(new_llm)
475480

@@ -481,12 +486,14 @@ def _emit_model_info(self) -> None:
481486
"""Emit an environment message with current model and available profiles."""
482487
current_model = self.agent.llm.model
483488
try:
484-
store = LLMProfileStore()
485-
profiles = store.list()
489+
profiles = self.profile_store.list()
486490
except Exception:
491+
logger.warning("Failed to load profile store", exc_info=True)
487492
profiles = []
488493

489-
profile_list = ", ".join(profiles) if profiles else "none"
494+
profile_list = (
495+
", ".join([Path(p).name for p in profiles]) if profiles else "none"
496+
)
490497
info_text = (
491498
f"Current model: {current_model}\nAvailable profiles: {profile_list}"
492499
)

0 commit comments

Comments
 (0)