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

@@ -63,7 +63,7 @@
"actions": [
{
"method": "start_to_goal",
"params": "每天数独是一款逻辑推理游戏,玩家需要通过推理来确定黄色方块的所在位置,以下是游戏的基本规则说明:\n1、方块外面的数字代表所在那一行或一列的黄色方块数量。\n2、初始状态为白色方块选择正确后变为黄色方块选择错误后变为红底的 X。\n3、如果同一行或列有两个数字则至少需要一个白底 X 分割它们作为间隔。\n4、如果数字与格子最大数相同时该列或行必然全都是黄色方块。\n5、只能点击白色方块不要重复点击同一个方块。\n\n请严格按照以上游戏规则开始游戏\n",
"params": "每天数独是一款逻辑推理游戏,玩家需要通过推理来确定黄色方块的所在位置,以下是游戏的基本规则说明:\n1、方块外面的数字代表所在那一行或一列的黄色方块数量。\n2、初始状态为白色方块选择正确后变为黄色方块选择错误后变为红底的 X。\n3、如果同一行或列有两个数字则至少需要一个白底 X 分割它们作为间隔。\n4、如果数字与格子最大数相同时该列或行必然全都是黄色方块。\n5、只能点击白色方块不要重复点击同一个方块。\n6、若出现「桌面入口」弹窗则直接关闭。\n\n请严格按照以上游戏规则开始游戏\n",
"options": {
"time_limit": 300,
"pre_mark_operation": true

View File

@@ -16,6 +16,7 @@ func TestGameSudoku(t *testing.T) {
3、如果同一行或列有两个数字则至少需要一个白底 X 分割它们作为间隔。
4、如果数字与格子最大数相同时该列或行必然全都是黄色方块。
5、只能点击白色方块不要重复点击同一个方块。
6、若出现「桌面入口」弹窗则直接关闭。
请严格按照以上游戏规则,开始游戏
`

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)