{"record":{"id":"bd3dd850b34f53ab","repo":"Unity-Technologies/ml-agents","slug":"can-t-use-behavior-type-behaviortype-without-a-m","errorCode":null,"errorMessage":"Can't use Behavior Type {behaviorType} without a model. Either assign a model, or change to a different Behavior Type.","messagePattern":"Can't use Behavior Type (.+?) without a model\\. Either assign a model, or change to a different Behavior Type\\.","errorType":"exception","errorClass":"UnityAgentsException","httpStatus":null,"severity":"critical","filePath":"com.unity.ml-agents/Runtime/Policies/BehaviorParameters.cs","lineNumber":240,"sourceCode":"        }\n\n        void Awake()\n        {\n            OnPolicyUpdated += mode => { };\n        }\n\n        internal IPolicy GeneratePolicy(ActionSpec actionSpec, ActuatorManager actuatorManager)\n        {\n            switch (m_BehaviorType)\n            {\n                case BehaviorType.HeuristicOnly:\n                    return new HeuristicPolicy(actuatorManager, actionSpec);\n                case BehaviorType.InferenceOnly:\n                    {\n                        if (m_Model == null)\n                        {\n                            var behaviorType = BehaviorType.InferenceOnly.ToString();\n                            throw new UnityAgentsException(\n                                $\"Can't use Behavior Type {behaviorType} without a model. \" +\n                                \"Either assign a model, or change to a different Behavior Type.\"\n                            );\n                        }\n                        return new SentisPolicy(actionSpec, actuatorManager, m_Model, m_InferenceDevice, m_BehaviorName, m_DeterministicInference);\n                    }\n                case BehaviorType.Default:\n                    if (Academy.Instance.IsCommunicatorOn)\n                    {\n                        return new RemotePolicy(actionSpec, actuatorManager, FullyQualifiedBehaviorName);\n                    }\n                    if (m_Model != null)\n                    {\n                        return new SentisPolicy(actionSpec, actuatorManager, m_Model, m_InferenceDevice, m_BehaviorName, m_DeterministicInference);\n                    }\n                    else\n                    {\n                        return new HeuristicPolicy(actuatorManager, actionSpec);","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/Unity-Technologies/ml-agents/blob/3ecb446f75d1e7400eb404c562dc005d3164cffc/com.unity.ml-agents/Runtime/Policies/BehaviorParameters.cs#L222-L258","documentation":"BehaviorParameters.GeneratePolicy() throws this when BehaviorType is set to InferenceOnly but no neural network model (m_Model) is assigned. Inference-only agents run entirely on a trained model, so without one there is no policy to create. The library demands either a model or a different behavior type that doesn't need one (e.g. HeuristicOnly).","triggerScenarios":"Setting a BehaviorParameters component's Behavior Type to 'Inference Only' while the Model field is left empty; assigning a model at runtime via SetModel() with a null model; clearing the model in code or via prefab overrides before academy initialization.","commonSituations":"Dropping a trained NN model out of the inspector and forgetting to reassign; a training run failed so the .nn file was never produced; switching from Heuristic Only to Inference Only to test inference but never wiring up the model asset; prefab variants inheriting from a base that had no model.","solutions":["Assign a trained model asset (.nn / ONNX) to the Model field of the BehaviorParameters component","Change Behavior Type to Heuristic Only or Default (which falls back to heuristic) if you don't have a model yet","Set the model programmatically via behaviorParameters.SetModel(behaviorName, model) before the Academy initializes","Verify the model asset import succeeded (Sentis/Unity Inference Engine imported the ONNX) so the field isn't silently null"],"exampleFix":"// before\nbehaviorParameters.behaviorType = BehaviorType.InferenceOnly; // Model left null\n// after\nbehaviorParameters.behaviorType = BehaviorType.InferenceOnly;\nbehaviorParameters.model = trainedModelAsset; // assigned .nn/ONNX model","handlingStrategy":"validation","validationCode":"// Unity C#: before Academy init / first step\nif (behaviorParameters.BehaviorType == BehaviorType.InferenceOnly && behaviorParameters.Model == null)\n{\n    behaviorParameters.Model = trainedModelAsset; // or fall back to BehaviorType.HeuristicOnly\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    academyInitialize();\n}\ncatch (UnityAgentsException e) when (e.Message.Contains(\"without a model\"))\n{\n    behaviorParameters.BehaviorType = BehaviorType.HeuristicOnly;\n}","preventionTips":["Always assign the .nn model asset in the inspector before entering Play mode","Use BehaviorType.Default while iterating without a trained model","Validate BehaviorParameters in an editor script for all agents in the scene"],"tags":["unity","ml-agents","configuration","inference"],"backgroundTag":"inference-without-model","analyzedSha":"3ecb446f75d1e7400eb404c562dc005d3164cffc","analyzedAt":"2026-09-02T16:33:12.832Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}