-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
area:coreThe bug / feature is about astrbot's core, backendThe bug / feature is about astrbot's core, backendbugSomething isn't workingSomething isn't workingpriority: p0will fix asapwill fix asap
Description
What happened / 发生了什么
在使用支持视觉的模型(如gemini-3-flash)接入 QQ 聊天时,发现 Token 消耗异常巨大。 具体表现为:
用户发送一张图片,Bot 正常回复(消耗正常)。
用户随后发送纯文本消息(如“你好”)。
此时 Token 消耗瞬间飙升至 100,000 ~ 500,000+。
经过排查代码 astrbot/core/provider/sources/openai_source.py,发现 AstrBot 将图片转为 Base64 存入了数据库的历史记录(Context)。在构建后续对话的 payload 时,系统会把历史记录中巨大的 Base64 字符串再次完整发送给 LLM。即使我只发了一个字,Bot 也会被迫“重读”之前的所有高清图片数据,导致成本极高。
Reproduce / 如何复现?
配置 OpenAI Provider,使用支持 Vision 的模型。
设置 max_context_length (上下文轮数) 为 3 或更高。
在对话中发送一张图片。
接着发送一条简短的文本消息。
查看控制台日志或 Token 消耗统计,会发现第二次请求的 Prompt Token 包含了之前图片的 Base64 数据,导致消耗巨大。
AstrBot version, deployment method (e.g., Windows Docker Desktop deployment), provider used, and messaging platform used. / AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器
AstrBot版本v4.10.5
部署方式Linux
消息平台适配器:OneBotV11
OS
Linux
Logs / 报错日志
Are you willing to submit a PR? / 你愿意提交 PR 吗?
- Yes!
Code of Conduct
- I have read and agree to abide by the project's Code of Conduct。
Metadata
Metadata
Assignees
Labels
area:coreThe bug / feature is about astrbot's core, backendThe bug / feature is about astrbot's core, backendbugSomething isn't workingSomething isn't workingpriority: p0will fix asapwill fix asap