Skip to content

上下文压缩bug。导致系统无法运行。 #3726

@jermeyhu

Description

@jermeyhu

Bug Description

nanobot-gateway  | 2026-05-10 17:13:55.990 | INFO     | nanobot.agent.loop:_process_message:765 - Processing message from qq:***: 你好
nanobot-gateway  | 2026-05-10 17:14:11.733 | DEBUG    | nanobot.agent.memory:maybe_consolidate_by_tokens:570 - Token consolidation: no safe boundary for qq:***(round 0)
nanobot-gateway  | 2026-05-10 17:14:20.732 | DEBUG    | nanobot.agent.loop:after_iteration:114 - LLM usage: prompt=0 completion=0 cached=0
nanobot-gateway  | 2026-05-10 17:14:20.733 | ERROR    | nanobot.agent.loop:_run_agent_loop:481 - LLM returned error: Error: {'message': 'invalid params, context window exceeds limit (2013)', 'type': 'bad_request_error', 'param': '', 'code': None}
nanobot-gateway  | 2026-05-10 17:14:20.734 | INFO     | nanobot.agent.loop:_process_message:876 - Response to qq:***: Error: {'message': 'invalid params, context window exceeds limit (2013)', 'type': 'bad_request_error', 'param': '', 'cod...
nanobot-gateway  | 2026-05-10 17:14:21.141 | INFO     | nanobot.agent.memory:maybe_consolidate_by_tokens:591 - Token consolidation round 0 for qq:***: 383404/65536 via tiktoken, chunk=2 msgs

Steps to Reproduce

错误日志在上面。
我应该是聊了很久的天。生成了一些ppt 和报告文件。
然后使用了/new 命令。
就出现了上面的错误。
直到我把 history.jsonl 这个文件删除。才恢复了。

看日志出现了:Token consolidation round 0 for qq:***: 383404/65536 via tiktoken, chunk=2 msgs
检查了记忆文件。 history.jsonl 文件有2M 还是多大。反正蛮大的。

Expected Behavior

程序正常运行。不会报错。

Relevant Logs

nanobot Version

0.1.5.post2

Python Version

3.12

Operating System

Docker

Channel / Platform

QQ

LLM Provider

OpenAI

Configuration (Optional)

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions