0Pricing
Claude Architect · บทเรียน

หลีกเลี่ยงเครื่องมือที่ทับซ้อนกัน

เครื่องมือที่กำกวมและทับซ้อนกันทำให้จัดเส้นทางผิด

หลีกเลี่ยงเครื่องมือที่ทับซ้อนกัน เป็นบทเรียน Claude Architect ฟรีบน CoddyKit นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Claude Architect และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Claude Architect มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Why Routing Goes Wrong

When you give Claude a set of tools, the model has to pick the right one for each step. It does this by reading the tool descriptions, not by guessing from clever names.

If two tools sound like they do the same job, Claude faces a coin flip. Sometimes it picks the right one, sometimes the wrong one. This is called misrouting, and it is one of the most common reasons a well-built agent behaves unpredictably in production.

In this lesson you will learn how overlapping, ambiguous tools cause misrouting, and how to design clean, non-overlapping tools that route reliably.

Descriptions Are the Selection Mechanism

The key fact to internalize: tool descriptions are the primary selection mechanism. The model reads each description and chooses the tool whose stated purpose best matches the current task.

A good description includes:

  • Purpose — what the tool does
  • Return values — what it gives back
  • Input formats — with concrete examples
  • Edge cases and applicability boundaries — when NOT to use it

When two descriptions blur together, the boundaries disappear, and Claude can no longer tell them apart.

What Overlap Looks Like

Here is a classic overlapping pair. Both tools claim to fetch order information, with vague descriptions that do not draw a clear line between them.

Ask yourself: if a user says "where is my package?", which tool should Claude call? The descriptions give no way to decide, so the model will sometimes pick the wrong one.

tools = [
    {
        "name": "lookup_order",
        "description": "Get order info.",
        "input_schema": {
            "type": "object",
            "properties": {"order_id": {"type": "string"}},
            "required": ["order_id"],
        },
    },
    {
        "name": "get_order_details",
        "description": "Retrieve details about an order.",
        "input_schema": {
            "type": "object",
            "properties": {"id": {"type": "string"}},
            "required": ["id"],
        },
    },
]

The Cost of Misrouting

Misrouting is not a cosmetic problem. In an agentic loop, one wrong tool call cascades:

  • The wrong tool returns the wrong shape of data, or an error.
  • Claude tries to recover, burning extra turns and tokens.
  • Preconditions get skipped — for example, calling process_refund down a path that never verified the customer's identity.

In the Customer Support scenario, tools like get_customer, lookup_order, process_refund, and escalate_to_human each have a distinct job. Blur any two and the whole flow becomes unreliable.

Fix 1 — One Tool, One Job

The cleanest fix for overlap is often to collapse duplicates into a single, well-described tool. If two tools really do the same thing, you do not need both.

Notice how the description now states purpose, return values, input format with an example, and an explicit boundary about what it does NOT do.

tools = [
    {
        "name": "lookup_order",
        "description": (
            "Retrieve the full status and line items of a SINGLE order by its "
            "order ID. Returns: status, items, tracking number, and dates. "
            "Input: order_id as a string like 'ORD-10482'. "
            "Use this for any 'where is my order' or order-status question. "
            "Does NOT look up customers by name or email — use get_customer for that."
        ),
        "input_schema": {
            "type": "object",
            "properties": {
                "order_id": {
                    "type": "string",
                    "description": "Order ID, e.g. 'ORD-10482'",
                }
            },
            "required": ["order_id"],
        },
    }
]

Fix 2 — Draw Explicit Boundaries

Sometimes you genuinely need two related tools. The trick is to make each description state when to use it AND when not to, pointing at its sibling.

Here a customer-lookup tool and an order-lookup tool sit side by side, but each names the boundary so Claude can route correctly every time.

tools = [
    {
        "name": "get_customer",
        "description": (
            "Find a customer record by email or phone. Returns the verified "
            "customer_id, name, and account tier. Use FIRST to verify identity "
            "before any account action. Does NOT return order details — "
            "pass the customer_id to lookup_order for that."
        ),
    },
    {
        "name": "lookup_order",
        "description": (
            "Retrieve one order by order_id. Returns status, items, tracking. "
            "Requires a known order_id. To find which orders belong to a "
            "customer, call get_customer first. Does NOT verify identity."
        ),
    },
]

Fix 3 — Scope Tools to the Role

Overlap often appears because an agent is handed every tool in the system. The discipline is to scope tools to the role: give each agent only the tools its job needs.

