hermes-trace/docs/adr/0002-store-full-payloads-without-truncation.md

11 lines
1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 完整儲存 request/response payload,不設大小限制
LLM API 的 request 與 response payload 可能相當大(數百 KB 至數 MB),不設截斷或大小 guardrail 意味著 SQLite 會完整儲存每一筆。
曾考慮加入 `max_payload_bytes` 參數,超過則截斷並記錄警告,但做出以下判斷:
- **debugging 需要完整資訊** — 截斷的 payload 在追蹤 LLM 行為異常時可能遺失關鍵證據(如 tool call 參數被截到中間、system prompt 尾巴被切掉)
- **目前規模可接受** — hermes-trace 是單機工具,每日幾千次 API 呼叫,完整 payload 在數百 MB 到數 GB 等級,SQLite 對此規模游刃有餘
- **截斷的邊界難以定義** — 截斷 JSON 的中段會破壞結構,截尾部可能砍掉 `finish_reason` 等關鍵欄位
**決定:** 完整儲存 `full_request` 與 `full_response`,不設大小限制。若日後儲存成本成為實際問題,應先從 retention 天數或 capture 端(是否真的需要存每一筆)著手,而非截斷 payload。