agentscope-ai / agentscope-ai/AgentTeams
[补充#561] Task CRD设计参考-如何在manager缺失情况下实现跨team任务协同 || [Supplement #561] Task CRD design reference-how to achieve cross-team task collaboration in the absence of manager
- Lenguaje dominante
- Go
- Estrellas
- 5.6k
- Forks
- 692
- Merge medio
- 5 d 4 h
- PR fusionados (30 d)
- 23
Descripción
之前沟通过,目前 跨 Team Task无法实现,跨实例 Task更无法实现,
因此需要实现一个更完整的 Task 架构,通过和CC的沟通,提供如下 作为参考
```
// hiclaw-controller/api/v1beta2/task_types.go
package v1beta2
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// Task 表示一个 Agent 任务
type Task struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec TaskSpec `json:"spec"`
Status TaskStatus `json:"status,omitempty"`
}
type TaskSpec struct {
// 任务意图
Intent TaskIntent `json:"intent"`
// 委托信息
Delegation TaskDelegation `json:"delegation"`
// 约束条件
Constraints TaskConstraints `json:"constraints,omitempty"`
// 数据面配置
DataPlane DataPlaneConfig `json:"dataPlane,omitempty"`
// 回调配置
Callbacks TaskCallbacks `json:"callbacks,omitempty"`
}
type TaskIntent struct {
// 任务类型
Type string `json:"type"` // code_generation, analysis, research, etc.
// 任务描述
Description string `json:"description"`
// 任务参数
Parameters map[string]interface{} `json:"parameters,omitempty"`
}
type TaskDelegation struct {
// 委托来源
From DelegateInfo `json:"from"`
// 委托目标
To DelegateInfo `json:"to"`
// 是否跨实例
CrossInstance bool `json:"crossInstance,omitempty"`
// 目标实例(如果跨实例)
TargetInstance string `json:"targetInstance,omitempty"`
}
type DelegateInfo struct {
// 类型:human, agent
Type string `json:"type"`
// ID
ID string `json:"id"`
// Matrix ID(如果是 agent)
MXID string `json:"mxid,omitempty"`
}
type TaskConstraints struct {
// 截止时间
Deadline *metav1.Time `json:"deadline,omitempty"`
// 预算
Budget TaskBudget `json:"budget,omitempty"`
// 数据访问范围
DataAccess []DataAccessSpec `json:"dataAccess,omitempty"`
}
type TaskBudget struct {
MaxTokens int `json:"maxTokens,omitempty"`
MaxCost float64 `json:"maxCost,omitempty"`
Currency string `json:"currency,omitempty"`
}
type DataAccessSpec struct {
Type string `json:"type"` // minio, mcp, http
Bucket string `json:"bucket,omitempty"`
Prefix string `json:"prefix,omitempty"`
Server string `json:"server,omitempty"`
Permission string `json:"permission"` // read, write
}
type DataPlaneConfig struct {
// 类型:matrix, webrtc, http
Type string `json:"type"`
// WebRTC 配置(如果 type = webrtc)
WebRTC WebRTCConfig `json:"webrtc,omitempty"`
}
type WebRTCConfig struct {
// SDP Offer
Offer string `json:"offer,omitempty"`
// SDP Answer
Answer string `json:"answer,omitempty"`
}
type TaskCallbacks struct {
// 完成回调
OnComplete CallbackSpec `json:"onComplete,omitempty"`
// 进度回调
OnProgress CallbackSpec `json:"onProgress,omitempty"`
// 错误回调
OnError CallbackSpec `json:"onError,omitempty"`
}
type CallbackSpec struct {
// 类型:matrix, http, webhook
Type string `json:"type"`
// Room ID(如果 type = matrix)
RoomID string `json:"roomId,omitempty"`
// URL(如果 type = http/webhook)
URL string `json:"url,omitempty"`
// 间隔(如果用于进度)
Interval string `json:"interval,omitempty"`
}
type TaskStatus struct {
// 阶段:Pending, Running, Completed, Failed, Cancelled
Phase string `json:"phase,omitempty"`
// 分配给的 Agent
AssignedTo string `json:"assignedTo,omitempty"`
// 开始时间
StartTime *metav1.Time `json:"startTime,omitempty"`
// 完成时间
CompletionTime *metav1.Time `json:"completionTime,omitempty"`
// 进度(0-100)
Progress int `json:"progress,omitempty"`
// 结果
Result map[string]interface{} `json:"result,omitempty"`
// 产出文件
Artifacts []string `json:"artifacts,omitempty"`
// 错误信息
Error string `json:"error,omitempty"`
// 消息
Message string `json:"message,omitempty"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type TaskList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Task `json:"items"`
}
```
---
We have communicated before that currently cross-Team Tasks cannot be implemented, and cross-instance Tasks cannot be implemented.
Therefore, it is necessary to implement a more complete Task architecture. Through communication with CC, the following is provided as a reference.
```
// hiclaw-controller/api/v1beta2/task_types.go
package v1beta2
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// Task represents an Agent task
type Task struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec TaskSpec `json:"spec"`
Status TaskStatus `json:"status,omitempty"`
}
type TaskSpec struct {
//Task intent
Intent TaskIntent `json:"intent"`
//Delegation information
Delegation TaskDelegation `json:"delegation"`
// Constraints
Constraints TaskConstraints `json:"constraints,omitempty"`
//Data plane configuration
DataPlane DataPlaneConfig `json:"dataPlane,omitempty"`
//Callback configuration
Callbacks TaskCallbacks `json:"callbacks,omitempty"`
}
typeTaskIntent struct {
//Task type
Type string `json:"type"` // code_generation, analysis, research, etc.
//Task description
Description string `json:"description"`
//Task parameters
Parameters map[string]interface{} `json:"parameters,omitempty"`
}
type TaskDelegation struct {
// Commission source
From DelegateInfo `json:"from"`
// Delegate target
To DelegateInfo `json:"to"`
// Whether to cross instances
CrossInstance bool `json:"crossInstance,omitempty"`
// Target instance (if across instances)
TargetInstance string `json:"targetInstance,omitempty"`
}
type DelegateInfo struct {
// Type: human, agent
Type string `json:"type"`
//ID
ID string `json:"id"`
// Matrix ID (if agent)
MXID string `json:"mxid,omitempty"`
}
type TaskConstraints struct {
// Deadline
Deadline *metav1.Time `json:"deadline,omitempty"`
// budget
Budget TaskBudget `json:"budget,omitempty"`
//Data access scope
DataAccess []DataAccessSpec `json:"dataAccess,omitempty"`
}
type TaskBudget struct {
MaxTokens int `json:"maxTokens,omitempty"`
MaxCost float64 `json:"maxCost,omitempty"`
Currency string `json:"currency,omitempty"`
}
type DataAccessSpec struct {
Type string `json:"type"` // minio, mcp, http
Bucket string `json:"bucket,omitempty"`
Prefix string `json:"prefix,omitempty"`
Server string `json:"server,omitempty"`
Permission string `json:"permission"` // read, write
}
type DataPlaneConfig struct {
// Type: matrix, webrtc, http
Type string `json:"type"`
// WebRTC configuration (if type = webrtc)
WebRTC WebRTCConfig `json:"webrtc,omitempty"`
}
typeWebRTCConfig struct {
// SDP Offer
Offer string `json:"offer,omitempty"`
// SDP Answer
Answer string `json:"answer,omitempty"`
}
type TaskCallbacks struct {
//Complete callback
OnComplete CallbackSpec `json:"onComplete,omitempty"`
// progress callback
OnProgress CallbackSpec `json:"onProgress,omitempty"`
// error callback
OnError CallbackSpec `json:"onError,omitempty"`
}
type CallbackSpec struct {
// Type: matrix, http, webhook
Type string `json:"type"`
// Room ID (if type = matrix)
RoomID string `json:"roomId,omitempty"`
// URL (if type = http/webhook)
URL string `json:"url,omitempty"`
// interval (if used for progress)
Interval string `json:"interval,omitempty"`
}
type TaskStatus struct {
// Stages: Pending, Running, Completed, Failed, Canceled
Phase string `json:"phase,omitempty"`
// Agent assigned to
AssignedTo string `json:"assignedTo,omitempty"`
// start time
StartTime *metav1.Time `json:"startTime,omitempty"`
//Complete time
CompletionTime *metav1.Time `json:"completionTime,omitempty"`
// Progress (0-100)
Progress int `json:"progress,omitempty"`
// result
Result map[string]interface{} `json:"result,omitempty"`
//output file
Artifacts []string `json:"artifacts,omitempty"`
// error message
Error string `json:"error,omitempty"`
// Message
Message string `json:"message,omitempty"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type TaskList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Task `json:"items"`
}
```
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Evaluación
Este issue todavía no se ha evaluado.