ข้อมูลกำกับการลองใหม่และผลลัพธ์บางส่วน
errorCategory, isRetryable, attempted_query, partials
ข้อมูลกำกับการลองใหม่และผลลัพธ์บางส่วน เป็นบทเรียน Claude Architect ฟรีบน CoddyKit นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Claude Architect และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Claude Architect มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
Why Error Shape Matters
When a tool or MCP server fails, the model has to decide what to do next. A generic status like "Operation failed" gives it nothing to reason about, so the only safe move is to abort or guess.
A structured error turns a dead end into a decision: should we retry, route around the failure, or escalate to a human? In this lesson you'll learn the four metadata fields that make that possible: errorCategory, isRetryable, attempted_query, and partial_results.
The isError Flag
Every structured MCP error starts with one boolean: isError: true. This is the unambiguous signal that the tool result is a failure, not data.
Without it, the model may treat an error message as a legitimate answer and happily summarize the failure as if it were a result. The flag is the gate that activates all the recovery logic that follows.
tool_result = {
"isError": True,
"errorCategory": "transient",
"isRetryable": True,
"message": "Upstream timeout contacting orders DB",
"attempted_query": "SELECT * FROM orders WHERE id='A-2291'",
"partial_results": []
}errorCategory: Four Buckets
errorCategory classifies why the call failed so the model can route intelligently. The four standard categories are:
- transient — a temporary fault (timeout, rate limit). Likely worth retrying.
- validation — the input was malformed. Fix the request, don't blindly retry.
- business — a domain rule blocked it (e.g. order already shipped).
- permission — the caller isn't authorized. Retrying won't help; escalate or re-auth.
The category drives the strategy; it doesn't make the decision alone.
isRetryable: The Action Hint
isRetryable is the explicit yes/no on whether retrying could possibly succeed. It works with the category but encodes a sharper signal.
A transient timeout is usually isRetryable: true. A validation error is isRetryable: false — retrying the same bad input just fails again. Crucially, this lets the subagent recover transient faults locally instead of bubbling every hiccup up to the coordinator.
if result.get("isError"):
if result["isRetryable"] and attempt < max_attempts:
attempt += 1
continue # recover locally in the subagent
else:
escalate(result) # non-recoverable: pass it up with contextDon't Confuse Failure with Empty
A subtle but exam-critical distinction: an access FAILURE is not the same as a valid EMPTY result.
isError: true+transient→ the query couldn't run. Consider a retry.isError: false+ empty list → the query ran fine and there are genuinely no matches. Retrying is pointless and wasteful.
Generic errors blur this line. Structured metadata keeps "I couldn't look" cleanly separated from "I looked, nothing's there."
attempted_query: Make Retry Possible
attempted_query records exactly what the tool tried to do — the SQL, the API call, the search string. This serves two jobs:
- It lets the model retry with feedback: send the original intent plus the error so a corrected query can be formed.
- It feeds provenance — you keep a claim-to-source trail of what was actually asked.
Remember: retry-with-feedback fixes format/structural mistakes. If the information is simply absent from the source, no amount of re-querying helps.
{
"isError": True,
"errorCategory": "validation",
"isRetryable": True,
"message": "Unknown column 'order_no'; did you mean 'order_id'?",
"attempted_query": "SELECT * FROM orders WHERE order_no='A-2291'",
"partial_results": []
}partial_results: Don't Throw Away Good Data
When a multi-step or multi-source operation fails halfway, the work done before the failure is still valuable. partial_results carries it forward.
Imagine a research subagent that queried five sources and the fifth timed out. Returning the four successful results plus the error means the coordinator can keep going — instead of discarding everything because one leg failed. Never abort the whole workflow on a single failure.
{
"isError": True,
"errorCategory": "transient",
"isRetryable": True,
"message": "Source 5 (vendor API) timed out after 4 of 5 sources",
"attempted_query": "fetch pricing from [s1..s5]",
"partial_results": [
{"source": "s1", "price": 19.0},
{"source": "s2", "price": 21.5},
{"source": "s3", "price": 18.9},
{"source": "s4", "price": 20.0}
]
}Recover Locally, Escalate with Context
The metadata enables a clean two-tier strategy in hub-and-spoke systems:
- Recover transient faults locally inside the subagent — retry the
isRetryableones quietly. - Escalate non-recoverable failures up to the coordinator, carrying the full structured context: failure type, attempted query, and any partial results.
The coordinator handles errors and routes. But it can only route well if the subagent hands it a structured signal instead of a bare exception or silence.
Designing the Error Schema
If you define the error as structured output, apply the schema rules carefully. Mark a field required only if it is always present. partial_results is often empty or absent on a hard failure — so don't force it as required, or the model may fabricate entries to satisfy the schema.
For errorCategory, use an enum with an "other" value plus a free-text detail field. That keeps classification clean today and extensible for failure modes you haven't met yet.
error_schema = {
"type": "object",
"properties": {
"isError": {"type": "boolean"},
"errorCategory": {
"enum": ["transient", "validation",
"business", "permission", "other"]
},
"categoryDetail": {"type": "string"},
"isRetryable": {"type": "boolean"},
"attempted_query": {"type": "string"},
"partial_results": {"type": "array"}
},
"required": ["isError", "errorCategory", "isRetryable"]
}Hooks for the Failures That Cost Money
Metadata guides the model probabilistically (~90%). When a failure has financial, legal, or safety consequences, that isn't enough.
Use a PostToolUse hook to intercept the tool result before the model sees it, and enforce policy deterministically (100%). For example: if errorCategory is permission on a refund tool, block any retry and force escalation — don't leave it to the prompt to behave.
# PostToolUse hook: deterministic guard on structured errors
def post_tool_use(result):
if result.get("isError") and \
result["errorCategory"] == "permission":
return block_and_escalate(
reason=result["message"],
attempted=result["attempted_query"])
return resultAnti-Pattern: Silent Suppression
The worst thing you can do with a failure is hide it. Two failure modes to avoid:
- Silent suppression — swallowing the error and returning an empty or made-up result. Now the model can't tell a real "no matches" from a broken query.
- Aborting the whole workflow on one failed leg — throwing away every partial result.
Structured errors are the cure for both: they surface the failure and preserve what succeeded.
Quick Check: Routing a Partial Failure
Apply what you've learned to a real multi-agent scenario.
Recap: The Recovery Toolkit
Structured errors turn failures into routable decisions:
- isError — the gate that activates recovery logic.
- errorCategory — transient / validation / business / permission (+ "other") sets the strategy.
- isRetryable — the explicit retry hint; recover transient faults locally.
- attempted_query — enables retry-with-feedback and provenance (won't help if info is truly absent).
- partial_results — carry forward good data; never abort the whole workflow on one failure.
Mark only always-present fields as required, guard money/legal/safety failures with deterministic hooks, and never suppress errors silently. That's architect-grade error handling.
คำถามที่พบบ่อย
บทเรียน “ข้อมูลกำกับการลองใหม่และผลลัพธ์บางส่วน” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “ข้อมูลกำกับการลองใหม่และผลลัพธ์บางส่วน” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Claude Architect ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Claude Architect มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “ข้อมูลกำกับการลองใหม่และผลลัพธ์บางส่วน”
errorCategory, isRetryable, attempted_query, partials คุณปฏิบัติ Claude Architect ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Claude Architect หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Claude Architect บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน
บทเรียน “ข้อมูลกำกับการลองใหม่และผลลัพธ์บางส่วน” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Claude Architect นี้ได้ไหม
ได้ บทเรียน Claude Architect ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- แฟล็ก isError
- หมวดหมู่ข้อผิดพลาด
- ข้อมูลกำกับการลองใหม่และผลลัพธ์บางส่วน
- รูปแบบต่อต้าน: ข้อความข้อผิดพลาดทั่วไป