Skip to content

[Bug] enable_social_context_injection 启用时会导致 LLM 工具调用(Tool Call)失效 #84

@beren929

Description

@beren929

Plugin Version

Next-2.1.0

AstrBot Version

v4.22.2

Database Type

SQLite (default)

Operating System

Linux

Bug Description

当 Social_Context_Settings.enable_social_context_injection 设置为 true 时,插件会向 LLM 请求中注入回复风格指令(如"详细解释型"、"直接回答型"、"引导思考型"等),这些指令会强烈诱导模型直接生成文字回复,导致模型不再调用已注册的工具(Tool Call),搜索等功能完全失效。

Steps to Reproduce

启用 astrbot_plugin_self_learning,保持 enable_social_context_injection: true
同时启用 astrbot-web-searcher 插件
向 BOT 发送需要搜索的消息,例如"搜索今天新闻"
观察 LLM 返回结果中 finish_reason 为 stop,tool_calls 为空列表 []
将 enable_social_context_injection 改为 false 后重启,同样消息可正常触发 finish_reason='tool_calls'

Expected Behavior

期望的修复方式
建议在 Social_Context_Settings 中增加一个独立开关,例如:
json"disable_reply_mode_injection_when_tools_present": true
或在检测到当前请求已注册工具时,跳过回复模式相关的指令注入,仅保留情感、好感度等不影响工具调用判断的上下文注入。

Error Logs

日志关键信息
问题出现时:
finish_reason='stop', tool_calls=[]
prompt_tokens=16000~22000
关闭后正常:
finish_reason='tool_calls'
tool_calls=[ChatCompletionMessageFunctionToolCall(...name='web_search_tavily'...)]
根本原因分析
Hook 执行顺序为:
astrbot_plugin_self_learning - inject_diversity_to_llm_request  ← 注入回复风格指令
astrbot_plugin_livingmemory - handle_memory_recall
astrbot-web-searcher - edit_web_search_tools                    ← 最后才挂载工具
self_learning 注入的 [HIDDEN_INSTRUCTION_START] 指令块中包含"推荐回复模式:详细解释型"等内容,使模型倾向于直接生成回答,而非判断是否需要调用工具。

Relevant Configuration

Additional Context

环境信息
AstrBot 版本:v4.22.2
插件:astrbot_plugin_self_learning
模型:本地 qwen3.5-35b(gguf 量化,通过 LM Studio 部署)
工具调用插件:astrbot-web-searcher(Tavily)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions