Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

fix(jiuwen): validate model identity against request config

FrancesShaw0073112af848afb
diff --git a/jiuwenswarm/server/runtime/agent_adapter/interface_deep.py b/jiuwenswarm/server/runtime/agent_adapter/interface_deep.py
index 07ce933cb8..e9a80dc824 100644
--- a/jiuwenswarm/server/runtime/agent_adapter/interface_deep.py
+++ b/jiuwenswarm/server/runtime/agent_adapter/interface_deep.py
@@ -6651,7 +6651,7 @@ class JiuWenSwarmDeepAdapter:
model_ref = str(request.params.get("model_ref") or "").strip()
if model_ref:
model = self._resolve_model_by_identity(model_ref)
- actual = str(getattr(model.model_client_config, "model_name", "") or "").strip()
+ actual = str(getattr(model.model_config, "model_name", "") or "").strip()
if requested and requested != actual:
raise ValueError(
f"model_name does not match model_ref: expected {requested!r}, found {actual!r}"
diff --git a/tests/test_single_agent_model_identity.py b/tests/test_single_agent_model_identity.py
index ab4f236c29..4711f47c1e 100644
--- a/tests/test_single_agent_model_identity.py
+++ b/tests/test_single_agent_model_identity.py
@@ -15,15 +15,16 @@ def _adapter(*models):
adapter._model_identity_to_keys = {}
for i, model in enumerate(models):
config = model.model_client_config
- ref = build_model_identity_reference(config.model_name, vars(config))
+ ref = build_model_identity_reference(model.model_config.model_name, vars(config))
adapter._model_identity_to_keys.setdefault(ref, []).append(f"glm-5.3#{i}")
return adapter
def _model(base, name="glm-5.3"):
- return SimpleNamespace(model_client_config=SimpleNamespace(
- api_base=base, model_name=name, client_provider="OpenAI"
- ))
+ return SimpleNamespace(
+ model_client_config=SimpleNamespace(api_base=base, client_provider="OpenAI"),
+ model_config=SimpleNamespace(model_name=name),
+ )
def _request(**params):