This commit is contained in:
lpf
2026-02-19 10:00:59 +08:00
parent 27c718def9
commit 1f38852f49
14 changed files with 201 additions and 148 deletions

View File

@@ -84,7 +84,7 @@ func (t *MemorySearchTool) Execute(ctx context.Context, args map[string]interfac
resultsChan := make(chan []searchResult, len(files))
var wg sync.WaitGroup
// 并发搜索所有文件
// Search all files concurrently
for _, file := range files {
wg.Add(1)
go func(f string) {
@@ -96,7 +96,7 @@ func (t *MemorySearchTool) Execute(ctx context.Context, args map[string]interfac
}(file)
}
// 异步关闭通道
// Close channel asynchronously
go func() {
wg.Wait()
close(resultsChan)

View File

@@ -119,7 +119,7 @@ func (t *ExecTool) Execute(ctx context.Context, args map[string]interface{}) (st
}
func (t *ExecTool) executeInSandbox(ctx context.Context, command, cwd string) (string, error) {
// 实现 Docker 沙箱执行逻辑
// Execute command inside Docker sandbox
absCwd, _ := filepath.Abs(cwd)
dockerArgs := []string{
"run", "--rm",

View File

@@ -89,11 +89,11 @@ func (sm *SubagentManager) runTask(ctx context.Context, task *SubagentTask) {
_ = sm.orc.MarkTaskRunning(task.PipelineID, task.PipelineTask)
}
// 1. 独立 Agent 逻辑:支持递归工具调用
// 这里简单实现:通过共享 AgentLoop 的逻辑来实现 full subagent 能力
// 但目前 subagent.go 不方便反向依赖 agent 包,我们暂时通过 Inject 方式解决
// 1. Independent agent logic: supports recursive tool calling.
// This lightweight approach reuses AgentLoop logic for full subagent capability.
// subagent.go cannot depend on agent package inversely, so use function injection.
// 如果没有注入 RunFunc则退化为简单的一步 Chat
// Fall back to one-shot chat when RunFunc is not injected.
if sm.runFunc != nil {
result, err := sm.runFunc(ctx, task.Task, task.OriginChannel, task.OriginChatID)
sm.mu.Lock()
@@ -112,7 +112,7 @@ func (sm *SubagentManager) runTask(ctx context.Context, task *SubagentTask) {
}
sm.mu.Unlock()
} else {
// 原有的 One-shot 逻辑
// Original one-shot logic
messages := []providers.Message{
{
Role: "system",
@@ -145,7 +145,7 @@ func (sm *SubagentManager) runTask(ctx context.Context, task *SubagentTask) {
sm.mu.Unlock()
}
// 2. 结果广播 (原有逻辑保持)
// 2. Result broadcast (keep existing behavior)
if sm.bus != nil {
prefix := "Task completed"
if task.Label != "" {