{"record":{"id":"e0ebaac45ce13b29","repo":"OpenBMB/ChatDev","slug":"similarity-threshold-must-be-numeric","errorCode":null,"errorMessage":"similarity_threshold must be numeric","messagePattern":"similarity_threshold must be numeric","errorType":"validation","errorClass":"ConfigError","httpStatus":null,"severity":"error","filePath":"entity/configs/node/memory.py","lineNumber":460,"sourceCode":"            stage_list = ensure_list(stages_raw)\n            parsed: List[AgentExecFlowStage] = []\n            for idx, item in enumerate(stage_list):\n                try:\n                    parsed.append(AgentExecFlowStage(item))\n                except ValueError as exc:\n                    raise ConfigError(\n                        f\"retrieve_stage entries must be one of {[stage.value for stage in AgentExecFlowStage]}\",\n                        extend_path(path, f\"retrieve_stage[{idx}]\"),\n                    ) from exc\n            stages = parsed\n\n        top_k_value = mapping.get(\"top_k\", 3)\n        if not isinstance(top_k_value, int) or top_k_value <= 0:\n            raise ConfigError(\"top_k must be a positive integer\", extend_path(path, \"top_k\"))\n\n        threshold_value = mapping.get(\"similarity_threshold\", -1.0)\n        if not isinstance(threshold_value, (int, float)):\n            raise ConfigError(\"similarity_threshold must be numeric\", extend_path(path, \"similarity_threshold\"))\n\n        read_value = mapping.get(\"read\", True)\n        if not isinstance(read_value, bool):\n            raise ConfigError(\"read must be boolean\", extend_path(path, \"read\"))\n\n        write_value = mapping.get(\"write\", True)\n        if not isinstance(write_value, bool):\n            raise ConfigError(\"write must be boolean\", extend_path(path, \"write\"))\n\n        return cls(\n            name=name,\n            retrieve_stage=stages,\n            top_k=top_k_value,\n            similarity_threshold=float(threshold_value),\n            read=read_value,\n            write=write_value,\n            path=path,\n        )","sourceCodeStart":442,"sourceCodeEnd":478,"githubUrl":"https://github.com/OpenBMB/ChatDev/blob/4fb2db0ea90375ce1059f44fe03ffbd191a7a169/entity/configs/node/memory.py#L442-L478","documentation":"MemoryRetrieveConfig.from_dict requires 'similarity_threshold' (default -1.0) to be an int or float (bool excluded in practice by intent, though bool is an int subclass). Any string, list, null-adjacent, or other non-numeric value raises this ConfigError.","triggerScenarios":"Setting similarity_threshold: '0.7' (string) or [0.7] in the retrieve config mapping.","commonSituations":"String values from environment variables or template interpolation not converted to numbers; YAML quoting the number; JSON configs where the value was serialized as a string.","solutions":["Remove quotes around the number so YAML/JSON parses it as numeric","Convert values with float(...) before building the mapping","Omit the key to use the default -1.0"],"exampleFix":"# before\nsimilarity_threshold: '0.7'\n# after\nsimilarity_threshold: 0.7","handlingStrategy":"validation","validationCode":"th = cfg.get('similarity_threshold', -1.0)\nassert isinstance(th, (int, float)) and not isinstance(th, bool)","typeGuard":"def is_valid_threshold(v) -> bool:\n    return isinstance(v, (int, float)) and not isinstance(v, bool)","tryCatchPattern":"try:\n    MemoryRetrieveConfig.from_dict(d, path='retrieve')\nexcept ConfigError as e:\n    if 'similarity_threshold' in str(e):\n        d['similarity_threshold'] = float(d['similarity_threshold'])\n        MemoryRetrieveConfig.from_dict(d, path='retrieve')","preventionTips":["float() cast env-var-derived thresholds","Keep numbers unquoted in YAML/JSON"],"tags":["config","validation","memory"],"backgroundTag":"invalid-config-value-type","analyzedSha":"4fb2db0ea90375ce1059f44fe03ffbd191a7a169","analyzedAt":"2026-08-27T14:35:29.622Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}