From e72570823eaefe64c419ba4ce1f852fc80ca132a Mon Sep 17 00:00:00 2001 From: loriscience Date: Sun, 22 Mar 2026 11:51:45 +0000 Subject: [PATCH] fix: ensure logical sorting for agent thought levels Fixed issue #145. Previously, agent thought levels (reasoning effort) were returned in the order they appeared in the resource JSON or session response, resulting in a confusing UI experience (e.g., 'high' appearing before 'low'). Changes: - Implemented logical sorting in parse_agent_config: low < medium < high < xhigh. - Ensures a consistent and predictable UX for model variant selection. --- server/packages/sandbox-agent/src/router/support.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/packages/sandbox-agent/src/router/support.rs b/server/packages/sandbox-agent/src/router/support.rs index 6bcc1034..9b24c4f1 100644 --- a/server/packages/sandbox-agent/src/router/support.rs +++ b/server/packages/sandbox-agent/src/router/support.rs @@ -284,7 +284,11 @@ fn parse_agent_config(json_str: &str) -> Vec { })); } - if let Some(thought_levels) = config.thought_levels { + if let Some(mut thought_levels) = config.thought_levels { + // Sort thought levels by predefined logical order: low < medium < high < xhigh + let order = ["low", "medium", "high", "xhigh"]; + thought_levels.sort_by_key(|t| order.iter().position(|&o| o == t.id).unwrap_or(order.len())); + options.push(json!({ "id": "thought_level", "name": "Thought Level",