Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion openhands-agent-server/openhands/agent_server/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
get_agent_profile_store,
get_llm_profile_store,
)
from openhands.agent_server.skills_service import discover_profile_skills
from openhands.agent_server.skills_service import (
discover_profile_skills,
discover_public_skill_names,
)
from openhands.sdk.agent import ACPAgent
from openhands.sdk.agent.base import AgentBase
from openhands.sdk.context.agent_context import AgentContext
Expand Down Expand Up @@ -62,11 +65,14 @@ def server_launch_stores(
settings: PersistedSettings, cipher: Cipher | None
) -> LaunchStores:
llm_store = get_llm_profile_store()
verification = getattr(settings.agent_settings, "verification", None)
return LaunchStores(
llm_profiles=llm_store,
llm_profile_names=lambda: [n.removesuffix(".json") for n in llm_store.list()],
mcp_config=settings.agent_settings.mcp_config,
skills=discover_profile_skills,
public_skill_names=discover_public_skill_names,
critic_api_key=verification.critic_api_key if verification else None,
agent_profiles=get_agent_profile_store(),
meta_profiles=MetaProfileStore(base_dir=default_meta_profile_dir()),
cipher=cipher,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class ServerInfo(BaseModel):
"tool_catalog_v1",
"agent_profile_draft_materialize_v1",
"agent_launch_pipeline_v1",
"profile_public_skills_v1",
]
)
app_backend_ingress_url: str | None = Field(
Expand Down
10 changes: 10 additions & 0 deletions openhands-agent-server/openhands/agent_server/skills_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,16 @@ def discover_profile_skills() -> list[Skill]:
)


def discover_public_skill_names() -> set[str]:
"""Names of the public tier of :func:`discover_profile_skills`.

A user skill that shadows a public one by name belongs to the user tier, as
it does in the merged catalog.
"""
names = load_available_skills(include_public=True)
return set(names) - set(load_available_skills(include_user=True))


