帮助 AI 智能体使用 API 的两种方法(以及为什么你需要两者兼顾)

文章分析了 AI 编程智能体在与 API 交互时频繁失败的原因,识别出两种主要的失败模式:缺乏“内部经验”(弃用的方法、反模式)以及缺乏环境上下文(实际的 Schema、现有数据)。为了解决这些问题,文章提倡一种结合方法。首先,'skill.md'(由 Mintlify 提出)作为静态简报文件,为智能体提供文档中经常缺失的决策表和“坑点”。其次,'REPL-first MCP'(由 Armin Ronacher 提出)为智能体提供了一个有状态的 Python Shell,用于动态检查系统状态。通过结合使用这两者,智能体可以避免诸如使用弃用函数或猜测集合名称等“无聊”的失败,从而让开发者专注于更高层级的逻辑和语义准确性。




Two Approaches to Helping AI Agents Use Your API (And Why You Need Both)

AI coding agents fail in predictable ways when working with APIs. Two recent approaches from Mintlify and Armin Ronacher attack different failure modes. Understanding both reveals something useful about how agents should interact with developer tools.

Two Failure Modes

When an agent writes code against your API, it can fail because:

  1. It doesn’t know what it doesn’t know. The agent uses a deprecated method, misconfigures a parameter, or violates a constraint that isn’t obvious from type signatures. This is the “known unknowns” problem: things the API maintainer knows but the agent doesn’t.

  2. It can’t discover what exists. The agent doesn’t know what collections exist, what the payload schema looks like, or what data is actually in the system. This is the “unknown unknowns” problem: things specific to the user’s environment that no amount of documentation covers.

Most agent failures trace back to one of these. Mintlify’s skill.md addresses the first. Armin Ronacher’s REPL-first MCP addresses the second.

What skill.md Gives You

Michael Ryaboy and the team at Mintlify introduced skill.md: a static file that ships knowledge to the agent before it writes code. It’s not documentation. It’s a briefing. Decision tables, not tutorials. Gotchas, not explanations.

For Qdrant, a skill.md might include:

Decision Table
Want to... Do
Search client.query_points(col, query=vec, limit=10)
Filter Add query_filter=Filter(must=[...])
Hybrid prefetch dense+sparse, FusionQuery(Fusion.RRF)
Multi-tenant create_payload_index(field, is_tenant=True)
Gotchas
query_points not search - all search variants deprecated

Never one collection per user - use is_tenant=True index

BM25 requires Modifier.IDF - sparse search needs it

This prevents the agent from using client.search() (deprecated), creating a collection per user (anti-pattern), or misconfiguring sparse vectors (common mistake). These are known failure modes that documentation alone doesn’t prevent. Agents don’t read docs the way humans do.

What REPL-First MCP Gives You

Armin Ronacher, creator of Flask and now building Earendil, proposed a different approach. Instead of 30 narrow MCP tools, give the agent a Python shell with the SDK pre-configured:

# Agent can just run this
collections = client.get_collections()
print([c.name for c in collections.collections])

# Then inspect the actual schema
info = client.get_collection("products")
print(info.config.params.vectors)

The agent discovers what exists by asking the system directly. No tool for “list collections.” No tool for “get schema.” Just Python. The REPL handles the unknown unknowns: what’s actually in your Qdrant instance right now.

Why Neither Alone Works

skill.md without REPL: The agent knows how to use query_points but not what to query. It guesses collection names. It assumes payload fields. It writes syntactically correct code that fails at runtime.

REPL without skill.md: The agent can discover what exists but still uses deprecated methods. It creates collections with wrong configurations. It makes the same mistakes it would have made without the REPL, just with more information about the data.

Together, the agent workflow looks like this:

Agent Workflow
1. Read skill.md
"Use query_points, not search"

"Never one collection per user"

"BM25 needs Modifier.IDF"
2. Use REPL
client.get_collections()

client.scroll("products", limit=1)

# Now knows: collection exists, payload has "category" field
3. Write code
Correct method + correct collection + correct filter fields

The skill.md prevents known mistakes. The REPL handles environment-specific discovery. Both failure modes addressed.

Implementation

The skill.md is just a file you drop into your project. The REPL is an MCP tool. A minimal implementation:

@server.call_tool()
async def handle_tool_call(name: str, arguments: dict):
    if name == "qdrant-repl":
        code = arguments["code"]
        # client, models pre-configured in repl_globals
        try:
            result = eval(compile(code, "<repl>", "eval"), repl_globals)
            return repr(result) if result else "(ok)"
        except SyntaxError:
            exec(compile(code, "<repl>", "exec"), repl_globals)
            return "(executed)"

State persists between calls. The agent builds up context incrementally.

The Broader Pattern

This isn’t specific to Qdrant. Any API with:

  • Deprecated methods or migration paths → needs skill.md
  • User-specific state (databases, collections, schemas) → needs REPL

The two approaches complement because they address orthogonal problems. Static knowledge for static mistakes. Dynamic access for dynamic discovery.

Most developer tools need both.

This Doesn’t Make It Easy

Adding skill.md and a REPL doesn’t mean agents suddenly work flawlessly. They still hallucinate. They still misunderstand requirements. They still write code that technically runs but doesn’t do what you wanted.

What these tools do is eliminate unnecessary failures. The agent won’t fail because it used a deprecated method. That’s a solved problem with skill.md. It won’t fail because it guessed a collection name. The REPL lets it check. But it can still fail because it misunderstood what you meant by “similar products” or because the embedding model you’re using doesn’t capture the semantics you care about.

You might ask: why not just pull context from docs automatically? Tools that generate context from documentation solve a real problem, but they solve a different one. Auto-generated context gives you API surface area. A skill.md gives you judgment. “Don’t create one collection per user” isn’t in any API reference. “BM25 is broken without Modifier.IDF” isn’t in any tutorial. Those lessons come from production pain, not documentation. The two approaches aren’t in competition. Use both.

The goal isn’t perfect agents. The goal is agents that fail for interesting reasons instead of boring ones. Deprecated API calls are boring failures. Wrong collection names are boring failures. Skill.md and REPL handle the boring stuff so you can focus on the hard problems.

Try It

The Qdrant skill.md is 94 lines. It’s a minimal example you can use, update, and configure for your own setup.

Drop it into your project:

mkdir -p .claude/skills/qdrant
curl -o .claude/skills/qdrant/skill.md \
  https://raw.githubusercontent.com/thierrypdamiba/skill-md/main/README.md

For the REPL side, configure the Qdrant MCP server with REPL. It’s a fork of the official MCP server that adds a qdrant-repl tool giving agents a stateful Python shell with a pre-configured QdrantClient. The agent gets both the briefing and the toolkit.

Your agents will stop using deprecated methods. They’ll stop guessing collection names. They’ll write correct queries on the first attempt. Not because they got smarter, but because they got the right information at the right time.

We’d love to hear how you’re using Qdrant with AI agents. What’s working, what’s breaking, what patterns you’ve found. If you want to stay ahead of the curve on this stuff, sign up for our newsletter. And thanks to you, our readers, for pushing us to make the developer experience better for everyone.


AI 前线

Sam Altman 与开发者的一小时:GPT-5 的坦白、招聘放缓、以及 2026 年最担心的事

2026-1-31 19:26:20

AI 前线

瓦解全球最大的住宅代理网络

2026-1-31 19:26:25

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索