model_config: decouple browser agent model wiring
Move the browser model instantiation logic out of `_model_config` and into `_browser_agent` to properly invert the dependency direction. This prevents the always-enabled `_model_config` plugin from taking a hard dependency on the optional `_browser_agent` module, ensuring it won't break if the browser module is removed or replaced.
Alessandro committed
Mar 24, 2026 at 16:38 UTC
5f235f73f69ee80feace7b5b54c109b48eb1bdd2
5 files changed
+21
-20
plugins/_browser_agent/extensions/python/_functions/agent/Agent/get_browser_model/start/_10_browser_agent.py
new
+7
@@ -0,0 +1,7 @@
1
+from helpers.extension import Extension
2
+from plugins._browser_agent.helpers.browser_llm import build_browser_model_for_agent
3
+
4
+class BrowserModelProvider(Extension):
5
+ def execute(self, data: dict = {}, **kwargs):
6
+ if self.agent:
7
+ data["result"] = build_browser_model_for_agent(self.agent)
plugins/_browser_agent/helpers/browser_llm.py
+12
@@ -129,3 +129,15 @@ def build_browser_model_from_config(
129
model_config,
130
**kwargs,
131
)
132
+
133
+def build_browser_model_for_agent(agent=None) -> BrowserCompatibleChatWrapper:
134
+ """Build and return the browser-use adapter using chat model config."""
135
+ from plugins._model_config.helpers.model_config import (
136
+ get_chat_model_config,
137
+ build_model_config,
138
+ )
139
+ import models
140
+
141
+ cfg = get_chat_model_config(agent)
142
+ mc = build_model_config(cfg, models.ModelType.CHAT)
143
+ return build_browser_model_from_config(mc)
plugins/_model_config/README.md
+2
-1
@@ -21,7 +21,8 @@ This plugin centralizes model selection and model-related settings for the appli
21
- **Per-chat override**
22
- Allows a chat context to store a temporary override or preset reference in context data.
23
- **Model object construction**
24
- - Builds `ModelConfig` objects and the runtime chat, browser, utility, and embedding wrappers used elsewhere in the app.
24
+ - Builds `ModelConfig` objects and the runtime chat, utility, and embedding wrappers used elsewhere in the app.
25
+ - Note: Browser model wiring now lives in the `_browser_agent` plugin.
26
- **API key validation**
27
- Reports configured providers that still require API keys.
28
plugins/_model_config/extensions/python/_functions/agent/Agent/get_browser_model/start/_10_model_config.py
deleted
-8
@@ -1,8 +0,0 @@
1
-from helpers.extension import Extension
2
-from plugins._model_config.helpers.model_config import build_browser_model
3
-
4
-
5
-class BrowserModelProvider(Extension):
6
- def execute(self, data: dict = {}, **kwargs):
7
- if self.agent:
8
- data["result"] = build_browser_model(self.agent)
plugins/_model_config/helpers/model_config.py
-11
@@ -189,17 +189,6 @@ def build_utility_model(agent=None):
189
)
190
191
192
-def build_browser_model(agent=None):
193
- """Build and return the browser-use adapter using chat model config."""
194
- cfg = get_chat_model_config(agent)
195
- mc = build_model_config(cfg, models.ModelType.CHAT)
196
- from plugins._browser_agent.helpers.browser_llm import (
197
- build_browser_model_from_config,
198
- )
199
-
200
- return build_browser_model_from_config(mc)
201
-
202
-
192
def build_embedding_model(agent=None):
193
"""Build and return an embedding model wrapper."""
194
cfg = get_embedding_model_config(agent)