每题先自己答,再看参考要点。场景题格式:Scenario / Constraints / Options / Best choice / Why / Why others are weaker / Tradeoffs / What would change the answer。
Scenario:每晚 20,000 次评估调用,目前循环调同步 Messages API,偶发 429/529 导致部分任务丢失,团队用 while True 无脑重试。 Constraints:结果次日 9 点前要出;预算紧;无实时性要求。 Options:(a) 加大重试次数 (b) Message Batches + 结果按 custom_id 对账 (c) 换更快模型 (d) 自建多线程并发 + 客户端限速 Best choice:(b)。 Why:批处理 50% 折扣、独立限流域、结果含 succeeded/errored/canceled/expired 四态可对账(errored 项可重入新批);24h 过期与 29 天取结果满足次日出报告的节奏;max_tokens: 0 与 stream 不可入批(来源: https://platform.claude.com/docs/en/build-with-claude/batch-processing(访问于 2026-08-30))。 Why others are weaker: 加剧流量放大还烧钱; 无助于丢失问题; 仍走同步限流域。 Tradeoffs:延迟小时级、需要轮询/取结果逻辑;共享前缀记得用 1h TTL 缓存。 What would change the answer:若要求分钟级出结果 → 客户端令牌桶 + 指数退避。
参考要点:
tool_choice 是否变化(作废 messages 缓存;tools/system 保留)cache_creation 与 cache_read 双 0)(来源: https://platform.claude.com/docs/en/build-with-claude/prompt-caching(访问于 2026-08-30))
参考要点:
参考要点:
get_final_message() 内部走流式保持连接活跃(来源: errors "Long requests",同上)参考要点:
anthropic-workspace-id;无状态工作负载可用 Workload Identity Federation 短期 token(POST /v1/oauth/token 换 Authorization: Bearer)(来源: https://platform.claude.com/docs/en/api/overview(访问于 2026-08-30))参考要点:
参考要点:
cache_control):多轮对话、消息尾部变化、"不想维护断点"——断点自动前移到最后可缓存块参考要点:
429 普通:静默退避对用户无感;预算内自动排队529/500:一次退避重试后仍失败 → 展示"服务繁忙"并保留用户输入refusal(stop_reason)或 403:不要原文展示给用户——转人审/换 phrasing;区别于 HTTP 错误(stop_reason 是 200 响应内的"完成方式")