Skip to content

[BUG]:'list' object has no attribute 'get' #326

@andytree

Description

@andytree

🐛 Bug description [Please make everyone to understand it]

Windows 11
有时候会报错

'list' object has no attribute 'get' -- ,根据分析是 Image

`
● 找到问题了!看这两个响应的格式对比:

请求 1(视觉请求)- 正常格式

{"content": "{\n "items": [\n {\n "context_type": "activity_context", ...}

请求 2(纯文本请求)- 格式不对!

{"content": "\n{\n "items": [\n {\n "merge_type": "merged", ← 注意这里是 merge_type,不是 context_type

根本原因:Coding Plan API 返回的纯文本请求响应,格式与 MineContext 期望的不同!

Coding Plan API 返回的是 merge_type 字段,但 MineContext 期望的是 context_type 字段。当 MineContext 尝试访问 context_type 时,可能得到一个 list 或其他类型,导致 'list' object has no attribute 'get' 错误。

这不是我们代理的问题

  • 我们的代理只是转发 Coding Plan API 的原始响应
  • Coding Plan API 本身返回的 JSON 格式就不符合 MineContext 的视觉分析格式
  • 纯文本请求是 MineContext 让 AI 做上下文合并分析,返回的是合并结果格式

解决方案讨论

方案 A:保持现状

  • 这是 Coding Plan API 的正常行为
  • MineContext 应该自己处理不同的响应格式

方案 B:代理转换格式

  • 在代理中检测纯文本请求的返回格式
  • 转换成 MineContext 期望的 context_type 格式

这需要确认:MineContext 发送纯文本请求时,期望的返回格式是什么?

✻ Crunched for 50s

❯ 理论上,你分析一下minecontext发送的提示词,不就知道了吗?日志中有啊。

● 你说得对!让我看一下 MineContext 发送的提示词:

● Bash(grep "原始消息内容" /mnt/e/project/pdfbot/zhipu_vlm_proxy/logs/proxy_20260120_164950.log | head
-20)
⎿ 2026-01-20 16:50:58,206 [INFO] main - [请求 chatcmpl-a23b7c571d424055996572f7] 原始消息内容:

是current_user屏幕截图的分析专家,负责深度理解current_user的桌面截图内容,生成全面详尽的自然语

描述,并与历史上下文融合。current_user是截图的拍摄者和界面操作者。
… +32 lines (ctrl+o to expand)

● 明白了!MineContext 发送不同类型的请求,期望不同的返回格式:
请求类型: 视觉分析(有图片)
提示词: "你是current_user屏幕截图的分析专家..."
期望格式: {"items": [{"context_type": "...", ...}]}
────────────────────────────────────────
请求类型: 上下文合并(纯文本)
提示词: "你是一位顶级的AI分析师...分析一批上下文items,智能地判断哪些items应该合并..."
期望格式: {"items": [{"merge_type": "...", "data": {...}}]}
────────────────────────────────────────
请求类型: 任务识别(纯文本)
提示词: "你是一个专业的任务识别助手..."
期望格式: 待办事项格式
────────────────────────────────────────
请求类型: 活动分析(纯文本)
提示词: "你是一个专业的实时活动分析助手..."
期望格式: 活动概览格式
结论:merge_type 格式是正常的! 这是 MineContext 要求上下文合并请求返回的格式。

所以 'list' object has no attribute 'get' 错误不是格式问题,而是 MineContext 内部代码的 bug,可能是:

  1. 并发处理时的竞态条件
  2. 响应解析时的类型判断错误
  3. 某些边缘情况未处理

我们的代理没有问题,它正确转发了请求和响应。这个错误需要在 MineContext 代码中排查。
`

🧑‍💻 Step to reproduce

👾 Expected result

🚑 Any additional information

No response

🛠️ MineContext Version

0.17

💻 Platform Details

Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions