KeyError: 'tables' when listing agents with SQL skills created via CREATE AGENT
还没有人认领这个 Issue。
评估
调研方向
从 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:
- 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
';
- 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
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
mindsdb/mindsdb_python_sdk 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 45/100
mindsdb/mindsdb_python_sdk#210 · 3 条评论 ·
-
难度 4/5 3-5 天 新手友好度 15/100
mindsdb/mindsdb_python_sdk#203 · 1 条评论 ·
-
难度 3/5 1-2 天 新手友好度 25/100
mindsdb/mindsdb_python_sdk#190 ·
-
难度 4/5 3-5 天 新手友好度 35/100
mindsdb/mindsdb_python_sdk#186 ·
-
难度 3/5 1-2 天 新手友好度 35/100
mindsdb/mindsdb_python_sdk#184 · 1 条评论 ·
查看 mindsdb/mindsdb_python_sdk 的全部 Issue
相似的 Issue
-
难度 1/5 1-3 小时 新手友好度 87/100
adri0/scadustats#128 ·
维护者通常 1 天内回复
-
`TIMESTAMP`, `TIMESTAMP_NTZ`, `TINYINT` and the other `TypeDecorator`s don't declare `python_type`未关闭
难度 2/5 1-3 小时 新手友好度 78/100
-
RPBC未关闭awaiting policy acceptance precheck-passed
难度 1/5 1 小时以内 新手友好度 78/100
Bioconductor/BiocContributions#240 · 1 条评论 ·
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
documentation good first issue launch
难度 2/5 1-3 小时 新手友好度 83/100
FlologixAI/etchwork#4 ·