@@ -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
0 commit comments