feat: implement UI automation test history isolation

- Add ResetHistory option to PlanningOptions and ActionOptions
- Implement task completion detection with isTaskFinished() method
- Add executeActions() method to separate action execution logic
- Modify ConversationHistory.Clear() to completely clear all messages including system message
- Refactor StartToGoal() to automatically reset history on first attempt
- Add WithResetHistory() option function for consistent API
- Consolidate test files into driver_ext_ai_test.go with comprehensive test coverage
This commit is contained in:
lilong.129
2025-06-06 15:29:42 +08:00
parent 6e1bd5bbe2
commit b642ea004e
6 changed files with 306 additions and 48 deletions
+7
View File
@@ -23,6 +23,7 @@ type PlanningOptions struct {
UserInstruction string `json:"user_instruction"` // append to system prompt
Message *schema.Message `json:"message"`
Size types.Size `json:"size"`
ResetHistory bool `json:"reset_history"` // whether to reset conversation history before planning
}
// PlanningResult represents the result of planning
@@ -85,6 +86,12 @@ func (p *Planner) Call(ctx context.Context, opts *PlanningOptions) (*PlanningRes
return nil, errors.Wrap(err, "validate planning parameters failed")
}
// reset conversation history if requested
if opts.ResetHistory {
p.history.Clear() // Clear everything including system message for complete isolation
log.Info().Msg("conversation history reset for planner")
}
// prepare prompt
if len(p.history) == 0 && opts.UserInstruction != "" {
// add system message