Skip to content

Check if the content is empty?#1843

Open
liuanping wants to merge 1 commit intoHKUDS:mainfrom
liuanping:nanobot-fix
Open

Check if the content is empty?#1843
liuanping wants to merge 1 commit intoHKUDS:mainfrom
liuanping:nanobot-fix

Conversation

@liuanping
Copy link
Copy Markdown

_apply_cache_control 方法中处理 system 消息 content 非字符串的逻辑:
else:
new_content = list(content)
new_content[-1] = {**new_content[-1], "cache_control": {"type": "ephemeral"}}
system 消息的 content 是空列表([]),new_content[-1] 会直接抛出 IndexError: list index out of range 异常,导致整个 LLM 请求崩溃。

@liuanping
Copy link
Copy Markdown
Author

不知道是不是会出现类似错误,但是还是保险一点好,毕竟也存在一些用户会不知道怎么用改出了问题。

@chengyongru
Copy link
Copy Markdown
Collaborator

hi! @liuanping

这个修复有对应真实场景下的bug吗?

@chengyongru chengyongru added the question Further information is requested label Mar 11, 2026
@liuanping
Copy link
Copy Markdown
Author

hi! @liuanping

这个修复有对应真实场景下的bug吗?

还没有,代码看到感觉有可能有问题,所以建议保护下。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

question Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants