Skip to content

Commit 50cd6fb

Browse files
committed
corrections
1 parent 5b11157 commit 50cd6fb

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

openhands-sdk/openhands/sdk/subagent/registry.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,18 @@ def agent_definition_to_factory(
126126
) -> Callable[["LLM"], "Agent"]:
127127
"""Create an agent factory closure from an `AgentDefinition`.
128128
129-
The returned callable accepts an `LLM` instance (the parent agent's LLM)
130-
and builds a fully-configured `Agent` instance.
131-
132-
- Tool names from `agent_def.tools` are mapped to `Tool` objects.
133-
- The system prompt is set as the `system_message_suffix` on the
134-
`AgentContext`.
135-
- ``model: inherit`` preserves the parent LLM unchanged.
136-
- ``model: profile:<name>`` loads a complete LLM from *profile_store*
137-
(or a default :class:`LLMProfileStore` when *profile_store* is ``None``).
129+
The returned callable accepts the parent agent's LLM and produces a
130+
fully-configured `Agent`. Regardless of which model mode is
131+
used, the resulting LLM always has streaming disabled and independent
132+
metrics (via `model_copy` + `reset_metrics`).
133+
134+
Model resolution (`agent_def.model`):
135+
- "inherit" or empty: Re-uses the parent LLM configuration as-is.
136+
- Any other value: Treated as a profile name and loaded from `LLMProfileStore`.
137+
Raises `ValueError` if the profile is not found.
138+
139+
The factory also wires up tools (from `agent_def.tools`) and the
140+
system prompt (as `AgentContext.system_message_suffix`).
138141
"""
139142

140143
def _factory(llm: "LLM") -> "Agent":
@@ -146,10 +149,11 @@ def _factory(llm: "LLM") -> "Agent":
146149
# 'inherit' and it was given
147150
if agent_def.model and agent_def.model != "inherit":
148151
store = _get_profile_store()
149-
if agent_def.model not in store.list():
152+
available_profiles = [name.removesuffix(".json") for name in store.list()]
153+
if agent_def.model not in available_profiles:
150154
raise ValueError(
151155
f"Profile {agent_def.model} not found in profile store.\n"
152-
f"Available profiles: {store.list()}"
156+
f"Available profiles: {available_profiles}"
153157
)
154158

155159
profile_name = agent_def.model

tests/sdk/subagent/test_subagent_registry.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ def test_agent_definition_to_factory_model_profile(tmp_path: Path) -> None:
331331
agent_def = AgentDefinition(
332332
name="profile-agent",
333333
description="Uses a profile",
334-
model="fast-gpt.json",
334+
model="fast-gpt",
335335
tools=["ReadTool"],
336336
system_prompt="Profile test.",
337337
)
@@ -387,7 +387,7 @@ def test_agent_definition_to_factory_model_profile_custom_store(tmp_path: Path)
387387
agent_def = AgentDefinition(
388388
name="custom-store-agent",
389389
description="Uses custom store",
390-
model="my-profile.json",
390+
model="my-profile",
391391
tools=[],
392392
system_prompt="",
393393
)

0 commit comments

Comments
 (0)