<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>调试 on 老张开工了</title>
    <link>/%E8%B0%83%E8%AF%95/</link>
    <description>Recent content in 调试 on 老张开工了</description>
    <generator>Hugo</generator>
    <language>zh-cn</language>
    <lastBuildDate>Sat, 27 Jun 2026 00:00:00 +0000</lastBuildDate>
    <atom:link href="/%E8%B0%83%E8%AF%95/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Agent 调试与可观测性</title>
      <link>/posts/2026/06/agent-observability/</link>
      <pubDate>Sat, 27 Jun 2026 00:00:00 +0000</pubDate>
      <guid>/posts/2026/06/agent-observability/</guid>
      <description>传统软件的 bug 多在&amp;quot;代码逻辑出错了&amp;quot;——你能读 stack trace。Agent 的 bug 多在&amp;quot;模型决策出错了&amp;quot;——stack trace 给你的是一句它怎么想的，而不是它怎么错的。本章讲怎么把 Agent 这种黑盒变白盒，让你和 Agent 一起 debug。&#xA;14.1 Agent bug 的四种错误形态 错误形态 现象 典型解法 根因层 ───────────────────────────────────────────────────────── Prompt bug 模型理解任务错误 改 prompt + 例 Prompt Tool bug tool 拖了 water fix tool 实现 Tool Loop bug 卡 / 自我提前终 调预算/校验 Loop Context bug 信息被误信 / 没看见 压缩/重排 Context 这四层 bug 出错的修法是完全不同的，混在一起 = 接 debug。要建立&amp;quot;先分类 → 后修&amp;quot;反射: 先问错在哪层。&#xA;14.2 三种必须的工件 任何 Agent harness，至少要留下三种工件，否则 debug = 玩猜:</description>
    </item>
    <item>
      <title>异常处理与调试</title>
      <link>/posts/2026/05/exceptions-debugging/</link>
      <pubDate>Thu, 14 May 2026 00:00:00 +0000</pubDate>
      <guid>/posts/2026/05/exceptions-debugging/</guid>
      <description>程序总会有出错的时候——用户输入了无效数据、网络连接中断、磁盘空间不足……优秀的程序员不是写出永不报错的代码（这是不可能的），而是能优雅地处理错误，让程序在异常情况下也能行为可预测、可排查。&#xA;本章将系统学习 Python 的异常处理机制——从 try/except 到自定义异常，再到使用 pdb 和 logging 进行调试，让你的代码从&amp;quot;动不动就崩溃&amp;quot;变成&amp;quot;稳如磐石&amp;quot;。&#xA;Python 的异常哲学 Python 推崇 EAFP 原则——&amp;ldquo;Easier to Ask for Forgiveness than Permission&amp;rdquo;（请求原谅比获得许可更容易）。也就是：先尝试执行，如果出错了再处理，而不是在动手之前做各种检查。&#xA;# LBYL 风格（Look Before You Leap）——非 Python 方式 def safe_divide_lbyl(a, b): if b == 0: return None if not isinstance(a, (int, float)): return None return a / b # EAFP 风格——Python 方式 def safe_divide_eafp(a, b): try: return a / b except (ZeroDivisionError, TypeError): return None try/except/else/finally Python 的异常处理结构由四个子句组成：</description>
    </item>
  </channel>
</rss>