def sync_public_skills() -> tuple[bool, str]:
"""Force refresh of public skills from GitHub repository.

Expand Down
14 changes: 11 additions & 3 deletions openhands-sdk/openhands/sdk/launch/preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@
_settings_for_runtime,
finalize,
)
from openhands.sdk.launch.resolve import LaunchStores, _load_llm, _load_skills, resolve
from openhands.sdk.launch.resolve import (
LaunchStores,
_load_llm,
_load_public_skill_names,
_load_skills,
resolve,
)
from openhands.sdk.profiles.agent_profile import ACPAgentProfile, OpenHandsAgentProfile
from openhands.sdk.profiles.resolver import (
AgentProfileDiagnostics,
_acp_credential_channels,
_api_key_set,
_apply_disabled_skills,
_compute_mcp_filter,
_profile_skills,
_unusable_tools,
)
from openhands.sdk.settings.model import OpenHandsAgentSettings
Expand Down Expand Up @@ -50,6 +56,7 @@ def preview_launch(
if isinstance(profile, OpenHandsAgentProfile):
diagnostics.llm_profile_ref = profile.llm_profile_ref
diagnostics.disabled_skills = profile.disabled_skills
diagnostics.public_skills = profile.public_skills
diagnostics.meta_profile_ref = profile.meta_profile_ref
diagnostics.unusable_tools = _unusable_tools(
profile.tools,
Expand Down Expand Up @@ -107,9 +114,10 @@ def _report_llm_key_and_skills(
try:
llm = _load_llm(stores, profile.llm_profile_ref)
catalog = _load_skills(stores)
public_names = _load_public_skill_names(profile, stores)
except (AgentLaunchError, LaunchStoreError):
return
diagnostics.llm_api_key_set = llm is not None and _api_key_set(llm)
diagnostics.resolved_skills = [
skill.name for skill in _apply_disabled_skills(catalog, profile.disabled_skills)
skill.name for skill in _profile_skills(profile, catalog, public_names)
]
36 changes: 30 additions & 6 deletions openhands-sdk/openhands/sdk/launch/resolve.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from __future__ import annotations

from collections.abc import Callable, Mapping, Sequence
from collections.abc import Callable, Collection, Mapping, Sequence
from dataclasses import dataclass
from typing import TYPE_CHECKING, Protocol
from uuid import UUID

from pydantic import SecretStr

from openhands.sdk.launch.errors import (
AgentLaunchError,
LaunchStoreError,
Expand All @@ -19,10 +21,11 @@
)
from openhands.sdk.profiles.resolver import (
ProfileNotFound,
_apply_disabled_skills,
_build_acp_settings,
_build_openhands_settings,
_compute_mcp_filter,
_profile_skills,
_select_skills,
)
from openhands.sdk.settings.model import ACPAgentSettings, OpenHandsAgentSettings
from openhands.sdk.skills import Skill
Expand Down Expand Up @@ -51,6 +54,12 @@ class LaunchStores:
llm_profiles: LLMProfileLoader
mcp_config: Mapping[str, MCPServer]
skills: Callable[[], Sequence[Skill]]
# Names of the public catalog tier that `public_skills` filters; None
# counts every catalog skill as public.
public_skill_names: Callable[[], Collection[str]] | None = None
# Server-wide credential: a profile is secret-free, so every OpenHands
# profile launch uses this one.
critic_api_key: SecretStr | None = None
agent_profiles: AgentProfileLoader | None = None
meta_profiles: MetaProfileLoader | None = None
llm_profile_names: Callable[[], Sequence[str]] | None = None
Expand Down Expand Up @@ -108,13 +117,16 @@ def resolve(
raise UnresolvedProfileReferences(mcp_server_refs=dangling_mcp)
try:
settings = _build_acp_settings(
profile, mcp_config, _apply_disabled_skills(catalog, [])
profile, mcp_config, _select_skills(catalog, [])
)
except ValueError as exc:
raise AgentLaunchError(str(exc)) from exc
else:
skills = _profile_skills(
profile, catalog, _load_public_skill_names(profile, stores)
)
settings = _resolve_openhands(
profile, stores, mcp_config, catalog, dangling_mcp, llm_profile_ref
profile, stores, mcp_config, skills, dangling_mcp, llm_profile_ref
)
if not isinstance(settings, OpenHandsAgentSettings | ACPAgentSettings):
raise AgentLaunchError(f"Unsupported agent kind {settings.agent_kind!r}")
Expand All @@ -134,7 +146,7 @@ def _resolve_openhands(
profile: OpenHandsAgentProfile,
stores: LaunchStores,
mcp_config: dict[str, MCPServer],
catalog: list[Skill],
skills: list[Skill],
dangling_mcp: list[str],
llm_profile_ref: str | None,
) -> OpenHandsAgentSettings | ACPAgentSettings:
Expand All @@ -157,10 +169,11 @@ def _resolve_openhands(
# when the runtime wires no token callback.
llm.model_copy(update={"stream": True}),
mcp_config,
_apply_disabled_skills(catalog, profile.disabled_skills),
skills,
browser_available=None,
meta_profile=meta_profile,
meta_profile_llms=meta_llms,
critic_api_key=stores.critic_api_key,
)
except ValueError as exc:
raise AgentLaunchError(str(exc)) from exc
Expand Down Expand Up @@ -195,6 +208,17 @@ def _load_skills(stores: LaunchStores) -> list[Skill]:
raise LaunchStoreError(f"Skill discovery failed: {exc}") from exc


def _load_public_skill_names(
profile: OpenHandsAgentProfile, stores: LaunchStores
) -> frozenset[str] | None:
if profile.public_skills is None or stores.public_skill_names is None:
return None
try:
return frozenset(stores.public_skill_names())
except Exception as exc:
raise LaunchStoreError(f"Skill discovery failed: {exc}") from exc


def _load_llm(stores: LaunchStores, name: str) -> LLM | None:
from openhands.sdk.llm.provider_connection_store import ProviderConnectionNotFound

Expand Down
9 changes: 9 additions & 0 deletions openhands-sdk/openhands/sdk/profiles/agent_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,15 @@ class OpenHandsAgentProfile(AgentProfileBase):
"exclusion is the only selection model that can't dangle."
),
)
public_skills: list[str] | None = Field(
default=None,
description=(
"Which public-catalog skills to load. null = all; [] = none; a list "
"= only the named skills, ignoring names the catalog lacks. User and "
"project skills are not affected, and `disabled_skills` still "
"applies to every skill."
),
)
condenser: CondenserSettingsConfig = Field(
default_factory=LLMSummarizingCondenserSettings,
description="Condenser settings for the agent.",
Expand Down
Loading
Loading