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(symphony): 修复能力指纹新增type字段导致的兼容性问题
lin-xiaoyu1367fee0d3ef
diff --git a/jiuwenswarm/symphony/fingerprint/models.py b/jiuwenswarm/symphony/fingerprint/models.pyindex 68311b03c4..f63d1b288a 100644--- a/jiuwenswarm/symphony/fingerprint/models.py+++ b/jiuwenswarm/symphony/fingerprint/models.py@@ -176,7 +176,7 @@ class Fingerprint:def from_dict(cls, payload: Dict[str, Any]) -> "Fingerprint":if not isinstance(payload, dict):raise ValueError("Fingerprint payload must be a dictionary.")- raw_type = str(payload.get("type") or "")+ raw_type = str(payload.get("type") or "skill")if raw_type not in {"agent", "skill"}:raise ValueError("Fingerprint type must be 'agent' or 'skill'.")raw_inputs = payload.get("inputs", [])diff --git a/tests/unit_tests/symphony/test_fingerprint_models.py b/tests/unit_tests/symphony/test_fingerprint_models.pyindex f5dc596e50..c2ddd685c9 100644--- a/tests/unit_tests/symphony/test_fingerprint_models.py+++ b/tests/unit_tests/symphony/test_fingerprint_models.py@@ -34,6 +34,20 @@ def test_fingerprint_round_trip_preserves_unified_fields():assert Fingerprint.from_dict(fingerprint.to_dict()) == fingerprint[email protected]("legacy_type", ["missing", None, ""])+def test_fingerprint_from_dict_defaults_legacy_empty_type_to_skill(legacy_type):+ payload = _fingerprint().to_dict()+ if legacy_type == "missing":+ payload.pop("type")+ else:+ payload["type"] = legacy_type++ fingerprint = Fingerprint.from_dict(payload)++ assert fingerprint.type == "skill"+ assert fingerprint.to_dict()["type"] == "skill"++def test_fingerprint_rejects_unknown_type():with pytest.raises(ValueError, match="agent.*skill"):_fingerprint(type="workflow")