Merge pull request #1413 from trheyi/main
Enhance Script Resolution Logic and Validation
This commit is contained in:
commit
2141ffe4f3
3 changed files with 40 additions and 24 deletions
|
|
@ -502,8 +502,8 @@ func (r *Executor) runSingleTest(ast *assistant.Assistant, tc *Case, agentID str
|
||||||
// Extract output
|
// Extract output
|
||||||
result.Output = extractOutput(response)
|
result.Output = extractOutput(response)
|
||||||
|
|
||||||
// Validate result using asserter
|
// Validate result using asserter (with response for tool_called assertions)
|
||||||
asserter := NewAsserter()
|
asserter := NewAsserter().WithResponse(response)
|
||||||
passed, errMsg := asserter.Validate(tc, result.Output)
|
passed, errMsg := asserter.Validate(tc, result.Output)
|
||||||
if passed {
|
if passed {
|
||||||
result.Status = StatusPassed
|
result.Status = StatusPassed
|
||||||
|
|
|
||||||
|
|
@ -28,30 +28,44 @@ func NewScriptRunner(opts *Options) *ScriptRunner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResolveScript resolves the script path from scripts.xxx.yyy format
|
// ResolveScript resolves the script path from scripts.xxx.yyy or scripts.xxx.yyy.zzz format
|
||||||
func ResolveScript(input string) (*ScriptInfo, error) {
|
func ResolveScript(input string) (*ScriptInfo, error) {
|
||||||
// Remove "scripts." prefix
|
// Remove "scripts." prefix
|
||||||
path := strings.TrimPrefix(input, "scripts.")
|
path := strings.TrimPrefix(input, "scripts.")
|
||||||
|
|
||||||
// Split into parts: "expense.setup" -> ["expense", "setup"]
|
// Split into parts:
|
||||||
|
// "expense.setup" -> ["expense", "setup"]
|
||||||
|
// "expense.submission.validation" -> ["expense", "submission", "validation"]
|
||||||
parts := strings.Split(path, ".")
|
parts := strings.Split(path, ".")
|
||||||
if len(parts) < 2 {
|
if len(parts) < 2 {
|
||||||
return nil, fmt.Errorf("invalid script path: %s (expected format: scripts.assistant.module)", input)
|
return nil, fmt.Errorf("invalid script path: %s (expected format: scripts.assistant.module or scripts.assistant.sub_agent.module)", input)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build paths
|
// Build paths based on number of parts
|
||||||
|
var basePaths []string
|
||||||
|
var assistantDir, moduleName string
|
||||||
|
|
||||||
|
if len(parts) == 2 {
|
||||||
|
// Format: scripts.expense.setup
|
||||||
// assistantDir: expense
|
// assistantDir: expense
|
||||||
// moduleName: setup
|
// moduleName: setup
|
||||||
// scriptPath: expense/src/setup.ts (or assistants/expense/src/setup.ts)
|
assistantDir = parts[0]
|
||||||
// testPath: expense/src/setup_test.ts
|
moduleName = parts[1]
|
||||||
assistantDir := parts[0]
|
basePaths = []string{
|
||||||
moduleName := parts[1]
|
|
||||||
|
|
||||||
// Try different path patterns
|
|
||||||
basePaths := []string{
|
|
||||||
filepath.Join("assistants", assistantDir, "src"),
|
filepath.Join("assistants", assistantDir, "src"),
|
||||||
filepath.Join(assistantDir, "src"),
|
filepath.Join(assistantDir, "src"),
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Format: scripts.expense.submission.validation (sub-agent)
|
||||||
|
// assistantDir: expense/submission (or expense.submission)
|
||||||
|
// moduleName: validation
|
||||||
|
assistantDir = strings.Join(parts[:len(parts)-1], "/")
|
||||||
|
moduleName = parts[len(parts)-1]
|
||||||
|
basePaths = []string{
|
||||||
|
filepath.Join("assistants", assistantDir, "src"),
|
||||||
|
filepath.Join(assistantDir, "src"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var scriptPath, testPath string
|
var scriptPath, testPath string
|
||||||
for _, basePath := range basePaths {
|
for _, basePath := range basePaths {
|
||||||
|
|
|
||||||
|
|
@ -363,12 +363,14 @@ func extractCollectionIDFromDocID(docID string) string {
|
||||||
if len(parts) < 2 {
|
if len(parts) < 2 {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
// First part contains prefix_collection_id
|
|
||||||
prefix := parts[0]
|
return parts[0]
|
||||||
// Find the first underscore to skip the prefix
|
// // First part contains prefix_collection_id
|
||||||
idx := strings.Index(prefix, "_")
|
// prefix := parts[0]
|
||||||
if idx == -1 {
|
// // Find the first underscore to skip the prefix
|
||||||
return prefix
|
// idx := strings.Index(prefix, "_")
|
||||||
}
|
// if idx == -1 {
|
||||||
return prefix[idx+1:]
|
// return prefix
|
||||||
|
// }
|
||||||
|
// return prefix[idx+1:]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue