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
|
||||
result.Output = extractOutput(response)
|
||||
|
||||
// Validate result using asserter
|
||||
asserter := NewAsserter()
|
||||
// Validate result using asserter (with response for tool_called assertions)
|
||||
asserter := NewAsserter().WithResponse(response)
|
||||
passed, errMsg := asserter.Validate(tc, result.Output)
|
||||
if passed {
|
||||
result.Status = StatusPassed
|
||||
|
|
|
|||
|
|
@ -28,29 +28,43 @@ 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) {
|
||||
// Remove "scripts." prefix
|
||||
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, ".")
|
||||
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
|
||||
// assistantDir: expense
|
||||
// moduleName: setup
|
||||
// scriptPath: expense/src/setup.ts (or assistants/expense/src/setup.ts)
|
||||
// testPath: expense/src/setup_test.ts
|
||||
assistantDir := parts[0]
|
||||
moduleName := parts[1]
|
||||
// Build paths based on number of parts
|
||||
var basePaths []string
|
||||
var assistantDir, moduleName string
|
||||
|
||||
// Try different path patterns
|
||||
basePaths := []string{
|
||||
filepath.Join("assistants", assistantDir, "src"),
|
||||
filepath.Join(assistantDir, "src"),
|
||||
if len(parts) == 2 {
|
||||
// Format: scripts.expense.setup
|
||||
// assistantDir: expense
|
||||
// moduleName: setup
|
||||
assistantDir = parts[0]
|
||||
moduleName = parts[1]
|
||||
basePaths = []string{
|
||||
filepath.Join("assistants", 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
|
||||
|
|
|
|||
|
|
@ -363,12 +363,14 @@ func extractCollectionIDFromDocID(docID string) string {
|
|||
if len(parts) < 2 {
|
||||
return ""
|
||||
}
|
||||
// First part contains prefix_collection_id
|
||||
prefix := parts[0]
|
||||
// Find the first underscore to skip the prefix
|
||||
idx := strings.Index(prefix, "_")
|
||||
if idx == -1 {
|
||||
return prefix
|
||||
}
|
||||
return prefix[idx+1:]
|
||||
|
||||
return parts[0]
|
||||
// // First part contains prefix_collection_id
|
||||
// prefix := parts[0]
|
||||
// // Find the first underscore to skip the prefix
|
||||
// idx := strings.Index(prefix, "_")
|
||||
// if idx == -1 {
|
||||
// return prefix
|
||||
// }
|
||||
// return prefix[idx+1:]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue