From 306414a5556b189b50bb76f52602cfc904814467 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Sun, 3 May 2026 21:56:03 +0000 Subject: [PATCH] fix(simulation): add int coercion and 400 validation for max_agents in prepare endpoint --- backend/app/api/simulation.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backend/app/api/simulation.py b/backend/app/api/simulation.py index aa72b61d..3aa4422a 100644 --- a/backend/app/api/simulation.py +++ b/backend/app/api/simulation.py @@ -449,6 +449,11 @@ def prepare_simulation(): entity_types_list = data.get('entity_types') max_agents = data.get('max_agents') # optional: limit to top-N most-connected entities + if max_agents is not None: + try: + max_agents = int(max_agents) + except (TypeError, ValueError): + return jsonify({"success": False, "error": "max_agents must be an integer"}), 400 use_llm_for_profiles = data.get('use_llm_for_profiles', True) parallel_profile_count = data.get('parallel_profile_count', 5)