A refund agent does not need a code-search tool. A research subagent does not need process_refund. In a multi-agent system, each AgentDefinition carries its own allowed_tools following least privilege — fewer tools means fewer chances to confuse two of them.

from claude_agent_sdk import AgentDefinition

refund_agent = AgentDefinition(
    name="refund_agent",
    description="Handles verified refund requests only.",
    system_prompt="Verify identity, then process eligible refunds.",
    # Least privilege: no order-search, no escalation overlap
    allowed_tools=["get_customer", "lookup_order", "process_refund"],
)

Keep the Toolset Small

Overlap and bloat are the same disease. The fact sheet is precise about counts:

  • 4–5 tools per agent is optimal for reliable selection.
  • 18+ tools degrades selection reliability sharply.

More tools means more surface area for two descriptions to brush against each other. If you find yourself past five tools, ask whether some belong to a different agent's role, or whether two of them are really one tool wearing two names.

Resources Are Not Tools

A subtle source of overlap: people wrap read-only reference data as a Tool when it should be an MCP Resource.

In MCP, the primitives are distinct:

  • Tools — actions (do something, possibly with side effects)
  • Resources — read-only data and context, like schemas or catalogs
  • Prompts — reusable templates

If a product catalog is exposed as a Resource instead of yet another get_* tool, your action tools stay few and distinct, and routing stays clean.

{
  "resources": [
    {
      "uri": "catalog://products",
      "name": "Product Catalog",
      "description": "Read-only product list with prices and SKUs.",
      "mimeType": "application/json"
    }
  ],
  "tools": [
    { "name": "create_order", "description": "Place an order for a given SKU and quantity." }
  ]
}

Differentiate by Boundary, Not by Name

A tempting but weak fix is to just rename tools — lookup_order_v2, get_order_fast, order_helper. Remember: Claude selects on descriptions, not names. A prettier name with the same vague description routes no better.

The real differentiator is the applicability boundary: a sentence in each description that says exactly when this tool wins and the other loses. Boundaries are what eliminate the coin flip.

A Quick Audit Checklist

Before you ship a toolset, run this audit:

  • For every pair of tools, can you state one input where it is unambiguous which to call? If not, merge or clarify.
  • Does each description name purpose, returns, input example, and an explicit “do NOT use when…” boundary?
  • Is each tool actually used by this agent's role, or did it leak in?
  • Are you at 4–5 tools, not 18+?
  • Is any read-only data better modeled as a Resource?

Passing this audit is the difference between an agent that routes reliably and one that quietly misroutes under load.

Quick Check

A support agent intermittently calls the wrong tool when users ask about orders. Apply what you learned.

Recap — Clean Tools Route Reliably

Key takeaways:

  • Descriptions, not names, drive selection. Ambiguous or overlapping descriptions cause misrouting.
  • One tool, one job. Merge true duplicates; otherwise give each tool an explicit “when to use / do NOT use” boundary that points at its sibling.
  • Scope to the role. Give each agent only the tools it needs (least privilege), and keep to 4–5 tools — 18+ degrades reliability.
  • Model read-only data as a Resource, not as another tool, to keep action tools few and distinct.
  • A great description names purpose, return values, input formats with examples, and applicability boundaries.

Design tools so the right choice is obvious, and your agent routes correctly every time.

คำถามที่พบบ่อย

บทเรียน “หลีกเลี่ยงเครื่องมือที่ทับซ้อนกัน” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “หลีกเลี่ยงเครื่องมือที่ทับซ้อนกัน” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Claude Architect ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Claude Architect มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “หลีกเลี่ยงเครื่องมือที่ทับซ้อนกัน”

เครื่องมือที่กำกวมและทับซ้อนกันทำให้จัดเส้นทางผิด คุณปฏิบัติ Claude Architect ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Claude Architect หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Claude Architect บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน

บทเรียน “หลีกเลี่ยงเครื่องมือที่ทับซ้อนกัน” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Claude Architect นี้ได้ไหม

ได้ บทเรียน Claude Architect ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. คำอธิบายเครื่องมือเป็นตัวขับเคลื่อนการเลือก
  2. โครงสร้างของคำอธิบายที่ดี
  3. หลีกเลี่ยงเครื่องมือที่ทับซ้อนกัน
  4. รูปแบบและตัวอย่าง input
← กลับไปที่ Claude Architect