Repository navigation
Expand file tree
/
Copy pathexecution.go
More file actions
45 lines (40 loc) · 1.56 KB
/
Copy pathexecution.go
File metadata and controls
45 lines (40 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package mcode
import (
"fmt"
"os"
"strings"
"github.com/MiniMax-AI/OpenAgentCore/internal/agentdaemon/proto"
declaration "github.com/MiniMax-AI/OpenAgentCore/internal/harnessconfig/mcode"
)
func validateExecutionRequest(req proto.PromptRequestPayload) error {
if !req.DisableExecutionEnvironment || req.AgentStateKey == "" || req.LocalEnvironment != nil || req.RequireExistingNativeSession {
return fmt.Errorf("mcode: unsupported execution configuration")
}
if req.ExecutionControls == nil || req.ExecutionControls.OutputFormat != nil {
return fmt.Errorf("mcode: unsupported execution controls")
}
if err := declaration.Declaration.ValidateExecutionControls(req.ExecutionControls); err != nil {
return err
}
if !req.DisableSubagents {
if req.MaxConcurrentSubagents == nil || *req.MaxConcurrentSubagents < 1 {
return fmt.Errorf("mcode: Subagent concurrency limit is required")
}
if _, _, err := subagentReader(); err != nil {
return err
}
}
return nil
}
// Harness children use the daemon user's ordinary environment.
func executionEnvironment() []string { return os.Environ() }
// ACP joins text blocks with "\n\n" and parses slash commands only from a
// single block. A second, empty block keeps input that starts with "/" as user
// text; any other input is sent as one block so the model sees it unchanged.
func promptContent(text string) []map[string]string {
content := []map[string]string{{"type": "text", "text": text}}
if strings.HasPrefix(text, "/") {
content = append(content, map[string]string{"type": "text", "text": ""})
}
return content
}