ความเสี่ยงของการสรุปแบบค่อยเป็นค่อยไป
ตัวเลข เปอร์เซ็นต์ และวันที่จะคลุมเครือเมื่อถูกสรุป
ความเสี่ยงของการสรุปแบบค่อยเป็นค่อยไป เป็นบทเรียน Claude Architect ฟรีบน CoddyKit นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Claude Architect และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Claude Architect มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
Why Summaries Drift
Long-running agents can't keep every turn in the context window. A common fix is progressive summarization: periodically compress earlier messages into a shorter recap so the conversation keeps fitting.
It works for narrative flow. But it has a sharp failure mode for the Context Management & Reliability domain: when prose gets compressed, numbers, percentages and dates go vague. "$1,284.50 refunded on 2026-03-14" quietly becomes "a refund was issued recently."
What Actually Gets Lost
Summarization optimizes for gist, not precision. The model keeps the storyline and drops the exact tokens that carry transactional meaning.
- Amounts: "$4,999.00" → "a large charge"
- Percentages: "a 17.5% discount" → "a discount"
- Dates: "order placed 2026-01-09" → "earlier this year"
- IDs: "order #A-88231" → "the order"
These are exactly the facts downstream tools and policy checks depend on.
/compact Carries the Same Risk
In Claude Code, /compact compresses the running context to free up room — the same mechanism, the same risk. After a compaction, a stack trace's line numbers, a failing test's exact assertion, or a config value can come back fuzzy.
The fix isn't to avoid compaction; it's to make sure the precise facts you'll need later don't live only inside the part that gets compressed.
# Claude Code session: compaction is convenient but lossy
/compact # compresses earlier turns -> numbers/dates can become vague
# Safer: persist exact facts that must survive
/memory # write durable facts into CLAUDE.md before compactingThe Core Pattern: A Case Facts Block
The exam-grade fix is simple: pull transactional facts into a separate "case facts" block kept verbatim, outside the summary.
Summarize the conversational narrative freely — but maintain a structured, append-only block of exact values that is never passed through the summarizer. The summary keeps context cheap; the case-facts block keeps the numbers exact.
Structuring Case Facts
Keep the block machine-readable and verbatim. Each entry preserves the original value exactly as stated, with enough labeling to reuse it later.
This block is re-injected into the system prompt on every turn — remember the API keeps no server-side state, so you resend it as part of the full message history each request.
case_facts = {
"customer_id": "CUS-44190",
"order_id": "A-88231",
"order_date": "2026-01-09",
"order_total": "4999.00", # exact, never rounded
"discount_pct": "17.5",
"refund_amount": "1284.50",
"refund_date": "2026-03-14",
}
system = (
"You are a support agent.\n"
"## CASE FACTS (verbatim, authoritative)\n"
f"{json.dumps(case_facts, indent=2)}\n"
"## CONVERSATION SUMMARY (may be lossy)\n"
f"{rolling_summary}"
)Summarize Narrative, Preserve Facts
Split your context-management routine in two. When you compress, run the summarizer only over the dialogue, and leave the case-facts block untouched.
Order matters too: facts go near the top, the lossy summary lower down. The model attends to the start and end of context more than the middle (lost-in-the-middle), so authoritative numbers belong where attention is strongest.
def build_context(history, case_facts, max_dialogue_turns=8):
recent = history[-max_dialogue_turns:]
older = history[:-max_dialogue_turns]
# Compress ONLY the narrative; facts are excluded from summarization
summary = summarize(older) if older else ""
return {
"facts_block": case_facts, # verbatim, top of context
"summary": summary, # lossy, fine for narrative
"recent": recent,
}Extract Facts at Capture Time
Don't try to recover exact numbers after they've been summarized away — by then the source is gone. Capture them the moment they appear, straight from tool results.
Trim verbose tool output to the relevant fields before it enters history, but route the precise values you'll need into the case-facts block first. Use structured output (a tool call with a JSON Schema) so extraction is reliable, not a regex guess.
# After lookup_order returns, capture facts verbatim before trimming
order = tool_result["order"]
case_facts.update({
"order_id": order["id"],
"order_total": order["total"], # keep raw string/decimal
"order_date": order["created_at"],
})
# Now the full verbose payload can be trimmed/summarized safelyWhy Retry Won't Save You
A tempting reflex: if a later answer cites the wrong amount, just retry with feedback. But retry-with-feedback only fixes format, structural or arithmetic errors — you resend the original doc, the wrong output, and the exact validation error.
Once a number has been summarized out of the context entirely, the information is simply absent from the source. Retry does not help when info is absent. Prevention (the facts block) is the only reliable fix.
Guard Hard Rules with Hooks, Not Memory
When a number gates a consequential action — say a refund threshold — never let a summarized, fuzzy amount drive the decision. Enforce it deterministically.
A PostToolUse or outgoing-call hook reads the verbatim case-facts value and blocks policy violations 100% of the time. Prompts are ~90% probabilistic; hooks are deterministic. Use hooks when failure has financial, legal or safety consequences.
{
"hooks": {
"PreToolUse": [{
"matcher": "process_refund",
"command": "check_refund_limit.py"
}]
}
}
# check_refund_limit.py reads case_facts.refund_amount (verbatim),
# not the lossy summary, and exits non-zero if > $500.Keep Provenance Alongside Facts
For research and extraction work, a verbatim fact is more trustworthy with its provenance: the source URL or doc name, the exact quote, and the publication date.
Dates frequently resolve apparent contradictions between conflicting stats — "revenue was $2.1M" vs "$2.4M" often just reflects different quarters. Annotate conflicting numbers with their sources rather than letting a summary silently pick one and blur the rest.
fact = {
"claim": "Q4 revenue was 2.4M USD",
"value": "2400000",
"source_doc": "FY26-Q4-earnings.pdf",
"quote": "Total revenue for Q4 reached $2.4M.",
"published": "2026-02-02",
}Fresh Session vs --resume
When a long session has been compacted many times, a resumed thread may carry a degraded summary — and resumed tool results can be stale if the codebase changed. Sometimes a fresh session seeded with a structured summary (your clean case-facts block) beats --resume.
The structured block is the carrier: it lets you start clean without losing the exact numbers and dates the work depends on.
# Long thread got fuzzy after repeated /compact?
# Start fresh and hand over the verbatim facts block:
claude -p "Resume task. ## CASE FACTS (authoritative):
$(cat case_facts.json)"
# vs. claude --resume my-session (may carry a degraded summary
# and stale tool results)Quick Check: Protecting the Numbers
A customer-support agent runs for many turns and periodically summarizes earlier messages to stay within the context window. QA finds it now quotes refund amounts and order dates that are slightly off or vague. Which fix is exam-correct?
Recap: Keep the Facts Verbatim
Key takeaways for the Context Management & Reliability domain:
- Progressive summarization (and /compact) makes numbers, percentages and dates vague — the gist survives, the precision doesn't.
- Fix: maintain a separate case-facts block, verbatim, outside the summary; summarize only the narrative.
- Capture facts at the source from tool results; never try to recover them after they're gone — retry can't restore absent info.
- Place facts near the start of context (beat lost-in-the-middle); keep provenance + dates for research.
- Gate consequential thresholds with deterministic hooks reading verbatim values, and prefer a fresh session with a structured summary over a degraded resume.
คำถามที่พบบ่อย
บทเรียน “ความเสี่ยงของการสรุปแบบค่อยเป็นค่อยไป” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “ความเสี่ยงของการสรุปแบบค่อยเป็นค่อยไป” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Claude Architect ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Claude Architect มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “ความเสี่ยงของการสรุปแบบค่อยเป็นค่อยไป”
ตัวเลข เปอร์เซ็นต์ และวันที่จะคลุมเครือเมื่อถูกสรุป คุณปฏิบัติ Claude Architect ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Claude Architect หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Claude Architect บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน
บทเรียน “ความเสี่ยงของการสรุปแบบค่อยเป็นค่อยไป” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Claude Architect นี้ได้ไหม
ได้ บทเรียน Claude Architect ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- ต้องใช้ประวัติทั้งหมด
- ความเสี่ยงของการสรุปแบบค่อยเป็นค่อยไป
- ผลกระทบจากข้อมูลที่หายไปตรงกลาง
- บล็อกข้อเท็จจริงของกรณีและการตัดผลลัพธ์