From c63c68fd7b512500a991a9db92141f3c100d9155 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 22 Jan 2026 22:46:58 +0800 Subject: [PATCH] Refine Autonomous Mode Caching Logic in ListRobots API - Updated the ListRobots function to enhance caching behavior by explicitly requiring the autonomous_mode filter to be true when using cached results. - Improved comments for clarity on caching conditions and the implications of autonomous_mode filtering. - Ensured that when autonomous_mode is not specified or set to false, the database is queried to include all robots, maintaining comprehensive results. --- agent/robot/api/robot.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/agent/robot/api/robot.go b/agent/robot/api/robot.go index dc7b918b..800d8be0 100644 --- a/agent/robot/api/robot.go +++ b/agent/robot/api/robot.go @@ -62,9 +62,11 @@ func ListRobots(ctx *types.Context, query *ListQuery) (*ListResult, error) { return listRobotsFromDB(query) } - // If only teamID specified (no other filters), use cache for faster lookup - // Note: Cache only contains autonomous_mode=true robots, so this is safe - if query.TeamID != "" && query.Status == "" && query.Keywords == "" && query.ClockMode == "" { + // If only teamID specified AND explicitly filtering for autonomous_mode=true, use cache + // Cache only contains autonomous_mode=true robots + // When autonomous_mode is not specified or false, must query database to include all robots + if query.TeamID != "" && query.Status == "" && query.Keywords == "" && query.ClockMode == "" && + query.AutonomousMode != nil && *query.AutonomousMode == true { robots := mgr.Cache().List(query.TeamID) return paginateRobots(robots, query), nil }