add subagent index selectors and session active filters

This commit is contained in:
DBT
2026-02-23 13:45:02 +00:00
parent c86e314d7f
commit f252afab64
3 changed files with 121 additions and 19 deletions

View File

@@ -36,11 +36,12 @@ func (t *SessionsTool) Parameters() map[string]interface{} {
return map[string]interface{}{
"type": "object",
"properties": map[string]interface{}{
"action": map[string]interface{}{"type": "string", "description": "list|history"},
"key": map[string]interface{}{"type": "string", "description": "session key for history"},
"limit": map[string]interface{}{"type": "integer", "description": "max items", "default": 20},
"kinds": map[string]interface{}{"type": "array", "items": map[string]interface{}{"type": "string"}, "description": "optional session kinds filter for list"},
"include_tools": map[string]interface{}{"type": "boolean", "description": "include tool role messages in history", "default": false},
"action": map[string]interface{}{"type": "string", "description": "list|history"},
"key": map[string]interface{}{"type": "string", "description": "session key for history"},
"limit": map[string]interface{}{"type": "integer", "description": "max items", "default": 20},
"active_minutes": map[string]interface{}{"type": "integer", "description": "only sessions updated in recent N minutes (list action)"},
"kinds": map[string]interface{}{"type": "array", "items": map[string]interface{}{"type": "string"}, "description": "optional session kinds filter for list"},
"include_tools": map[string]interface{}{"type": "boolean", "description": "include tool role messages in history", "default": false},
},
"required": []string{"action"},
}
@@ -58,6 +59,10 @@ func (t *SessionsTool) Execute(ctx context.Context, args map[string]interface{})
if v, ok := args["include_tools"].(bool); ok {
includeTools = v
}
activeMinutes := 0
if v, ok := args["active_minutes"].(float64); ok && int(v) > 0 {
activeMinutes = int(v)
}
kindFilter := map[string]struct{}{}
if rawKinds, ok := args["kinds"].([]interface{}); ok {
for _, it := range rawKinds {
@@ -89,6 +94,16 @@ func (t *SessionsTool) Execute(ctx context.Context, args map[string]interface{})
}
items = filtered
}
if activeMinutes > 0 {
cutoff := time.Now().Add(-time.Duration(activeMinutes) * time.Minute)
filtered := make([]SessionInfo, 0, len(items))
for _, s := range items {
if s.UpdatedAt.After(cutoff) {
filtered = append(filtered, s)
}
}
items = filtered
}
if len(items) == 0 {
return "No sessions (after filters).", nil
}