mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-24 00:12:00 +00:00
移除仓库中的商业数据:删掉 21 个相关用例,其余标识符脱敏
这个仓库是公开的,而历史里带着一份客户 BI 仓的逐字转储:ANALYTICS(原 schema 名)下 53 张视图名、实测行数、字段结构表,外加一句写明取数方是谁 的注脚。还有一处把真人姓名和工作单位写进了检查脚本的断言里。这些都不是 化名,是能直接拿去对库的东西。 按"含敏感词的测试直接删"处理,共 21 个用例: test_agent_tool_loop.py 整个文件(2 个,agent 工具循环的真图验收) test_conversations.py 9 个(会话 CRUD、历史文本、上下文进 prompt) test_datasource.py 5 个(探查失败的实情、候选 schema 提示) test_copilot_context.py 3 个(数据源摘要的限定名) test_review.py 1 个(干净运行无信号) test_tool_args.py 1 个(call_tool 端到端) 辅助函数和产品源码不在"测试"之列,改为脱敏——否则删一个 _seeded 会连带 带走 8 个没被点名的用例。标识符一律换成中性名:shop→shop、 ANALYTICS→ANALYTICS、prod_shop→prod_shop、真人姓名→张三。 markdown 样本里那两条不是改标识符能解决的:行数、字段结构、业务域描述 整段都是客户的。换成同构的合成内容——领域换了,markdown 构造逐项对齐 (标题层级、有序/无序列表、三列表、带 inline code 的单元格、引用块), 渲染器的覆盖面没有变窄。check-stream 里那句"用的是真实输出"跟着改成实话。 286 → 265 passed,差值正好是删掉的 21 个。tsc 干净,decode / stream / ui 三个 check 不回归。 历史里的同一批内容另行用 git filter-repo 处理。
This commit is contained in:
@@ -172,40 +172,6 @@ async def test_schema_tool_args_are_validated_too(source) -> None:
|
||||
assert payload["table"] == "orders" and note is not None
|
||||
|
||||
|
||||
async def test_call_tool_end_to_end_on_the_path_that_broke(source) -> None:
|
||||
"""走 call_tool 这个真实入口(工具节点和设置页的"试一下"都走它)。
|
||||
|
||||
以前这条路径对动态工具是裸 `**args` 展开的,报错止步于 TypeError;
|
||||
现在参数名能被纠正、纠正这件事能通过 on_fix 说出去。
|
||||
"""
|
||||
from app.db.base import SessionLocal
|
||||
from app.db.models import DataSource
|
||||
from app.tools.registry import call_tool
|
||||
|
||||
async with SessionLocal() as session:
|
||||
session.add(DataSource(
|
||||
name="shop", kind="sqlite", database=source.database,
|
||||
readonly=True, description="测试库", options={}, schema_cache={}, enabled=True,
|
||||
))
|
||||
await session.commit()
|
||||
|
||||
notes: list[str] = []
|
||||
async with SessionLocal() as session:
|
||||
out = await call_tool(
|
||||
"db_query__shop", {"query": "SELECT COUNT(*) AS c FROM orders"},
|
||||
ToolContext(), session=session, on_fix=notes.append,
|
||||
)
|
||||
assert "5" in str(out)
|
||||
# 跑通了,但配置里那个错的参数名还在,必须留下痕迹而不是安静地把事办了
|
||||
assert len(notes) == 1 and "sql" in notes[0]
|
||||
|
||||
async with SessionLocal() as session:
|
||||
with pytest.raises(ToolArgsError) as e:
|
||||
await call_tool("db_query__shop", {"foo": 1, "bar": 2}, ToolContext(), session=session)
|
||||
assert "sql" in str(e.value)
|
||||
assert "unexpected keyword argument" not in str(e.value)
|
||||
|
||||
|
||||
def test_tools_without_a_pydantic_schema_are_let_through() -> None:
|
||||
"""MCP 这类工具的 args_schema 可能是一份 JSON Schema dict,校验不了就放行。"""
|
||||
assert args_model_of(SimpleNamespace(args_schema={"type": "object"})) is None
|
||||
|
||||
Reference in New Issue
Block a user