Merge branch 'fix-sleep-tool' into 'master'

Fix sleep tool

See merge request iesqa/httprunner!120
This commit is contained in:
李隆
2025-07-04 13:08:21 +00:00
4 changed files with 10 additions and 9 deletions

View File

@@ -167,7 +167,7 @@ func (dExt *XTDriver) StartToGoal(ctx context.Context, prompt string, opts ...op
log.Error().Err(err).
Str("action", toolCall.Function.Name).
Msg("invoke tool call failed")
subActionResult.Error = err
subActionResult.Error = err.Error()
return err
}
return nil
@@ -400,7 +400,7 @@ type SubActionResult struct {
Arguments interface{} `json:"arguments,omitempty"` // arguments passed to the sub-action
StartTime int64 `json:"start_time"` // sub-action start time
Elapsed int64 `json:"elapsed_ms"` // sub-action elapsed time(ms)
Error error `json:"error,omitempty"` // sub-action execution result
Error string `json:"error,omitempty"` // sub-action execution result
SessionData
}

View File

@@ -75,9 +75,9 @@ func (t *ToolSleep) Implement() server.ToolHandlerFunc {
case <-time.After(duration):
// Normal completion
case <-ctx.Done():
// Interrupted by context cancellation (e.g., CTRL+C)
log.Warn().Msg("sleep interrupted by cancellation")
return nil, fmt.Errorf("sleep interrupted: %w", ctx.Err())
// Interrupted by context cancellation (interrupt signal, timeout, time limit)
log.Info().Msg("sleep interrupted by context cancellation")
// Don't return error - let the upper layer handle timeout/time limit logic
}
message := fmt.Sprintf("Successfully slept for %v seconds", actualSeconds)
@@ -157,9 +157,9 @@ func (t *ToolSleepMS) Implement() server.ToolHandlerFunc {
case <-time.After(duration):
// Normal completion
case <-ctx.Done():
// Interrupted by context cancellation (e.g., CTRL+C)
log.Warn().Msg("sleep interrupted by cancellation")
return nil, fmt.Errorf("sleep interrupted: %w", ctx.Err())
// Interrupted by context cancellation (interrupt signal, timeout, time limit)
log.Info().Msg("sleep interrupted by context cancellation")
// Don't return error - let the upper layer handle timeout/time limit logic
}
message := fmt.Sprintf("Successfully slept for %d milliseconds", actualMilliseconds)