Enhance Design Document with Trigger Sources Configuration

- Added a new section detailing the configuration of trigger sources for AI members, including default settings and an example YAML configuration.
- Updated the execution flow diagram to reflect the configurable nature of trigger sources, incorporating a check for trigger enablement.
- Refactored the AI member configuration structure to include a dedicated triggers section, improving clarity and organization of the configuration options.
This commit is contained in:
Max 2026-01-13 08:47:54 +08:00
parent f7b8e970b2
commit ce7996b982

View file

@ -920,17 +920,44 @@ func (r *ExecutionRequest) CalculatePriority(config *ManagerConfig, agentConfig
## Execution Flow ## Execution Flow
### Trigger Sources Configuration
Trigger sources can be configured per AI member. All triggers are **enabled by default**.
| Trigger Type | Config Field | Description | Default |
| ------------ | ---------------------------- | -------------------------------------- | ------- |
| Schedule | `triggers.schedule.enabled` | World Clock trigger (cron/interval) | `true` |
| Intervene | `triggers.intervene.enabled` | Human intervention trigger | `true` |
| Event | `triggers.event.enabled` | External event trigger (webhook, etc.) | `true` |
**Configuration Example:**
```yaml
agent_config:
triggers:
schedule: { enabled: true }
intervene: { enabled: true, actions: ["add_task", "pause"] }
event: { enabled: false }
schedule:
type: cron
expr: "0 9 * * 1-5"
tz: Asia/Shanghai
timeout: 30m
```
### Execution Flow Diagram (Mermaid) ### Execution Flow Diagram (Mermaid)
```mermaid ```mermaid
flowchart TB flowchart TB
subgraph Trigger["Trigger Sources"] subgraph Trigger["Trigger Sources (Configurable)"]
WC[/"World Clock<br/>(Schedule)"/] WC[/"World Clock<br/>(Schedule)<br/>triggers.schedule"/]
HI[/"Human Intervention<br/>(Intervene)"/] HI[/"Human Intervention<br/>(Intervene)<br/>triggers.intervene"/]
EV[/"External Events<br/>(Event)"/] EV[/"External Events<br/>(Event)<br/>triggers.event"/]
end end
subgraph Manager["Autonomous Agent Manager"] subgraph Manager["Autonomous Agent Manager"]
TriggerCheck{"Trigger<br/>Enabled?"}
Cache[("Agent Cache<br/>(Memory)")] Cache[("Agent Cache<br/>(Memory)")]
Check{Schedule Check<br/>& Dedup} Check{Schedule Check<br/>& Dedup}
Queue["Global Queue<br/>(Priority Sorted)"] Queue["Global Queue<br/>(Priority Sorted)"]
@ -990,10 +1017,12 @@ flowchart TB
Job[("Job System<br/>(Activity Monitor)")] Job[("Job System<br/>(Activity Monitor)")]
end end
%% Trigger to Manager %% Trigger to Manager (with trigger enabled check)
WC --> Cache WC --> TriggerCheck
HI --> Cache HI --> TriggerCheck
EV --> Cache EV --> TriggerCheck
TriggerCheck -->|Enabled| Cache
TriggerCheck -->|Disabled| X[/"Ignored"/]
Cache --> Check Cache --> Check
Check -->|Pass| Queue Check -->|Pass| Queue
Check -->|Duplicate/Skip| Cache Check -->|Duplicate/Skip| Cache
@ -1206,97 +1235,92 @@ Each Autonomous Agent executes the following standard flow when scheduling condi
### Agent Configuration (stored in team_members.agent_config) ### Agent Configuration (stored in team_members.agent_config)
```go ```go
// AgentConfig AI member configuration (stored in team_members.agent_config JSON field) // Config AI member configuration (stored in team_members.agent_config JSON field)
type AgentConfig struct { type Config struct {
// Scheduling configuration Triggers *Triggers `json:"triggers,omitempty"` // Trigger sources (all enabled by default)
Schedule *Schedule `json:"schedule"` Schedule *Schedule `json:"schedule,omitempty"` // Schedule config (for cron/interval)
Identity *Identity `json:"identity"` // Role & responsibilities
// Identity settings Quota *Quota `json:"quota"` // Concurrency quota
Identity *Identity `json:"identity"` PrivateKB *KB `json:"private_kb"` // Private knowledge base
SharedKB *KB `json:"shared_kb,omitempty"` // Shared knowledge base
// Concurrency quota Resources *Resources `json:"resources"` // Available assistants & tools
Concurrency *ConcurrencyConfig `json:"concurrency"` Delivery *Delivery `json:"delivery"` // Output delivery config
// Private knowledge base (Agent exclusive, for self-learning)
PrivateKB *PrivateKB `json:"private_kb"`
// Shared knowledge base (optional, team-shared knowledge)
SharedKB *SharedKB `json:"shared_kb,omitempty"`
// Available resources
Resources *Resources `json:"resources"`
// Delivery configuration
Delivery *Delivery `json:"delivery"`
} }
// ConcurrencyConfig concurrency quota configuration // Triggers trigger sources configuration (all enabled by default)
type ConcurrencyConfig struct { type Triggers struct {
MaxConcurrent int `json:"max_concurrent"` // Max concurrent executions for this member (default: 2) Schedule *Trigger `json:"schedule,omitempty"` // World Clock
QueueSize int `json:"queue_size"` // Queue size (default: 10) Intervene *Trigger `json:"intervene,omitempty"` // Human Intervention
Priority int `json:"priority"` // Scheduling priority (1-10, default: 5) Event *Trigger `json:"event,omitempty"` // External Events
} }
// Schedule scheduling configuration // Trigger single trigger configuration
type Trigger struct {
Enabled bool `json:"enabled"` // default: true
Actions []string `json:"actions,omitempty"` // Allowed actions (for intervene only)
}
// Quota concurrency quota
type Quota struct {
Max int `json:"max"` // Max concurrent (default: 2)
Queue int `json:"queue"` // Queue size (default: 10)
Priority int `json:"priority"` // Priority 1-10 (default: 5)
}
// Schedule timing configuration
type Schedule struct { type Schedule struct {
Type string `json:"type"` // cron | interval Type string `json:"type"` // cron | interval
Expression string `json:"expression"` // cron: "0 9 * * 1-5" or interval: "1h" Expr string `json:"expr"` // "0 9 * * 1-5" or "1h"
Timezone string `json:"timezone"` // Timezone TZ string `json:"tz"` // Timezone
MaxExecutionTime string `json:"max_execution_time"` // Max execution time Timeout string `json:"timeout"` // Max execution time
} }
// Identity identity settings // Identity role settings
type Identity struct { type Identity struct {
Role string `json:"role"` // Role name Role string `json:"role"` // Role name
Responsibilities []string `json:"responsibilities"` // Responsibility list Duties []string `json:"duties"` // Responsibilities
Constraints []string `json:"constraints"` // Constraints Rules []string `json:"rules"` // Constraints
} }
// PrivateKB Agent private knowledge base (auto-created, for self-learning) // KB knowledge base configuration
type PrivateKB struct { type KB struct {
CollectionID string `json:"collection_id"` // KB collection ID (auto-generated: agent_{agent_id}_kb) ID string `json:"id,omitempty"` // Collection ID (auto-gen for private)
Refs []string `json:"refs,omitempty"` // Referenced collections (for shared)
// Learning configuration Learning *Learn `json:"learn,omitempty"` // Learning config (for private)
Learning *LearningConfig `json:"learning,omitempty"`
} }
// LearningConfig learning configuration // Learn self-learning configuration
type LearningConfig struct { type Learn struct {
Enabled bool `json:"enabled"` // Enable self-learning On bool `json:"on"` // Enable learning
Categories []string `json:"categories"` // Learning categories: ["execution", "feedback", "insight"] Types []string `json:"types"` // ["execution", "feedback", "insight"]
RetentionDays int `json:"retention_days"` // Knowledge retention days, 0 means permanent Keep int `json:"keep"` // Retention days, 0 = forever
} }
// SharedKB shared knowledge base (optional, references team or global knowledge) // Resources available assistants & tools
type SharedKB struct {
Collections []string `json:"collections"` // Referenced KB collection list
}
// Resources available resources
type Resources struct { type Resources struct {
// Phase assistants (built-in or custom) // Phase agents (P0-P5)
Inspiration string `json:"inspiration"` // Inspiration Agent (Phase 0) P0 string `json:"p0"` // Inspiration
GoalGenerator string `json:"goal_generator"` // Goal generation assistant (Phase 1) P1 string `json:"p1"` // Goal Generator
TaskPlanner string `json:"task_planner"` // Task planning assistant (Phase 2) P2 string `json:"p2"` // Task Planner
Validator string `json:"validator"` // Result validation assistant (Phase 3) P3 string `json:"p3"` // Validator
Delivery string `json:"delivery"` // Delivery assistant (Phase 4) P4 string `json:"p4"` // Delivery
Learning string `json:"learning"` // Learning assistant (Phase 5) P5 string `json:"p5"` // Learning
// Execution resources // Execution resources
Assistants []string `json:"assistants"` // Callable assistant list Agents []string `json:"agents"` // Callable assistants
MCP []MCPServerConfig `json:"mcp"` // Callable MCP services MCP []MCP `json:"mcp"` // MCP services
} }
// MCPServerConfig MCP service configuration // MCP server configuration
type MCPServerConfig struct { type MCP struct {
ServerID string `json:"server_id"` ID string `json:"id"`
Tools []string `json:"tools"` // Available tools list, empty means all Tools []string `json:"tools,omitempty"` // empty = all
} }
// Delivery delivery configuration // Delivery output configuration
type Delivery struct { type Delivery struct {
Type string `json:"type"` // email | file | webhook | notification Type string `json:"type"` // email | file | webhook | notify
Config map[string]interface{} `json:"config"` // Type-specific configuration Opts map[string]interface{} `json:"opts"` // Type-specific options
} }
``` ```
@ -1626,46 +1650,46 @@ POST /api/teams/:team_id/members
"agent_id": "sales-bot", "agent_id": "sales-bot",
"role_id": "analyst", "role_id": "analyst",
"agent_config": { "agent_config": {
"triggers": {
"schedule": { "enabled": true },
"intervene": { "enabled": true },
"event": { "enabled": false }
},
"schedule": { "schedule": {
"type": "cron", "type": "cron",
"expression": "0 9 * * 1-5", "expr": "0 9 * * 1-5",
"timezone": "Asia/Shanghai", "tz": "Asia/Shanghai",
"max_execution_time": "30m" "timeout": "30m"
}, },
"identity": { "identity": {
"role": "Sales Analyst", "role": "Sales Analyst",
"responsibilities": ["Analyze sales data", "Generate weekly reports"], "duties": ["Analyze sales data", "Generate weekly reports"],
"constraints": ["Only access sales-related data"] "rules": ["Only access sales-related data"]
}, },
"concurrency": { "quota": {
"max_concurrent": 2, "max": 2,
"queue_size": 10, "queue": 10,
"priority": 5 "priority": 5
}, },
"private_kb": { "private_kb": {
"learning": { "learn": { "on": true, "types": ["execution", "feedback", "insight"], "keep": 90 }
"enabled": true,
"categories": ["execution", "feedback", "insight"],
"retention_days": 90
}
}, },
"shared_kb": { "shared_kb": {
"collections": ["sales-policies", "product-catalog"] "refs": ["sales-policies", "product-catalog"]
}, },
"resources": { "resources": {
"goal_generator": "__yao.goal-generator", "p0": "__yao.inspiration",
"task_planner": "__yao.task-planner", "p1": "__yao.goal-gen",
"validator": "__yao.validator", "p2": "__yao.task-plan",
"delivery": "__yao.report-generator", "p3": "__yao.validator",
"learning": "__yao.learning", "p4": "__yao.delivery",
"assistants": ["data-analyst", "chart-generator"], "p5": "__yao.learning",
"mcp": [ "agents": ["data-analyst", "chart-gen"],
{"server_id": "database", "tools": ["query"]} "mcp": [{ "id": "database", "tools": ["query"] }]
]
}, },
"delivery": { "delivery": {
"type": "email", "type": "email",
"config": {"recipients": ["manager@company.com"]} "opts": { "to": ["manager@company.com"] }
} }
} }
} }
@ -2204,61 +2228,56 @@ agent_config:
priority: 5 # Execution priority (affects queue sorting) priority: 5 # Execution priority (affects queue sorting)
``` ```
## Complete AgentConfig Structure ## Complete Config Structure
```go ```go
// AgentConfig AI member complete configuration // Config AI member complete configuration
type AgentConfig struct { type Config struct {
// Scheduling configuration Triggers *Triggers `json:"triggers,omitempty"` // Trigger sources (all enabled by default)
Schedule *Schedule `json:"schedule"` Schedule *Schedule `json:"schedule,omitempty"` // Timing config
Identity *Identity `json:"identity"` // Role & duties
// Identity settings Quota *Quota `json:"quota"` // Concurrency quota
Identity *Identity `json:"identity"` PrivateKB *KB `json:"private_kb"` // Private KB
SharedKB *KB `json:"shared_kb,omitempty"` // Shared KB refs
// Concurrency quota Resources *Resources `json:"resources"` // Agents & tools
Concurrency *ConcurrencyConfig `json:"concurrency"` Delivery *Delivery `json:"delivery"` // Output config
Input *Input `json:"input,omitempty"` // Input isolation
// Private knowledge base Events []Event `json:"events,omitempty"` // Event sources
PrivateKB *PrivateKB `json:"private_kb"` Monitor *Monitor `json:"monitor,omitempty"` // Monitoring
// Shared knowledge base
SharedKB *SharedKB `json:"shared_kb,omitempty"`
// Available resources
Resources *Resources `json:"resources"`
// Delivery configuration
Delivery *Delivery `json:"delivery"`
// Input configuration (isolation, strategies)
Input *InputConfig `json:"input,omitempty"`
// Event source configuration
EventSources []EventSource `json:"event_sources,omitempty"`
// Monitoring configuration
Monitoring *MonitoringConfig `json:"monitoring,omitempty"`
} }
// MonitoringConfig monitoring configuration // Triggers trigger sources (all enabled by default)
type MonitoringConfig struct { type Triggers struct {
Enabled bool `json:"enabled"` Schedule *Trigger `json:"schedule,omitempty"`
Alerts []AlertRule `json:"alerts,omitempty"` Intervene *Trigger `json:"intervene,omitempty"`
Event *Trigger `json:"event,omitempty"`
} }
// AlertRule alert rule definition // Trigger single trigger config
type AlertRule struct { type Trigger struct {
Name string `json:"name"` // Rule name Enabled bool `json:"enabled"`
Condition string `json:"condition"` // Trigger condition: "execution_failed" | "timeout" | "error_rate_high" Actions []string `json:"actions,omitempty"` // For intervene only
Threshold float64 `json:"threshold"` // Threshold value (e.g., error rate > 0.1)
Window string `json:"window"` // Time window (e.g., "1h", "24h")
Actions []AlertAction `json:"actions"` // Actions to take when triggered
Cooldown string `json:"cooldown"` // Cooldown period between alerts
} }
// AlertAction alert action // Monitor monitoring config
type AlertAction struct { type Monitor struct {
Type string `json:"type"` // "email" | "webhook" | "notification" On bool `json:"on"`
Config map[string]interface{} `json:"config"` // Action-specific configuration Alerts []Alert `json:"alerts,omitempty"`
}
// Alert rule definition
type Alert struct {
Name string `json:"name"` // Rule name
When string `json:"when"` // failed | timeout | error_rate
Value float64 `json:"value"` // Threshold
Window string `json:"window"` // 1h | 24h
Do []Action `json:"do"` // Actions
Cooldown string `json:"cooldown"` // Cooldown period
}
// Action alert action
type Action struct {
Type string `json:"type"` // email | webhook | notify
Opts map[string]interface{} `json:"opts"`
} }
``` ```