Skip to content

[Bug] 未来任务重复请求多次 LLM API 并一直发送内容直到30条 #9412

Description

@TGSAN

What happened / 发生了什么

设置的未来任务,每天定时发一条消息,之前偶尔遇到发送多条。结果今天突然会在发送消息后继续发送提示词相同,但是内容不同的消息,直到发了30遍才停下来。
因为发送了太多消息(因为设置了三个定时任务,所以总计刷了90遍才停),然后因为有群友让AI回溯群聊历史,结果AstrBot有用的日志都被群聊日志工具洗掉了。
但是好在AxonHub(LLM 服务器)上有较完整的原始返回数据记录。

Reproduce / 如何复现?

正常环境很难复现,需要长期观察。但是应该可以mock LLM数据来复现。

AstrBot version, deployment method (e.g., Windows Docker Desktop deployment), provider used, and messaging platform used. / AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器

Windows Server 2022 / AstrBot Launcher 0.3.8 / AstrBot v4.26.7

OS

Windows

Logs / 报错日志

QQ号用000000代替
第一次 LLM 回应:

{
  "id": "msg_011CdRhQLg1FqzDbd6iFJB9h",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "tool_calls": [
          {
            "id": "toolu_01L1ZsWaWNbSR4AF5cu9iUo3",
            "type": "function",
            "function": {
              "name": "send_message_to_user",
              "arguments": "{\"messages\":[{\"type\":\"mention_user\",\"mention_user_id\":\"000000\"},{\"type\":\"plain\",\"text\":\" 起床啦~都九点半了,昨晚熬到一点多的家伙该醒醒了喵(\"}]}"
            },
            "index": 0
          }
        ],
        "reasoning_content": ""
      },
      "finish_reason": "tool_calls",
      "logprobs": null
    }
  ],
  "object": "chat.completion",
  "created": 0,
  "model": "azure/claude-fable-5",
  "usage": {
    "prompt_tokens": 32837,
    "completion_tokens": 170,
    "total_tokens": 33007,
    "prompt_tokens_details": {
      "audio_tokens": 0,
      "cached_tokens": 0
    },
    "completion_tokens_details": {
      "audio_tokens": 0,
      "reasoning_tokens": 0,
      "accepted_prediction_tokens": 0,
      "rejected_prediction_tokens": 0
    }
  }
}

第二次:

{
  "id": "msg_011CdRhRnmB8gAwgELAVqY1T",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "到点叫ayase起床啦~",
        "tool_calls": [
          {
            "id": "toolu_01BgdgDgRYPhfZDSn8fWp1hH",
            "type": "function",
            "function": {
              "name": "send_message_to_user",
              "arguments": "{\"messages\":[{\"type\":\"mention_user\",\"mention_user_id\":\"000000\"},{\"type\":\"plain\",\"text\":\" 起床啦起床啦~都九点半了,昨晚熬到一点多的家伙快醒醒喵(\"}]}"
            },
            "index": 0
          }
        ],
        "reasoning_content": ""
      },
      "finish_reason": "tool_calls",
      "logprobs": null
    }
  ],
  "object": "chat.completion",
  "created": 0,
  "model": "azure/claude-fable-5",
  "usage": {
    "prompt_tokens": 32862,
    "completion_tokens": 196,
    "total_tokens": 33058,
    "prompt_tokens_details": {
      "audio_tokens": 0,
      "cached_tokens": 0
    },
    "completion_tokens_details": {
      "audio_tokens": 0,
      "reasoning_tokens": 0,
      "accepted_prediction_tokens": 0,
      "rejected_prediction_tokens": 0
    }
  }
}

中间几十次就忽略了
最后一次(30次):

{
  "id": "msg_011CdRiAvdttVCzdA4Mhpje1",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "时间到啦,该去群里叫ayase起床了~",
        "tool_calls": [
          {
            "id": "toolu_01WNBQuX7ixigBxGoVLr2BEW",
            "type": "function",
            "function": {
              "name": "send_message_to_user",
              "arguments": "{\"messages\":[{\"type\":\"mention_user\",\"mention_user_id\":\"000000\"},{\"type\":\"plain\",\"text\":\" 九点半啦~昨晚熬到一点多的家伙该起床了喵(≧∇≦)ノ\"}]}"
            },
            "index": 0
          }
        ],
        "reasoning_content": ""
      },
      "finish_reason": "tool_calls",
      "logprobs": null
    }
  ],
  "object": "chat.completion",
  "created": 0,
  "model": "azure/claude-fable-5",
  "usage": {
    "prompt_tokens": 33512,
    "completion_tokens": 228,
    "total_tokens": 33740,
    "prompt_tokens_details": {
      "audio_tokens": 0,
      "cached_tokens": 0
    },
    "completion_tokens_details": {
      "audio_tokens": 0,
      "reasoning_tokens": 0,
      "accepted_prediction_tokens": 0,
      "rejected_prediction_tokens": 0
    }
  }
}

Are you willing to submit a PR? / 你愿意提交 PR 吗?

  • Yes!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:coreThe bug / feature is about astrbot's core, backendarea:providerThe bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner.bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions