Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

KeyError: 'tables' when listing agents with SQL skills created via CREATE AGENT

未关闭
#201 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
python
领域
api

调研方向

从 skills.py 中 SQLSkill.from_json() 附近开始,然后跟踪 server.agents.list() 使用的 agents.py Agent.from_json() 路径。使用 SQL skill 包含 include_tables 的 agent 重现该问题,并验证列出 agents 时能够处理所报告的 skill JSON,而不会引发 KeyError: 'tables'。

由索引模型根据 Issue 内容生成。

描述

My Environment

  • Python version: 3.12.11
  • Operating system: Linux 6.12.12-061212-generic (Ubuntu-based)
  • Mindsdb Python SDK version: 3.4.4
  • Additional info if applicable: MindsDB Cloud instance, self hosted at mindsdb.openpolis.io

When attempting to list agents using server.agents.list(), the SDK throws a KeyError: 'tables' for agents that have SQL skills created through the SQL interface.

Steps to Reproduce:

  1. Create an agent using SQL with table references:
CREATE AGENT agent_001
USING
    model = {
        "provider": "google",
        "model_name": "gemini-2.0-flash",
        "api_key": "your_api_key"
    },
    data = {
         "tables": ["sales_manager_data.public.prospects_details", "sales_manager_data.public.call_summaries"]
    },
    prompt_template='
        sales_manager_data.public.prospects_details stores prospects data
        sales_manager_data.public.call_summaries stores calls from companies data
    ';
  1. Try to list agents via Python SDK:
import mindsdb_sdk
server = mindsdb_sdk.connect('https://your-instance.com', login='user', password='pass')
agents = server.agents.list()  # This throws KeyError: 'tables'

Error Details:

Traceback (most recent call last):
  File "<string>", line 16, in <module>
  File "/path/to/mindsdb_sdk/agents.py", line 233, in list
    return [Agent.from_json(agent, self) for agent in data]
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/mindsdb_sdk/agents.py", line 203, in from_json
    [Skill.from_json(skill) for skill in json['skills']],
     ^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/mindsdb_sdk/skills.py", line 57, in from_json
    return SQLSkill(name, params['tables'], params['database'], params.get('description', ''))
                          ~~~~~~^^^^^^^^^^
KeyError: 'tables'

Root Cause Analysis:

When agents are created via SQL, MindsDB stores the table information in the skill params as include_tables,
but the SDK's SQLSkill.from_json() method expects the key to be tables.

Actual skill JSON structure from MindsDB:

{
  "type": "sql",
  "params": {
    "database": null,
    "description": "Auto-generated SQL skill for agent agent_001",
    "include_tables": [
      "sales_manager_data.public.prospects_details", 
      "sales_manager_data.public.call_summaries"
    ],
    "knowledge_base_database": "mindsdb",
    "type": "sql"
  }
}

Expected by SDK (skills.py:57):

return SQLSkill(name, params['tables'], params['database'], params.get('description', ''))

Suggested Fix:

The SQLSkill.from_json() method should handle both tables and include_tables keys:

# In skills.py around line 57
tables = params.get('tables') or params.get('include_tables', [])
return SQLSkill(name, tables, params['database'], params.get('description', ''))

This appears to be a version compatibility issue between how MindsDB server stores agent skills and how the SDK expects to parse them.

主要语言
Python
星标
44
派生
16
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

mindsdb/mindsdb_python_sdk 的其他 Issue

查看 mindsdb/mindsdb_python_sdk 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。