<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: 侯垒</title>
    <description>The latest articles on DEV Community by 侯垒 (@houleixx).</description>
    <link>https://dev.to/houleixx</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3976799%2Fc165c283-c505-4c96-ba45-7b87ea20771c.png</url>
      <title>DEV Community: 侯垒</title>
      <link>https://dev.to/houleixx</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/houleixx"/>
    <language>en</language>
    <item>
      <title>中转站余额为什么掉得快？我拆了一次 AI 编程任务的真实消耗</title>
      <dc:creator>侯垒</dc:creator>
      <pubDate>Thu, 25 Jun 2026 06:33:13 +0000</pubDate>
      <link>https://dev.to/houleixx/zhong-zhuan-zhan-yu-e-wei-shi-yao-diao-de-kuai-wo-chai-liao-ci-ai-bian-cheng-ren-wu-de-zhen-shi-xiao-hao-4fai</link>
      <guid>https://dev.to/houleixx/zhong-zhuan-zhan-yu-e-wei-shi-yao-diao-de-kuai-wo-chai-liao-ci-ai-bian-cheng-ren-wu-de-zhen-shi-xiao-hao-4fai</guid>
      <description>&lt;h1&gt;
  
  
  中转站余额为什么掉得快？我拆了一次 AI 编程任务的真实消耗
&lt;/h1&gt;

&lt;p&gt;最近很多人开始高频使用 Claude Code、Codex、Cursor、OpenCode 这类 AI 编程 Agent。&lt;/p&gt;

&lt;p&gt;用起来确实很爽：一句话丢过去，它能读项目、找文件、分析报错、改代码、跑命令，最后再给你一个总结。&lt;/p&gt;

&lt;p&gt;但用得多了，另一个问题也开始明显起来：&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;中转站余额掉得真快。&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;有时候明明只是让它修一个小 bug，或者开一次 Code Plan，让它先分析一下项目，结果额度消耗比想象中高很多。&lt;/p&gt;

&lt;p&gt;这时很多人的第一反应是：&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;是不是中转站扣量不准？&lt;/li&gt;
&lt;li&gt;是不是模型太贵？&lt;/li&gt;
&lt;li&gt;是不是 Agent 偷偷请求了很多次？&lt;/li&gt;
&lt;li&gt;是不是 plan 模式也在大量消耗 token？&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;这些问题不能靠感觉判断。&lt;/p&gt;

&lt;p&gt;如果想知道钱到底花在哪里，就得把一次 AI 编程任务拆开看。&lt;/p&gt;

&lt;p&gt;所以我最近开始用一个更笨但更有效的方法：把一次 Agent 任务的每一轮请求拆开看。先看一张图。&lt;/p&gt;

&lt;p&gt;这里我用到的工具是 ccglass。它不是另一个 AI 编程助手，而是可以帮你观察 Claude Code、Codex 等工具每一轮真实请求的本地工具。对成本敏感的人来说，它最直接的价值是：&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;看清一次 Agent 任务到底烧了多少上下文、多少 token、多少 cache、多少 latency。&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fo5l0p8yppm6q1m3r7uun.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fo5l0p8yppm6q1m3r7uun.png" alt=" " width="800" height="402"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;这张图里，模型最终只输出了 &lt;code&gt;34 tokens&lt;/code&gt;，但顶部已经显示 &lt;code&gt;24,660 in&lt;/code&gt;，估算成本约 &lt;code&gt;$0.0930&lt;/code&gt;。请求概览里还能看到 &lt;code&gt;31 tools&lt;/code&gt;、&lt;code&gt;cache write 24,654 tokens&lt;/code&gt;、&lt;code&gt;latency 2.40s&lt;/code&gt;。&lt;/p&gt;

&lt;p&gt;也就是说，真正值得关注的不是最后输出了多少字，而是这一轮请求背后带了多少上下文。&lt;/p&gt;

&lt;h2&gt;
  
  
  不是你的错觉，Agent 任务确实比普通聊天重
&lt;/h2&gt;

&lt;p&gt;普通聊天的成本比较容易理解。&lt;/p&gt;

&lt;p&gt;你问一句，模型答一句：&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;用户输入 -&amp;gt; 模型输出
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;输入多少 token，输出多少 token，大概还能估。&lt;/p&gt;

&lt;p&gt;但 AI 编程 Agent 完全不是这个结构。&lt;/p&gt;

&lt;p&gt;你输入一句：&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;帮我分析这个 bug，并修复相关代码。
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;背后可能发生的是：&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;第 1 轮：模型理解任务
第 2 轮：搜索相关文件
第 3 轮：读取代码
第 4 轮：分析调用关系
第 5 轮：运行测试
第 6 轮：带着测试输出继续分析
第 7 轮：修改文件
第 8 轮：再次验证
第 9 轮：总结结果
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;这不是一次请求，而是一串请求。&lt;/p&gt;

&lt;p&gt;每一轮都可能有 input token 和 output token。更重要的是，后面的请求往往会带上前面产生的上下文。&lt;/p&gt;

&lt;p&gt;所以你看到的是“修一个小 bug”，实际消耗的是“多轮上下文 + 工具调用 + 文件内容 + 命令输出 + 模型回复”。&lt;/p&gt;

&lt;p&gt;这就是 Agent 类工具比普通聊天更烧额度的根本原因。&lt;/p&gt;

&lt;h2&gt;
  
  
  真正贵的，往往不是最后生成的那几行代码
&lt;/h2&gt;

&lt;p&gt;很多人以为 AI 编程的成本主要花在“生成代码”上。&lt;/p&gt;

&lt;p&gt;但实际拆开看，经常不是。&lt;/p&gt;

&lt;p&gt;下面这张图更直观。这里用户输入的只是一个简单的 &lt;code&gt;hello&lt;/code&gt;，但请求流里已经出现了 system reminder、Agent 类型说明，以及 &lt;code&gt;31 tools offered to the model&lt;/code&gt;。&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Foejgwcq7wvz633f2cwdd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Foejgwcq7wvz633f2cwdd.png" alt=" " width="800" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;这就是 AI 编程 Agent 和普通聊天最大的区别。&lt;/p&gt;

&lt;p&gt;普通聊天里，你可能只是在发一句话。&lt;br&gt;&lt;br&gt;
但 Agent 请求里，模型同时会看到一整套运行上下文：系统提醒、工具说明、可用能力、当前环境、历史消息，以及后续可能调用的工具。&lt;/p&gt;

&lt;p&gt;真正重的内容通常包括这些：&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;system prompt；&lt;/li&gt;
&lt;li&gt;developer 指令；&lt;/li&gt;
&lt;li&gt;tools schema；&lt;/li&gt;
&lt;li&gt;历史消息；&lt;/li&gt;
&lt;li&gt;当前工作目录信息；&lt;/li&gt;
&lt;li&gt;搜索结果；&lt;/li&gt;
&lt;li&gt;文件内容；&lt;/li&gt;
&lt;li&gt;测试日志；&lt;/li&gt;
&lt;li&gt;命令输出；&lt;/li&gt;
&lt;li&gt;前几轮 assistant 的分析；&lt;/li&gt;
&lt;li&gt;tool call 和 tool result；&lt;/li&gt;
&lt;li&gt;Code Plan 阶段生成的规划上下文。&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;其中最容易被忽略的是 tools schema 和工具结果。&lt;/p&gt;

&lt;p&gt;Agent 能读文件、写文件、跑命令，是因为它把可用工具的定义发给了模型。工具越多，schema 越复杂，这部分上下文就越重。&lt;/p&gt;

&lt;p&gt;Agent 读文件以后，文件内容也可能进入下一轮请求。&lt;br&gt;&lt;br&gt;
Agent 跑测试以后，测试输出也可能进入下一轮请求。&lt;br&gt;&lt;br&gt;
Agent 搜索代码以后，搜索结果也可能进入下一轮请求。&lt;/p&gt;

&lt;p&gt;如果某一轮读了一个很大的文件，或者测试输出很长，后续几轮的 input token 就可能明显上升。&lt;/p&gt;

&lt;p&gt;这时你以为自己只是在让它“改几行代码”，但实际上模型每轮都在背着一大包上下文继续工作。&lt;/p&gt;
&lt;h2&gt;
  
  
  Code Plan 为什么看起来没写代码也会贵
&lt;/h2&gt;

&lt;p&gt;很多人对 Code Plan 或 plan mode 的消耗尤其困惑。&lt;/p&gt;

&lt;p&gt;因为它看起来还没开始写代码，只是在“想一下”。&lt;/p&gt;

&lt;p&gt;但对 Agent 来说，plan 不等于空想。&lt;/p&gt;

&lt;p&gt;一个比较完整的 plan 阶段，可能会做这些事：&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;读取项目结构；&lt;/li&gt;
&lt;li&gt;分析 README 或配置文件；&lt;/li&gt;
&lt;li&gt;搜索相关模块；&lt;/li&gt;
&lt;li&gt;理解已有代码风格；&lt;/li&gt;
&lt;li&gt;判断任务影响范围；&lt;/li&gt;
&lt;li&gt;推断需要修改哪些文件；&lt;/li&gt;
&lt;li&gt;生成分步骤执行计划；&lt;/li&gt;
&lt;li&gt;保留这些分析给后续实现阶段使用。&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;这些动作都会消耗 token。&lt;/p&gt;

&lt;p&gt;尤其是当项目比较大、任务描述比较宽泛时，plan 阶段为了建立项目地图，可能会读很多上下文。&lt;/p&gt;

&lt;p&gt;所以 Code Plan 贵，不一定是异常。&lt;/p&gt;

&lt;p&gt;它的本质是：在正式动手前，先花 token 买一次理解和规划。&lt;/p&gt;

&lt;p&gt;这个成本值不值，取决于任务复杂度。&lt;/p&gt;

&lt;p&gt;如果是大重构、跨模块修改、复杂 bug，plan 阶段很有价值。&lt;br&gt;&lt;br&gt;
如果只是改一个很小的样式或文案，反复开 plan 就可能显得浪费。&lt;/p&gt;
&lt;h2&gt;
  
  
  中转站倍率会放大这种体感
&lt;/h2&gt;

&lt;p&gt;如果你用的是中转站、聚合 API 或第三方模型网关，成本体感会更明显。&lt;/p&gt;

&lt;p&gt;因为它通常不是简单看“请求次数”，而是跟这些因素有关：&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;模型倍率；&lt;/li&gt;
&lt;li&gt;input token；&lt;/li&gt;
&lt;li&gt;output token；&lt;/li&gt;
&lt;li&gt;cache 计费方式；&lt;/li&gt;
&lt;li&gt;上下文长度；&lt;/li&gt;
&lt;li&gt;是否使用高价模型；&lt;/li&gt;
&lt;li&gt;是否多轮请求；&lt;/li&gt;
&lt;li&gt;是否有长输出和长工具结果。&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;高倍率模型本身就贵。&lt;br&gt;&lt;br&gt;
如果再叠加长上下文和多轮请求，余额下降会非常明显。&lt;/p&gt;

&lt;p&gt;这也是为什么同样是“修一个 bug”，有时很便宜，有时很贵。&lt;/p&gt;

&lt;p&gt;任务表面看起来相似，但背后的请求链路可能完全不同：&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;一个任务只读了 2 个文件；&lt;/li&gt;
&lt;li&gt;另一个任务读了 15 个文件；&lt;/li&gt;
&lt;li&gt;一个任务只跑了单个测试；&lt;/li&gt;
&lt;li&gt;另一个任务跑了全量测试并返回大量日志；&lt;/li&gt;
&lt;li&gt;一个任务 cache 命中不错；&lt;/li&gt;
&lt;li&gt;另一个任务每轮都在创建新上下文；&lt;/li&gt;
&lt;li&gt;一个任务很快收敛；&lt;/li&gt;
&lt;li&gt;另一个任务来回尝试了很多轮。&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;如果没有工具观察，你只能看到余额变少。&lt;br&gt;&lt;br&gt;
但你不知道是哪一轮、哪个文件、哪个工具结果把成本拉上去的。&lt;/p&gt;
&lt;h2&gt;
  
  
  用 ccglass 拆一笔账
&lt;/h2&gt;

&lt;p&gt;ccglass 的实用性就在这里。&lt;/p&gt;

&lt;p&gt;它可以在本地作为代理，记录 Claude Code、Codex、OpenCode 等 AI 编程工具实际发给模型 API 的请求和响应，并通过 Dashboard 展示出来。&lt;/p&gt;

&lt;p&gt;对成本分析来说，重点不是看热闹，而是看这些信息：&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;一次任务到底有几轮请求；&lt;/li&gt;
&lt;li&gt;每一轮 input token 多少；&lt;/li&gt;
&lt;li&gt;每一轮 output token 多少；&lt;/li&gt;
&lt;li&gt;cache creation 有多少；&lt;/li&gt;
&lt;li&gt;cache read 有多少；&lt;/li&gt;
&lt;li&gt;latency 是否异常；&lt;/li&gt;
&lt;li&gt;messages 数量是否增长；&lt;/li&gt;
&lt;li&gt;tools 数量是否很大；&lt;/li&gt;
&lt;li&gt;哪一轮请求突然变重；&lt;/li&gt;
&lt;li&gt;哪个工具结果进入了后续上下文；&lt;/li&gt;
&lt;li&gt;是 plan 阶段贵，还是实现阶段贵；&lt;/li&gt;
&lt;li&gt;是读文件贵，还是测试输出贵。&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;再看 response 里的 usage 明细。&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fuw8rfkv9i2lvwsvfqir0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fuw8rfkv9i2lvwsvfqir0.png" alt=" " width="800" height="353"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;这次请求里，&lt;code&gt;input_tokens&lt;/code&gt; 是 &lt;code&gt;6&lt;/code&gt;，&lt;code&gt;output_tokens&lt;/code&gt; 是 &lt;code&gt;34&lt;/code&gt;，但 &lt;code&gt;cache_creation_input_tokens&lt;/code&gt; 达到了 &lt;code&gt;24,654&lt;/code&gt;，&lt;code&gt;cache_read_input_tokens&lt;/code&gt; 是 &lt;code&gt;0&lt;/code&gt;。&lt;/p&gt;

&lt;p&gt;这个例子很适合说明一个成本误区：用户输入和模型输出本身都不长，但 Agent 请求仍然可能携带大量可缓存上下文。对于中转站或聚合 API 用户来说，这类上下文最终都会反映到额度消耗、倍率成本或延迟体感上。&lt;/p&gt;

&lt;p&gt;有了这些信息以后，很多问题就能从“感觉”变成“证据”。&lt;/p&gt;

&lt;p&gt;比如你可以看到：&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;第 1 轮 input 不高，只是任务和系统上下文。
第 2 轮 tools schema 很大。
第 3 轮读了一个大文件，input 开始上涨。
第 4 轮测试输出很长，后面几轮都变重。
第 5 轮 cache 没怎么命中，所以延迟和消耗都上去了。
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;这时你就知道，余额掉得快不是玄学。&lt;/p&gt;

&lt;p&gt;它可能是因为 Agent 读了太多无关文件，也可能是测试日志太长，也可能是 plan 阶段上下文太宽，也可能是模型倍率太高。&lt;/p&gt;

&lt;h2&gt;
  
  
  看清成本以后，怎么省？
&lt;/h2&gt;

&lt;p&gt;ccglass 本身不会替你省钱。&lt;/p&gt;

&lt;p&gt;它的作用是告诉你钱花在哪里。真正省钱，还要调整使用习惯。&lt;/p&gt;

&lt;p&gt;下面这些方法通常很有效。&lt;/p&gt;

&lt;h2&gt;
  
  
  1. 小任务不要开太大范围
&lt;/h2&gt;

&lt;p&gt;不要动不动就说：&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;帮我优化这个项目。
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;这类 prompt 会鼓励 Agent 大范围搜索和读取上下文。&lt;/p&gt;

&lt;p&gt;更好的写法是：&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;只检查 src/auth 目录下 session 相关逻辑，先分析问题，不要修改代码。
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;范围越清楚，Agent 乱读文件的概率越低。&lt;/p&gt;

&lt;h2&gt;
  
  
  2. 直接给关键文件
&lt;/h2&gt;

&lt;p&gt;如果你已经知道问题大概在哪，就直接告诉它。&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;问题大概率在 src/auth/session.ts 和 src/auth/session.test.ts。
请优先检查这两个文件。
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;这比让它全项目搜索更省。&lt;/p&gt;

&lt;h2&gt;
  
  
  3. 控制测试日志
&lt;/h2&gt;

&lt;p&gt;测试日志很容易变成长上下文。&lt;/p&gt;

&lt;p&gt;如果你把完整 CI 日志丢给 Agent，或者让它反复跑全量测试，token 会涨得很快。&lt;/p&gt;

&lt;p&gt;更好的方式是：&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;先给失败测试名；&lt;/li&gt;
&lt;li&gt;给核心报错；&lt;/li&gt;
&lt;li&gt;给关键调用栈；&lt;/li&gt;
&lt;li&gt;让它按需运行单个测试；&lt;/li&gt;
&lt;li&gt;避免把无关日志全部塞进去。&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. 不要反复开 plan
&lt;/h2&gt;

&lt;p&gt;Plan 很有用，但不是所有任务都需要。&lt;/p&gt;

&lt;p&gt;如果只是小改动，反复进入 Code Plan 可能不划算。&lt;/p&gt;

&lt;p&gt;可以把 plan 用在这些场景：&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;跨模块修改；&lt;/li&gt;
&lt;li&gt;大重构；&lt;/li&gt;
&lt;li&gt;复杂 bug；&lt;/li&gt;
&lt;li&gt;不熟悉的项目；&lt;/li&gt;
&lt;li&gt;需要评估风险的任务。&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;简单任务可以直接限定范围，让 Agent 小步执行。&lt;/p&gt;

&lt;h2&gt;
  
  
  5. 低价值任务用低倍率模型
&lt;/h2&gt;

&lt;p&gt;不是所有任务都值得用最强模型。&lt;/p&gt;

&lt;p&gt;比如：&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;改文案；&lt;/li&gt;
&lt;li&gt;补简单类型；&lt;/li&gt;
&lt;li&gt;生成重复样板代码；&lt;/li&gt;
&lt;li&gt;改格式；&lt;/li&gt;
&lt;li&gt;写简单测试；&lt;/li&gt;
&lt;li&gt;查找明显错误。&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;这类任务可以考虑低倍率模型。&lt;/p&gt;

&lt;p&gt;高价模型留给真正需要复杂推理的任务。&lt;/p&gt;

&lt;h2&gt;
  
  
  6. 定期看异常任务
&lt;/h2&gt;

&lt;p&gt;如果你是重度用户，建议偶尔用 ccglass 看几次典型任务。&lt;/p&gt;

&lt;p&gt;不用每次都盯着看，但可以定期做成本体检：&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;哪类任务最耗 token？&lt;/li&gt;
&lt;li&gt;哪个 Agent 请求轮数最多？&lt;/li&gt;
&lt;li&gt;哪个模型 latency 最高？&lt;/li&gt;
&lt;li&gt;哪些任务 cache 命中差？&lt;/li&gt;
&lt;li&gt;哪些工具结果特别大？&lt;/li&gt;
&lt;li&gt;哪些 prompt 容易导致全项目搜索？&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;看几次以后，你会更清楚自己怎么用 Agent 最划算。&lt;/p&gt;

&lt;h2&gt;
  
  
  ccglass 的定位：不是抓包玩具，而是成本观察入口
&lt;/h2&gt;

&lt;p&gt;如果只是偶尔用 AI 补一段代码，可能不需要 ccglass。&lt;/p&gt;

&lt;p&gt;但如果你已经开始高频使用 Claude Code、Codex、Code Plan，或者你用的是中转站、聚合 API、第三方模型网关，那成本就不是小问题。&lt;/p&gt;

&lt;p&gt;这时你需要的不只是“能不能完成任务”，还要知道：&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;它请求了几轮；&lt;/li&gt;
&lt;li&gt;它每轮带了多少上下文；&lt;/li&gt;
&lt;li&gt;它为什么突然变贵；&lt;/li&gt;
&lt;li&gt;它有没有重复发送无效内容；&lt;/li&gt;
&lt;li&gt;plan 阶段到底花了多少；&lt;/li&gt;
&lt;li&gt;cache 有没有帮上忙；&lt;/li&gt;
&lt;li&gt;高倍率模型是否用在了值得的地方。&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;ccglass 解决的就是这个可见性问题。&lt;/p&gt;

&lt;p&gt;它不会替你决定用哪个模型，也不会替你优化 prompt。&lt;br&gt;&lt;br&gt;
但它可以把一次 AI 编程任务的消耗摊开，让你知道钱到底花在哪里。&lt;/p&gt;

&lt;h2&gt;
  
  
  总结
&lt;/h2&gt;

&lt;p&gt;AI 编程不是不能花钱。&lt;/p&gt;

&lt;p&gt;真正的问题是：钱花得明不明白。&lt;/p&gt;

&lt;p&gt;Claude Code、Codex、Code Plan 这类 Agent 工具，本来就比普通聊天更重。它们会多轮请求、携带工具定义、读取文件、保留历史、处理测试输出，还可能在 plan 阶段建立大量上下文。&lt;/p&gt;

&lt;p&gt;如果你用中转站，这些都会变成非常真实的额度消耗。&lt;/p&gt;

&lt;p&gt;所以，与其只盯着余额下降，不如拆开看一次任务：&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;哪一轮最贵；&lt;/li&gt;
&lt;li&gt;哪些上下文最重；&lt;/li&gt;
&lt;li&gt;哪些工具结果被反复带入；&lt;/li&gt;
&lt;li&gt;cache 有没有命中；&lt;/li&gt;
&lt;li&gt;plan 阶段是否值得；&lt;/li&gt;
&lt;li&gt;模型倍率是否匹配任务价值。&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;这就是 ccglass 对成本敏感用户的实用价值。&lt;/p&gt;

&lt;p&gt;它让 AI 编程成本从一笔糊涂账，变成可以观察、分析和优化的工程指标。&lt;/p&gt;

&lt;p&gt;一句话总结：&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;不是少用 AI，而是少烧无效上下文。&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  项目地址
&lt;/h2&gt;

&lt;p&gt;ccglass 是一个开源项目，项目地址：&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/jianshuo/ccglass" rel="noopener noreferrer"&gt;https://github.com/jianshuo/ccglass&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;如果你也在使用 Claude Code、Codex、OpenCode 或其他 AI 编程 Agent，并且对请求链路、token 成本、cache 命中、延迟分析感兴趣，欢迎试用、提 issue 或 star 支持。&lt;/p&gt;

</description>
    </item>
    <item>
      <title>AI Agent 出问题时，不要只看最终回答：一次请求级调试的思路</title>
      <dc:creator>侯垒</dc:creator>
      <pubDate>Mon, 22 Jun 2026 02:04:28 +0000</pubDate>
      <link>https://dev.to/houleixx/ai-agent-chu-wen-ti-shi-bu-yao-zhi-kan-zui-zhong-hui-da-ci-qing-qiu-ji-diao-shi-de-si-lu-1b5g</link>
      <guid>https://dev.to/houleixx/ai-agent-chu-wen-ti-shi-bu-yao-zhi-kan-zui-zhong-hui-da-ci-qing-qiu-ji-diao-shi-de-si-lu-1b5g</guid>
      <description>&lt;p&gt;这两年 AI 编程工具变化很快。&lt;/p&gt;

&lt;p&gt;从 Copilot 式的代码补全，到 Claude Code、Codex、OpenCode、Cursor、Cline 这类 Agent 工具，AI 已经不只是“帮你补几行代码”了。它可以读项目、改文件、跑命令、调用工具、分析报错，然后继续下一轮。&lt;/p&gt;

&lt;p&gt;但 Agent 越像一个“会干活的人”，问题也越明显：&lt;/p&gt;

&lt;p&gt;它出错的时候，你很难判断它到底错在哪里。&lt;/p&gt;

&lt;p&gt;很多人遇到 AI 编程工具跑偏时，第一反应是改 prompt。&lt;/p&gt;

&lt;p&gt;比如：&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;你要更认真一点。&lt;br&gt;
不要偷懒。&lt;br&gt;
必须先读代码再修改。&lt;br&gt;
不要乱改无关文件。&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;这些提示有时有用，但更多时候只是把问题往后推。&lt;/p&gt;

&lt;p&gt;因为真正的问题可能根本不在你写给它的那句话里，而在它实际发给模型的完整请求里。&lt;/p&gt;

&lt;h2&gt;
  
  
  为什么只看最终回答不够？
&lt;/h2&gt;

&lt;p&gt;一个 AI Agent 完成任务，通常不是一次请求结束。&lt;/p&gt;

&lt;p&gt;它的流程更像这样：&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;用户提出任务
-&amp;gt; 模型收到 system prompt、上下文、工具列表
-&amp;gt; 模型决定调用某个工具
-&amp;gt; 本地执行工具，比如读文件、搜索代码、运行命令
-&amp;gt; 工具结果再进入下一轮模型请求
-&amp;gt; 模型继续判断
-&amp;gt; 直到给出最终回答或修改代码
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;我们在终端或编辑器里看到的，通常只是这个过程的一小部分。&lt;/p&gt;

&lt;p&gt;最终回答只能告诉你“它做了什么”，但很难告诉你“它为什么这么做”。&lt;/p&gt;

&lt;p&gt;比如下面这些问题，只看最终回答基本看不出来：&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;它到底有没有看到关键文件？&lt;/li&gt;
&lt;li&gt;它看到的是完整上下文，还是被截断后的上下文？&lt;/li&gt;
&lt;li&gt;system prompt 里有没有某条规则影响了它？&lt;/li&gt;
&lt;li&gt;工具 schema 是不是描述不清，导致它选错工具？&lt;/li&gt;
&lt;li&gt;tool result 有没有进入下一轮？&lt;/li&gt;
&lt;li&gt;哪一轮开始 token 暴涨？&lt;/li&gt;
&lt;li&gt;provider 返回的 400 到底是模型问题，还是请求格式问题？&lt;/li&gt;
&lt;li&gt;它是不是每一轮都重复带入了大量无效上下文？&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;这些都属于“请求级问题”。&lt;/p&gt;

&lt;h2&gt;
  
  
  AI Agent 的常见问题，其实可以分层看
&lt;/h2&gt;

&lt;p&gt;我现在更倾向于把 AI Agent 的问题分成几层，而不是笼统地说“模型不行”。&lt;/p&gt;

&lt;h3&gt;
  
  
  第一层：模型没有看到该看的东西
&lt;/h3&gt;

&lt;p&gt;这是最常见的问题之一。&lt;/p&gt;

&lt;p&gt;你以为 Agent 已经读了某个文件，但实际发给模型的请求里没有那段内容。&lt;/p&gt;

&lt;p&gt;或者它读过，但后续请求里没有保留。&lt;/p&gt;

&lt;p&gt;于是模型只能基于不完整上下文做判断，结果自然不稳定。&lt;/p&gt;

&lt;p&gt;这种时候继续强调“请仔细阅读代码”没有太大意义。你真正要确认的是：&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;关键上下文有没有进入下一轮请求？&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  第二层：工具列表或工具描述有问题
&lt;/h3&gt;

&lt;p&gt;Agent 能调用工具，并不代表它会正确调用工具。&lt;/p&gt;

&lt;p&gt;模型看到的是一组工具 schema，包括工具名、描述、参数结构。&lt;/p&gt;

&lt;p&gt;如果工具描述太模糊，模型可能不知道什么时候该用。&lt;/p&gt;

&lt;p&gt;如果参数结构太复杂，模型可能生成错误参数。&lt;/p&gt;

&lt;p&gt;如果工具太多，模型也可能选错。&lt;/p&gt;

&lt;p&gt;这类问题在 MCP、插件、子任务工具越来越多以后会更明显。&lt;/p&gt;

&lt;h3&gt;
  
  
  第三层：tool call 和 tool result 没有正确闭环
&lt;/h3&gt;

&lt;p&gt;一个正常的工具调用闭环应该是：&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;assistant: tool_use
tool: tool_result
assistant: 根据 tool_result 继续
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;如果中间某一环丢了，Agent 就会开始出现奇怪行为。&lt;/p&gt;

&lt;p&gt;比如：&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;工具没有真正执行，但模型以为执行了&lt;/li&gt;
&lt;li&gt;tool result 太长，进入下一轮后污染上下文&lt;/li&gt;
&lt;li&gt;多个 tool_result 顺序错了&lt;/li&gt;
&lt;li&gt;tool_use 和 tool_result 没有正确配对&lt;/li&gt;
&lt;li&gt;provider 要求的消息格式和客户端保存的格式不一致&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;这类 bug 最难靠肉眼看最终回答判断。&lt;/p&gt;

&lt;p&gt;你必须看到真实的请求和响应。&lt;/p&gt;

&lt;h3&gt;
  
  
  第四层：token 和成本问题
&lt;/h3&gt;

&lt;p&gt;很多人用 AI 编程工具时，一开始只关心效果。&lt;/p&gt;

&lt;p&gt;但一旦使用频率上来，token 成本就会变成实际问题。&lt;/p&gt;

&lt;p&gt;尤其是 Agent 场景里，token 并不只花在最终回答上。&lt;/p&gt;

&lt;p&gt;大量 token 可能花在：&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;system prompt&lt;/li&gt;
&lt;li&gt;工具 schema&lt;/li&gt;
&lt;li&gt;历史消息&lt;/li&gt;
&lt;li&gt;文件内容&lt;/li&gt;
&lt;li&gt;搜索结果&lt;/li&gt;
&lt;li&gt;命令输出&lt;/li&gt;
&lt;li&gt;tool result&lt;/li&gt;
&lt;li&gt;子 Agent 的上下文&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;有时一次任务很贵，不是因为最终回答很长，而是因为某一轮请求带了巨大的上下文。&lt;/p&gt;

&lt;p&gt;所以看 session 总成本还不够，最好能看到每一次请求的 token 使用。&lt;/p&gt;

&lt;h2&gt;
  
  
  请求级调试应该看什么？
&lt;/h2&gt;

&lt;p&gt;如果一个 AI Agent 跑偏，我通常会先看这几类信息。&lt;/p&gt;

&lt;h3&gt;
  
  
  1. system prompt
&lt;/h3&gt;

&lt;p&gt;system prompt 是 Agent 行为的底层约束。&lt;/p&gt;

&lt;p&gt;很多看似“模型自己决定”的行为，其实是 system prompt 影响的。&lt;/p&gt;

&lt;p&gt;比如：&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;它为什么总是先写计划？&lt;/li&gt;
&lt;li&gt;它为什么不直接执行命令？&lt;/li&gt;
&lt;li&gt;它为什么遇到某类文件不修改？&lt;/li&gt;
&lt;li&gt;它为什么要反复确认？&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;这些可能都和 system prompt 有关。&lt;/p&gt;

&lt;h3&gt;
  
  
  2. messages
&lt;/h3&gt;

&lt;p&gt;messages 决定模型当前能看到什么。&lt;/p&gt;

&lt;p&gt;重点不是“这个 Agent 曾经读过什么”，而是：&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;当前这一轮请求里到底包含了什么？&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;这两个问题不一样。&lt;/p&gt;

&lt;p&gt;Agent 本地读过一个文件，不代表后续每一轮模型请求都带着这个文件。&lt;/p&gt;

&lt;h3&gt;
  
  
  3. tools schema
&lt;/h3&gt;

&lt;p&gt;如果 Agent 没有调用你期望的工具，先不要急着骂模型。&lt;/p&gt;

&lt;p&gt;可以先看：&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;工具是否真的出现在 tools 里？&lt;/li&gt;
&lt;li&gt;工具描述是否清楚？&lt;/li&gt;
&lt;li&gt;参数 schema 是否合理？&lt;/li&gt;
&lt;li&gt;是否有多个类似工具让模型混淆？&lt;/li&gt;
&lt;li&gt;provider 是否支持这种 schema？&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. tool call / tool result
&lt;/h3&gt;

&lt;p&gt;这一层最适合排查 Agent 为什么做错。&lt;/p&gt;

&lt;p&gt;你可以看：&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;模型选择了哪个工具&lt;/li&gt;
&lt;li&gt;传入了什么参数&lt;/li&gt;
&lt;li&gt;工具返回了什么&lt;/li&gt;
&lt;li&gt;返回结果有没有进入下一轮&lt;/li&gt;
&lt;li&gt;下一轮模型有没有基于这个结果继续&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;如果这里断了，后面再怎么调 prompt 都不稳定。&lt;/p&gt;

&lt;h3&gt;
  
  
  5. token / cache / cost / latency
&lt;/h3&gt;

&lt;p&gt;这些指标能帮你判断问题发生在哪一轮。&lt;/p&gt;

&lt;p&gt;比如：&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;哪一轮 input token 突然升高？&lt;/li&gt;
&lt;li&gt;哪一轮 tool result 特别大？&lt;/li&gt;
&lt;li&gt;cache 有没有命中？&lt;/li&gt;
&lt;li&gt;哪个模型最贵？&lt;/li&gt;
&lt;li&gt;哪个请求延迟最高？&lt;/li&gt;
&lt;li&gt;失败请求有没有 usage 信息？&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;这比只看“今天花了多少钱”有用得多。&lt;/p&gt;

&lt;h2&gt;
  
  
  ccglass 解决的就是这一层
&lt;/h2&gt;

&lt;p&gt;最近我发现了一个开源工具：ccglass。&lt;/p&gt;

&lt;p&gt;项目地址：&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/jianshuo/ccglass" rel="noopener noreferrer"&gt;https://github.com/jianshuo/ccglass&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;它不是另一个 AI 编程助手，而是一个本地观测工具。&lt;/p&gt;

&lt;p&gt;简单说，它会在本地启动一个代理和 Dashboard，让你看到 Claude Code、Codex、OpenCode、CodeBuddy、Qoder 等工具实际发给模型的请求。&lt;/p&gt;

&lt;p&gt;你可以看到：&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;system prompt&lt;/li&gt;
&lt;li&gt;messages&lt;/li&gt;
&lt;li&gt;tools schema&lt;/li&gt;
&lt;li&gt;tool calls&lt;/li&gt;
&lt;li&gt;tool results&lt;/li&gt;
&lt;li&gt;request / response body&lt;/li&gt;
&lt;li&gt;token / cache / cost&lt;/li&gt;
&lt;li&gt;latency&lt;/li&gt;
&lt;li&gt;turn-to-turn diff&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;也就是说，它关心的不是“再帮你写一段代码”，而是“让你看清 Agent 到底是怎么工作的”。&lt;/p&gt;

&lt;h2&gt;
  
  
  一个典型使用场景
&lt;/h2&gt;

&lt;p&gt;假设你让 Claude Code 修一个 bug。&lt;/p&gt;

&lt;p&gt;它最后确实改了代码，但你觉得改得很奇怪。&lt;/p&gt;

&lt;p&gt;这时你可以不急着重跑，而是打开 ccglass 看这几件事：&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;第一轮请求里有没有带上相关文件？&lt;/li&gt;
&lt;li&gt;system prompt 有没有影响它的修改策略？&lt;/li&gt;
&lt;li&gt;它调用了哪些工具？&lt;/li&gt;
&lt;li&gt;每个工具返回了什么？&lt;/li&gt;
&lt;li&gt;哪个 tool result 进入了下一轮？&lt;/li&gt;
&lt;li&gt;修改代码前，它是否真的看到了测试失败信息？&lt;/li&gt;
&lt;li&gt;token 是不是在某一轮突然暴涨？&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;如果你能回答这些问题，调试 Agent 就从“感觉不对”变成了“证据链不对”。&lt;/p&gt;

&lt;h2&gt;
  
  
  它和普通抓包工具有什么区别？
&lt;/h2&gt;

&lt;p&gt;很多人会问：这是不是 Charles、mitmproxy、Proxyman 也能做？&lt;/p&gt;

&lt;p&gt;某些情况下可以，但 AI 编程 Agent 有几个麻烦点：&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;不一定遵守系统代理&lt;/li&gt;
&lt;li&gt;有些客户端走自定义 base URL&lt;/li&gt;
&lt;li&gt;有些使用 OpenAI / Anthropic 兼容接口&lt;/li&gt;
&lt;li&gt;有些 provider 的 streaming 格式不一样&lt;/li&gt;
&lt;li&gt;有些工具调用信息需要按 Agent 语义展示，而不是只看 HTTP 包&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;ccglass 的目标不是替代通用抓包工具，而是专门围绕 AI Agent 请求结构做展示。&lt;/p&gt;

&lt;p&gt;它会把 system、messages、tools、tool call、tool result、usage、cost、diff 这些东西整理成适合调试 Agent 的视图。&lt;/p&gt;

&lt;h2&gt;
  
  
  为什么我觉得这件事会越来越重要？
&lt;/h2&gt;

&lt;p&gt;AI 编程工具的发展方向很明显：Agent 会越来越自动。&lt;/p&gt;

&lt;p&gt;它们会读更多文件，调用更多工具，跑更长任务，甚至调度子 Agent。&lt;/p&gt;

&lt;p&gt;这当然会提高效率。&lt;/p&gt;

&lt;p&gt;但如果没有观测能力，复杂度也会一起上升。&lt;/p&gt;

&lt;p&gt;以后我们遇到的问题可能不再是：&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;这段代码补全得对不对？&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;而是：&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;为什么这个 Agent 在第 7 轮调用了这个工具？&lt;br&gt;
为什么它把这个 tool result 带到了后面 12 轮？&lt;br&gt;
为什么这次任务花了 30 万 token？&lt;br&gt;
为什么同样的任务换 provider 就失败？&lt;br&gt;
为什么上下文压缩后它丢了关键约束？&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;这些问题都需要请求级视角。&lt;/p&gt;

&lt;h2&gt;
  
  
  结语
&lt;/h2&gt;

&lt;p&gt;我觉得 AI 编程工具接下来的一个重要方向，不只是让 Agent 更强，而是让 Agent 更可观察。&lt;/p&gt;

&lt;p&gt;只看最终回答，就像只看程序崩溃后的最后一行日志。&lt;/p&gt;

&lt;p&gt;真正要调试复杂系统，还是要看输入、输出、中间状态和调用链。&lt;/p&gt;

&lt;p&gt;AI Agent 也是一样。&lt;/p&gt;

&lt;p&gt;如果你也在用 Claude Code、Codex、OpenCode、CodeBuddy、Qoder 这类工具，可以试试 ccglass：&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/jianshuo/ccglass" rel="noopener noreferrer"&gt;https://github.com/jianshuo/ccglass&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;它解决的不是“让 AI 更聪明”，而是让使用者更清楚地知道：&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;AI 到底看到了什么，又基于什么做出了下一步。&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Debugging AI Coding Agents: How to See Prompts, Tool Calls, Token Usage, and Cost</title>
      <dc:creator>侯垒</dc:creator>
      <pubDate>Sun, 21 Jun 2026 02:33:55 +0000</pubDate>
      <link>https://dev.to/houleixx/debugging-ai-coding-agents-how-to-see-prompts-tool-calls-token-usage-and-cost-4omm</link>
      <guid>https://dev.to/houleixx/debugging-ai-coding-agents-how-to-see-prompts-tool-calls-token-usage-and-cost-4omm</guid>
      <description>&lt;p&gt;When a coding agent fails, the visible error is rarely the whole story.&lt;/p&gt;

&lt;p&gt;You might see:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a tool call that never ran&lt;/li&gt;
&lt;li&gt;a command repeated again and again&lt;/li&gt;
&lt;li&gt;a sudden token spike&lt;/li&gt;
&lt;li&gt;a provider rejecting a request with &lt;code&gt;400 Bad Request&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;an agent that says it edited a file but did not&lt;/li&gt;
&lt;li&gt;a long session that starts producing shallow or confused answers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The usual reaction is to tweak the prompt and try again.&lt;/p&gt;

&lt;p&gt;Sometimes that works. But for agentic coding tools, guessing is not enough. You need to inspect what the agent actually sent to the model.&lt;/p&gt;

&lt;p&gt;That is the problem &lt;strong&gt;ccglass&lt;/strong&gt; is built for.&lt;/p&gt;

&lt;p&gt;GitHub: &lt;a href="https://github.com/jianshuo/ccglass" rel="noopener noreferrer"&gt;https://github.com/jianshuo/ccglass&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The debugging problem with coding agents
&lt;/h2&gt;

&lt;p&gt;Modern coding agents are not simple chatbots.&lt;/p&gt;

&lt;p&gt;Tools like Claude Code, Codex, OpenCode, CodeBuddy, Qoder, and similar systems usually run a loop like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;user request
  -&amp;gt; model request
  -&amp;gt; tool call
  -&amp;gt; local command / file read / edit / search
  -&amp;gt; tool result
  -&amp;gt; next model request
  -&amp;gt; final answer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When something goes wrong, the bug can be in any part of that loop.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The model never saw the tool schema you thought it saw.&lt;/li&gt;
&lt;li&gt;The tool schema was too large or malformed.&lt;/li&gt;
&lt;li&gt;The model returned a malformed tool call.&lt;/li&gt;
&lt;li&gt;The local client dropped part of the tool result.&lt;/li&gt;
&lt;li&gt;A huge tool result entered the next request and inflated token usage.&lt;/li&gt;
&lt;li&gt;The provider rejected a request shape that another provider accepts.&lt;/li&gt;
&lt;li&gt;A proxy or gateway translated Anthropic and OpenAI formats incorrectly.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You cannot debug that reliably from the final answer alone.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to inspect first
&lt;/h2&gt;

&lt;p&gt;When an agent behaves strangely, I usually want to see five things.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. The system prompt
&lt;/h3&gt;

&lt;p&gt;The system prompt often explains behavior that looks mysterious from the outside.&lt;/p&gt;

&lt;p&gt;It may contain rules about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;when to ask permission&lt;/li&gt;
&lt;li&gt;when to use tools&lt;/li&gt;
&lt;li&gt;how much work to do before stopping&lt;/li&gt;
&lt;li&gt;whether to run tests&lt;/li&gt;
&lt;li&gt;whether to preserve existing files&lt;/li&gt;
&lt;li&gt;how to summarize results&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the agent ignores your instruction, first check whether the system prompt is pushing it in a different direction.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. The tool schema
&lt;/h3&gt;

&lt;p&gt;Tool calling depends heavily on the schema sent to the model.&lt;/p&gt;

&lt;p&gt;If a tool is described vaguely, has confusing parameter names, or contains a schema shape the provider does not like, the model may choose the wrong tool or produce invalid arguments.&lt;/p&gt;

&lt;p&gt;This matters even more with MCP servers and custom tools.&lt;/p&gt;

&lt;p&gt;The question is not "what did my code define?" The real question is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;What tool schema was actually sent in the model request?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  3. The tool call
&lt;/h3&gt;

&lt;p&gt;A tool call bug can come from the model, the client, or the provider adapter.&lt;/p&gt;

&lt;p&gt;You want to inspect:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;tool name&lt;/li&gt;
&lt;li&gt;call id&lt;/li&gt;
&lt;li&gt;arguments&lt;/li&gt;
&lt;li&gt;malformed fields&lt;/li&gt;
&lt;li&gt;missing required fields&lt;/li&gt;
&lt;li&gt;whether the tool call was emitted as structured data or plain text&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, if the model emits something that looks like a tool call but the client renders it as text, the agent may continue as if the tool ran even though no tool result exists.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. The tool result
&lt;/h3&gt;

&lt;p&gt;Tool results are often the hidden source of context bloat.&lt;/p&gt;

&lt;p&gt;A single file read, search result, stack trace, or command output can add thousands of tokens to the next turn.&lt;/p&gt;

&lt;p&gt;If the agent suddenly becomes expensive or confused, check what tool results were fed back into the model.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Token usage and latency
&lt;/h3&gt;

&lt;p&gt;Token totals are useful, but per-request token usage is better.&lt;/p&gt;

&lt;p&gt;You want to know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;which request got expensive&lt;/li&gt;
&lt;li&gt;whether input, output, or cache tokens dominated&lt;/li&gt;
&lt;li&gt;whether a request was slow before the first token&lt;/li&gt;
&lt;li&gt;whether repeated turns reused the same large context&lt;/li&gt;
&lt;li&gt;whether a provider returned usage data at all&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That is the difference between "this session was expensive" and "this specific tool result caused the spike."&lt;/p&gt;

&lt;h2&gt;
  
  
  Using ccglass for request-level debugging
&lt;/h2&gt;

&lt;p&gt;ccglass is a local proxy and dashboard for coding-agent traffic.&lt;/p&gt;

&lt;p&gt;It lets you inspect what supported agents actually send to the model:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;system prompts&lt;/li&gt;
&lt;li&gt;messages&lt;/li&gt;
&lt;li&gt;tool schemas&lt;/li&gt;
&lt;li&gt;tool calls&lt;/li&gt;
&lt;li&gt;tool results&lt;/li&gt;
&lt;li&gt;raw request and response bodies&lt;/li&gt;
&lt;li&gt;token/cache/cost&lt;/li&gt;
&lt;li&gt;latency&lt;/li&gt;
&lt;li&gt;turn-to-turn diffs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It works locally. It is open source.&lt;/p&gt;

&lt;p&gt;Install:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; ccglass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Start it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ccglass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or choose a client directly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ccglass claude
ccglass codex
ccglass opencode
ccglass qoder
ccglass codebuddy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For generic OpenAI-compatible or Anthropic-compatible clients, you can also run proxy-only mode:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ccglass proxy &lt;span class="nt"&gt;--provider&lt;/span&gt; openai
ccglass proxy &lt;span class="nt"&gt;--provider&lt;/span&gt; claude
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then point your client or IDE at the printed local base URL.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example debugging workflow
&lt;/h2&gt;

&lt;p&gt;Suppose an agent repeatedly fails to call a tool correctly.&lt;/p&gt;

&lt;p&gt;Instead of changing the prompt first, inspect the actual request flow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open the ccglass dashboard.&lt;/li&gt;
&lt;li&gt;Find the request where the model was expected to call the tool.&lt;/li&gt;
&lt;li&gt;Expand the system prompt and tool schema.&lt;/li&gt;
&lt;li&gt;Check whether the tool was visible to the model.&lt;/li&gt;
&lt;li&gt;Check the model response for the tool call.&lt;/li&gt;
&lt;li&gt;Check whether the tool result was paired correctly.&lt;/li&gt;
&lt;li&gt;Compare the next request to see what context was carried forward.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That gives you a factual answer to questions like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Did the model see the tool?&lt;/li&gt;
&lt;li&gt;Did it call the wrong tool?&lt;/li&gt;
&lt;li&gt;Were the arguments malformed?&lt;/li&gt;
&lt;li&gt;Did the client drop the tool result?&lt;/li&gt;
&lt;li&gt;Did the next turn include the right result?&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Example: debugging token spikes
&lt;/h2&gt;

&lt;p&gt;Another common problem:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Why did this one coding-agent session use so many tokens?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In ccglass, inspect the request list and session summary.&lt;/p&gt;

&lt;p&gt;Look for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a request with unusually high input tokens&lt;/li&gt;
&lt;li&gt;a large tool result entering the next request&lt;/li&gt;
&lt;li&gt;many repeated requests with similar context&lt;/li&gt;
&lt;li&gt;cache usage that is lower than expected&lt;/li&gt;
&lt;li&gt;a slow request with high input size&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then use turn-to-turn diff to see what changed between two requests.&lt;/p&gt;

&lt;p&gt;This is often more useful than looking only at the final cost.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example: debugging provider 400 errors
&lt;/h2&gt;

&lt;p&gt;Provider errors are another good use case.&lt;/p&gt;

&lt;p&gt;If an Anthropic-compatible or OpenAI-compatible endpoint rejects a request, you need the exact payload.&lt;/p&gt;

&lt;p&gt;Check:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;request body&lt;/li&gt;
&lt;li&gt;tool schema&lt;/li&gt;
&lt;li&gt;message order&lt;/li&gt;
&lt;li&gt;tool_use / tool_result pairing&lt;/li&gt;
&lt;li&gt;response or error body&lt;/li&gt;
&lt;li&gt;provider/model name&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is useful when working with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;internal gateways&lt;/li&gt;
&lt;li&gt;OpenRouter&lt;/li&gt;
&lt;li&gt;Ollama-compatible endpoints&lt;/li&gt;
&lt;li&gt;Bedrock or Vertex routes&lt;/li&gt;
&lt;li&gt;Anthropic-compatible translation layers&lt;/li&gt;
&lt;li&gt;OpenAI-compatible coding-agent backends&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The failure is often not "the model is bad." It is often a request-shape problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  Exporting evidence
&lt;/h2&gt;

&lt;p&gt;ccglass can export captured requests:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ccglass &lt;span class="nb"&gt;export&lt;/span&gt; &amp;lt;session&amp;gt;/&amp;lt;&lt;span class="nb"&gt;seq&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;--format&lt;/span&gt; raw
ccglass &lt;span class="nb"&gt;export&lt;/span&gt; &amp;lt;session&amp;gt;/&amp;lt;&lt;span class="nb"&gt;seq&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;--format&lt;/span&gt; md
ccglass &lt;span class="nb"&gt;export&lt;/span&gt; &amp;lt;session&amp;gt;/&amp;lt;&lt;span class="nb"&gt;seq&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;--format&lt;/span&gt; json
ccglass &lt;span class="nb"&gt;export&lt;/span&gt; &amp;lt;session&amp;gt;/&amp;lt;&lt;span class="nb"&gt;seq&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;--format&lt;/span&gt; har
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is useful when reporting bugs to an agent project, provider, or proxy maintainer.&lt;/p&gt;

&lt;p&gt;Instead of saying:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The agent failed.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You can show:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This exact request contained this tool schema, this model response emitted this malformed tool call, and this provider returned this error.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That is much easier to debug.&lt;/p&gt;

&lt;h2&gt;
  
  
  A few practical notes
&lt;/h2&gt;

&lt;p&gt;ccglass is not a universal network sniffer.&lt;/p&gt;

&lt;p&gt;It works best when the client can be pointed at a local base URL or local proxy. For example, API-key based OpenAI-compatible and Anthropic-compatible traffic is a good fit.&lt;/p&gt;

&lt;p&gt;Some clients have special transports. For example, Codex authenticated through ChatGPT login may use a WebSocket path that does not honor &lt;code&gt;OPENAI_BASE_URL&lt;/code&gt;, so local base URL inspection will not see that traffic.&lt;/p&gt;

&lt;p&gt;For CodeBuddy, ccglass uses a forward-proxy mode because CodeBuddy hardcodes its upstream endpoint.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why this matters
&lt;/h2&gt;

&lt;p&gt;As coding agents become more autonomous, debugging needs to move one layer deeper.&lt;/p&gt;

&lt;p&gt;It is no longer enough to ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Did the agent produce the right diff?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You also need to ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;What did the agent see, what tool did it choose, what result came back, and what context entered the next turn?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That is what ccglass tries to make visible.&lt;/p&gt;

&lt;p&gt;GitHub:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/jianshuo/ccglass" rel="noopener noreferrer"&gt;https://github.com/jianshuo/ccglass&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Install:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; ccglass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you build with coding agents, request-level debugging is worth having in your toolbox.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>debugging</category>
      <category>opensource</category>
      <category>devtools</category>
    </item>
    <item>
      <title>Stop Flying Blind with Coding Agents: Inspect Claude Code and Codex Requests with ccglass</title>
      <dc:creator>侯垒</dc:creator>
      <pubDate>Sat, 20 Jun 2026 00:31:18 +0000</pubDate>
      <link>https://dev.to/houleixx/stop-flying-blind-with-coding-agents-inspect-claude-code-and-codex-requests-with-ccglass-1oe8</link>
      <guid>https://dev.to/houleixx/stop-flying-blind-with-coding-agents-inspect-claude-code-and-codex-requests-with-ccglass-1oe8</guid>
      <description>&lt;p&gt;AI coding agents are getting good enough that they no longer feel like autocomplete.&lt;/p&gt;

&lt;p&gt;Tools like Claude Code, Codex, OpenCode, Cursor, Cline, and other agentic coding systems can read files, modify code, run commands, call tools, inspect errors, and continue working across multiple turns.&lt;/p&gt;

&lt;p&gt;That is useful. It is also increasingly opaque.&lt;/p&gt;

&lt;p&gt;When you ask an agent to fix a bug, you usually see the final answer and maybe a few tool calls in the terminal. But you often do not know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What system prompt did the model receive?&lt;/li&gt;
&lt;li&gt;Which messages were included in the request?&lt;/li&gt;
&lt;li&gt;Which tool schemas were shown to the model?&lt;/li&gt;
&lt;li&gt;Why did it choose one tool instead of another?&lt;/li&gt;
&lt;li&gt;What tool result was fed into the next turn?&lt;/li&gt;
&lt;li&gt;How many tokens did the task use?&lt;/li&gt;
&lt;li&gt;Was cache used?&lt;/li&gt;
&lt;li&gt;Which request was slow?&lt;/li&gt;
&lt;li&gt;How much did the session cost?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For small experiments, guessing is fine. For real work, guessing is a bad debugging strategy.&lt;/p&gt;

&lt;p&gt;That is why I built &lt;strong&gt;ccglass&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;GitHub: &lt;a href="https://github.com/jianshuo/ccglass" rel="noopener noreferrer"&gt;https://github.com/jianshuo/ccglass&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is ccglass?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;ccglass is a local observability tool for AI coding agents.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It runs a local proxy, captures model requests and responses, and shows them in a web dashboard.&lt;/p&gt;

&lt;p&gt;The goal is simple: make it easy to see what tools like Claude Code, Codex, DeepSeek-TUI, Kimi, OpenCode, Ollama, OpenRouter, and other agent clients are actually sending to the model.&lt;/p&gt;

&lt;p&gt;ccglass can show:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;system prompts&lt;/li&gt;
&lt;li&gt;user and assistant message history&lt;/li&gt;
&lt;li&gt;tool schemas&lt;/li&gt;
&lt;li&gt;tool calls and tool results&lt;/li&gt;
&lt;li&gt;raw request and response bodies&lt;/li&gt;
&lt;li&gt;token usage&lt;/li&gt;
&lt;li&gt;cache usage&lt;/li&gt;
&lt;li&gt;estimated cost&lt;/li&gt;
&lt;li&gt;latency&lt;/li&gt;
&lt;li&gt;turn-to-turn diffs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is not another coding agent. It is a visibility layer for the agents you already use.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not just use a normal HTTP proxy?
&lt;/h2&gt;

&lt;p&gt;General-purpose tools like Charles, mitmproxy, or Proxyman are great, but AI coding agents can be awkward to inspect with traditional proxy setups.&lt;/p&gt;

&lt;p&gt;Some clients do not reliably honor &lt;code&gt;HTTP_PROXY&lt;/code&gt; / &lt;code&gt;HTTPS_PROXY&lt;/code&gt;. Some have their own networking behavior. Some use provider-specific base URL settings. Patching the client is fragile.&lt;/p&gt;

&lt;p&gt;ccglass takes a more targeted approach.&lt;/p&gt;

&lt;p&gt;It starts a local proxy, then launches or configures the target agent with the right base URL environment variable, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;ANTHROPIC_BASE_URL&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;OPENAI_BASE_URL&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The agent sends model traffic to the local proxy. ccglass logs it, forwards it to the real upstream API, and renders the result in a dashboard.&lt;/p&gt;

&lt;p&gt;That means you can inspect LLM traffic without installing a CA certificate, decrypting TLS, or modifying the client source code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick start
&lt;/h2&gt;

&lt;p&gt;Install ccglass with npm:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; ccglass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ccglass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also start a specific client directly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ccglass claude
ccglass codex
ccglass opencode
ccglass deepseek
ccglass kimi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ccglass codex
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When it starts, ccglass prints a local dashboard URL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dashboard: http://127.0.0.1:57633
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open that URL and you can watch requests appear as the agent works.&lt;/p&gt;

&lt;h2&gt;
  
  
  What can you debug with it?
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Prompt and context problems
&lt;/h3&gt;

&lt;p&gt;Sometimes an agent makes a bad decision because it did not see the context you expected.&lt;/p&gt;

&lt;p&gt;With ccglass, you can inspect the actual messages sent to the model instead of guessing from the terminal output.&lt;/p&gt;

&lt;p&gt;You can answer questions like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Did the file content make it into the request?&lt;/li&gt;
&lt;li&gt;Was the previous tool result included?&lt;/li&gt;
&lt;li&gt;Did a long conversation bury the important instruction?&lt;/li&gt;
&lt;li&gt;Did the system prompt constrain the behavior?&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Tool call behavior
&lt;/h3&gt;

&lt;p&gt;Coding agents are only as good as their tool loop.&lt;/p&gt;

&lt;p&gt;ccglass lets you inspect the tools shown to the model, the tool call selected by the model, the arguments passed to the tool, and the result that was fed back into the next request.&lt;/p&gt;

&lt;p&gt;That is useful when an agent:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;chooses the wrong tool&lt;/li&gt;
&lt;li&gt;repeats the same command&lt;/li&gt;
&lt;li&gt;fails to use an available tool&lt;/li&gt;
&lt;li&gt;gets confused by a tool schema&lt;/li&gt;
&lt;li&gt;behaves differently across providers&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Token and cost spikes
&lt;/h3&gt;

&lt;p&gt;Long-running agent sessions can burn tokens quickly.&lt;/p&gt;

&lt;p&gt;ccglass shows token usage, cache usage, estimated cost, and latency per request and per session.&lt;/p&gt;

&lt;p&gt;That makes it easier to spot:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a huge tool result entering the context&lt;/li&gt;
&lt;li&gt;repeated large prompts&lt;/li&gt;
&lt;li&gt;low cache hit behavior&lt;/li&gt;
&lt;li&gt;slow requests&lt;/li&gt;
&lt;li&gt;expensive turns that did not add much value&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. Provider and proxy issues
&lt;/h3&gt;

&lt;p&gt;If you use local gateways, OpenAI-compatible endpoints, Anthropic-compatible endpoints, OpenRouter, Ollama, Bedrock, Vertex, or internal proxies, request shape matters.&lt;/p&gt;

&lt;p&gt;ccglass helps you compare what the client sent with what the upstream expected.&lt;/p&gt;

&lt;p&gt;This is especially useful when debugging:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;custom &lt;code&gt;base_url&lt;/code&gt; configuration&lt;/li&gt;
&lt;li&gt;Anthropic vs OpenAI-compatible payload differences&lt;/li&gt;
&lt;li&gt;missing tool call fields&lt;/li&gt;
&lt;li&gt;malformed tool arguments&lt;/li&gt;
&lt;li&gt;provider-specific routing&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Exporting requests
&lt;/h2&gt;

&lt;p&gt;You can export captured requests for deeper inspection or bug reports:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ccglass &lt;span class="nb"&gt;export&lt;/span&gt; &amp;lt;session&amp;gt;/&amp;lt;&lt;span class="nb"&gt;seq&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;--format&lt;/span&gt; raw
ccglass &lt;span class="nb"&gt;export&lt;/span&gt; &amp;lt;session&amp;gt;/&amp;lt;&lt;span class="nb"&gt;seq&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;--format&lt;/span&gt; md
ccglass &lt;span class="nb"&gt;export&lt;/span&gt; &amp;lt;session&amp;gt;/&amp;lt;&lt;span class="nb"&gt;seq&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;--format&lt;/span&gt; json
ccglass &lt;span class="nb"&gt;export&lt;/span&gt; &amp;lt;session&amp;gt;/&amp;lt;&lt;span class="nb"&gt;seq&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;--format&lt;/span&gt; har
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That makes it easier to attach useful evidence when reporting issues to an agent, provider, or gateway project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Who is this for?
&lt;/h2&gt;

&lt;p&gt;ccglass is useful if you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;use Claude Code, Codex, OpenCode, or similar coding agents heavily&lt;/li&gt;
&lt;li&gt;build tools around coding agents&lt;/li&gt;
&lt;li&gt;maintain an LLM gateway or proxy&lt;/li&gt;
&lt;li&gt;debug prompt, context, or tool-call behavior&lt;/li&gt;
&lt;li&gt;want to understand token usage and cost&lt;/li&gt;
&lt;li&gt;compare different providers or agent clients&lt;/li&gt;
&lt;li&gt;care about local-first observability instead of sending traces to a SaaS service&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A note on Codex
&lt;/h2&gt;

&lt;p&gt;Codex has multiple auth and transport paths.&lt;/p&gt;

&lt;p&gt;In API-key mode, routing through a configurable base URL works well for local proxy inspection.&lt;/p&gt;

&lt;p&gt;When Codex is authenticated through ChatGPT login, some traffic may use a WebSocket path that does not honor &lt;code&gt;OPENAI_BASE_URL&lt;/code&gt;. In that case, local proxy tools like ccglass cannot see that traffic.&lt;/p&gt;

&lt;p&gt;That distinction matters when debugging Codex routing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why I think this matters
&lt;/h2&gt;

&lt;p&gt;As coding agents become more capable, developers need better tools for understanding agent behavior.&lt;/p&gt;

&lt;p&gt;The interesting question is no longer only:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Did the agent produce the right code?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It is also:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Why did the agent behave that way?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To answer that, you need visibility into prompts, context, tools, requests, latency, and cost.&lt;/p&gt;

&lt;p&gt;ccglass is a small open-source step in that direction.&lt;/p&gt;

&lt;p&gt;GitHub: &lt;a href="https://github.com/jianshuo/ccglass" rel="noopener noreferrer"&gt;https://github.com/jianshuo/ccglass&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Install:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; ccglass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you are building with coding agents and have ever wondered what they actually send to the model, give it a try.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>opensource</category>
      <category>productivity</category>
      <category>devbugsmash</category>
    </item>
    <item>
      <title>Building ccglass: the architecture of a local LLM reverse proxy</title>
      <dc:creator>侯垒</dc:creator>
      <pubDate>Wed, 17 Jun 2026 02:14:58 +0000</pubDate>
      <link>https://dev.to/houleixx/building-ccglass-the-architecture-of-a-local-llm-reverse-proxy-1k07</link>
      <guid>https://dev.to/houleixx/building-ccglass-the-architecture-of-a-local-llm-reverse-proxy-1k07</guid>
      <description>&lt;h2&gt;
  
  
  The 30-second pitch
&lt;/h2&gt;

&lt;p&gt;ccglass is a local reverse proxy that captures LLM API traffic from coding agent CLIs (Claude Code, Codex, DeepSeek, Kimi, etc.) and shows you a real-time dashboard of prompts, costs, and cache hit rates.&lt;/p&gt;

&lt;p&gt;It's open source. It's 5,000 lines of Node. It's MIT licensed.&lt;/p&gt;

&lt;p&gt;GitHub: &lt;a href="https://github.com/jianshuo/ccglass" rel="noopener noreferrer"&gt;https://github.com/jianshuo/ccglass&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The constraint that shaped everything
&lt;/h2&gt;

&lt;p&gt;The hardest part wasn't building a proxy. It was making it work with coding agent CLIs that &lt;strong&gt;deliberately bypass HTTP_PROXY&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Every native CLI (Claude Code is Node, Codex is Node, DeepSeek's CLI is Go, etc.) opens HTTPS sockets directly. They don't honor &lt;code&gt;HTTP_PROXY&lt;/code&gt; env vars. So the standard "man-in-the-middle" pattern (mitmproxy, Charles) doesn't apply — these tools need a CA cert to intercept HTTPS, but the CLI isn't going to trust your CA.&lt;/p&gt;

&lt;p&gt;The trick: &lt;strong&gt;intercept the local loopback hop, not the wire&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The CLI's API base URL is &lt;code&gt;https://api.anthropic.com&lt;/code&gt;. We override it to &lt;code&gt;http://127.0.0.1:8123&lt;/code&gt;. Now the local hop is plain HTTP — no cert, no interception, no TLS. The CLI's Node &lt;code&gt;https&lt;/code&gt; module makes a request to &lt;code&gt;http://127.0.0.1:8123&lt;/code&gt;, which our proxy receives, logs, and forwards to the real &lt;code&gt;https://api.anthropic.com&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Architecture
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌─────────────┐   plain HTTP    ┌─────────────┐    HTTPS    ┌─────────────┐
│  Claude     │ ──────────────▶ │  ccglass    │ ──────────▶ │ Anthropic   │
│  Code CLI   │  127.0.0.1:8123 │  proxy      │             │ API         │
└─────────────┘                 └─────────────┘             └─────────────┘
                                       │
                                       │ log + dashboard
                                       ▼
                                ┌─────────────┐
                                │  Browser    │
                                │  UI :8123   │
                                └─────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3 components:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Spawn wrapper&lt;/strong&gt; — overrides &lt;code&gt;*_BASE_URL&lt;/code&gt; env vars, spawns the CLI as a child process&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Proxy server&lt;/strong&gt; — logs requests, forwards upstream, captures responses (SSE streaming included)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Web UI&lt;/strong&gt; — real-time dashboard, web-socket fed&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What I learned about streaming
&lt;/h2&gt;

&lt;p&gt;The trickiest part: LLM APIs use Server-Sent Events (SSE) for streaming. The CLI expects an &lt;code&gt;openai-sse&lt;/code&gt; or &lt;code&gt;anthropic-sse&lt;/code&gt; stream. We need to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Proxy the response &lt;em&gt;as a stream&lt;/em&gt; (no buffering)&lt;/li&gt;
&lt;li&gt;Tee the stream to the log file (we need every chunk)&lt;/li&gt;
&lt;li&gt;Compute the cost &lt;em&gt;incrementally&lt;/em&gt; as chunks arrive (token counts come in the final chunk)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In Node, this is &lt;code&gt;pipeline()&lt;/code&gt; with a &lt;code&gt;Transform&lt;/code&gt; stream that hashes each chunk and writes it to a side channel. The CLI gets the original stream unchanged.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cost calculation
&lt;/h2&gt;

&lt;p&gt;Each provider has a different pricing model. Cache hits, prompt caching, batch API, all change the math.&lt;/p&gt;

&lt;p&gt;I extracted pricing into a JSON file (&lt;code&gt;data/pricing.json&lt;/code&gt;) keyed by &lt;code&gt;provider:model&lt;/code&gt; and updated monthly. The cost is computed &lt;em&gt;during the response stream&lt;/em&gt; so you see cost accumulating in real time on the dashboard.&lt;/p&gt;

&lt;h2&gt;
  
  
  MCP integration
&lt;/h2&gt;

&lt;p&gt;The wild feature: ccglass has its own MCP (Model Context Protocol) server. When Claude Code starts, it can call our MCP tools. One of them is &lt;code&gt;get_recent_requests&lt;/code&gt; — Claude can query its own request history &lt;em&gt;from inside the chat&lt;/em&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User: what did I prompt you with 3 turns ago?
Claude: [calls ccglass MCP get_recent_requests]
Claude: You prompted me with "refactor the user service to use the new repository pattern".
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's recursive and weird. I love it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's next
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;More providers&lt;/strong&gt; — every new coding agent CLI that ships will need a config&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cost forecasting&lt;/strong&gt; — given your usage pattern, predict next month's bill&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Team sharing&lt;/strong&gt; — local mode stays local, but opt-in to share specific sessions with teammates (encrypted, E2E)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i &lt;span class="nt"&gt;-g&lt;/span&gt; ccglass
ccglass claude
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open the dashboard. Run a few prompts. The first time you see your own cache hit rate, you'll get it.&lt;/p&gt;

&lt;p&gt;GitHub: &lt;a href="https://github.com/jianshuo/ccglass" rel="noopener noreferrer"&gt;https://github.com/jianshuo/ccglass&lt;/a&gt;&lt;/p&gt;

</description>
      <category>node</category>
      <category>claudecode</category>
      <category>opensource</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Why I quit SaaS AI observability tools and built a local proxy instead</title>
      <dc:creator>侯垒</dc:creator>
      <pubDate>Sun, 14 Jun 2026 02:02:55 +0000</pubDate>
      <link>https://dev.to/houleixx/why-i-quit-saas-ai-observability-tools-and-built-a-local-proxy-instead-2i7n</link>
      <guid>https://dev.to/houleixx/why-i-quit-saas-ai-observability-tools-and-built-a-local-proxy-instead-2i7n</guid>
      <description>&lt;h2&gt;
  
  
  A confession
&lt;/h2&gt;

&lt;p&gt;I've been using Langfuse and Helicone for the last 6 months. They're great products. Their teams are sharp.&lt;/p&gt;

&lt;p&gt;But they don't work for coding agents.&lt;/p&gt;

&lt;h2&gt;
  
  
  The mismatch
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Architecture&lt;/th&gt;
&lt;th&gt;Works for coding agents?&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Langfuse&lt;/td&gt;
&lt;td&gt;SDK + async upload to SaaS&lt;/td&gt;
&lt;td&gt;❌ Need to instrument the agent&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Helicone&lt;/td&gt;
&lt;td&gt;HTTPS proxy via HTTP_PROXY&lt;/td&gt;
&lt;td&gt;❌ CLIs ignore HTTP_PROXY&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Datadog LLM Obs&lt;/td&gt;
&lt;td&gt;APM agent&lt;/td&gt;
&lt;td&gt;❌ Same problem&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;ccglass&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Local loopback reverse proxy&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The reason: Claude Code, Codex, OpenCode, Kimi, etc. are &lt;strong&gt;native CLIs&lt;/strong&gt; (Node, Rust, Go). They make HTTPS calls directly to the API endpoint. They do not respect &lt;code&gt;HTTP_PROXY&lt;/code&gt; environment variables.&lt;/p&gt;

&lt;p&gt;So the standard observability play — "just point your SDK at our proxy" — doesn't work. The agent isn't using a library that knows to call your endpoint.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I actually needed
&lt;/h2&gt;

&lt;p&gt;I needed something that would:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Be a &lt;strong&gt;man-in-the-middle on the loopback&lt;/strong&gt; (so it sees plain HTTP)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Forward to the real API&lt;/strong&gt; (so the agent works)&lt;/li&gt;
&lt;li&gt;Be &lt;strong&gt;zero-config&lt;/strong&gt; (the agent already trusts &lt;code&gt;http://127.0.0.1&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Not require a CA cert&lt;/strong&gt; (loopback is plain HTTP)&lt;/li&gt;
&lt;li&gt;Be &lt;strong&gt;local-only&lt;/strong&gt; (no SaaS, no account)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I built it. It's called &lt;a href="https://github.com/jianshuo/ccglass" rel="noopener noreferrer"&gt;ccglass&lt;/a&gt;. It does those 5 things. Nothing else.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it looks like in practice
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;npm i &lt;span class="nt"&gt;-g&lt;/span&gt; ccglass
&lt;span class="nv"&gt;$ &lt;/span&gt;ccglass claude
&lt;span class="c"&gt;# → starts proxy on http://127.0.0.1:8123&lt;/span&gt;
&lt;span class="c"&gt;# → overrides ANTHROPIC_BASE_URL to point at it&lt;/span&gt;
&lt;span class="c"&gt;# → spawns claude&lt;/span&gt;
&lt;span class="c"&gt;# → opens dashboard at http://127.0.0.1:8123&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The dashboard shows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Live request log&lt;/strong&gt; with the full system prompt, tool calls, responses&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Per-request cost&lt;/strong&gt; (with cache-aware pricing)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Per-turn diff&lt;/strong&gt; (what changed in the context this turn)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cache hit rate&lt;/strong&gt; (how often your system prompt is being cached)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Token breakdown&lt;/strong&gt; (input / output / cache_read / cache_write)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What's different from Langfuse / Helicone
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Local-only.&lt;/strong&gt; No data leaves your machine. No account. No API key on their side.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Works for coding agents specifically.&lt;/strong&gt; Built for the HTTP_PROXY-bypass problem.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Single binary, 1-command install.&lt;/strong&gt; No SDK to integrate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Open source&lt;/strong&gt; under MIT. You can read every line.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What's the same
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Token accounting&lt;/li&gt;
&lt;li&gt;Per-request cost&lt;/li&gt;
&lt;li&gt;Latency tracking&lt;/li&gt;
&lt;li&gt;Provider routing (multiple model providers)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why I'm sharing this
&lt;/h2&gt;

&lt;p&gt;If you use a coding agent heavily, and you don't know which of your prompts are 4,000 tokens of accidental repetition, you're leaving money on the table.&lt;/p&gt;

&lt;p&gt;The first time I saw my own cache hit rate (38% — meaning I was re-sending the same system prompt 38% of the time and not knowing it), I had a "wait, that's literally me paying for nothing" moment.&lt;/p&gt;

&lt;p&gt;Try it once. The data is eye-opening.&lt;/p&gt;

&lt;p&gt;🔗 GitHub: &lt;a href="https://github.com/jianshuo/ccglass" rel="noopener noreferrer"&gt;https://github.com/jianshuo/ccglass&lt;/a&gt;&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>opensource</category>
      <category>llm</category>
      <category>webdev</category>
    </item>
    <item>
      <title>I built a local reverse proxy to see what Claude Code actually sends to Anthropic</title>
      <dc:creator>侯垒</dc:creator>
      <pubDate>Wed, 10 Jun 2026 07:08:09 +0000</pubDate>
      <link>https://dev.to/houleixx/i-built-a-local-reverse-proxy-to-see-what-claude-code-actually-sends-to-anthropic-5foo</link>
      <guid>https://dev.to/houleixx/i-built-a-local-reverse-proxy-to-see-what-claude-code-actually-sends-to-anthropic-5foo</guid>
      <description>&lt;h2&gt;
  
  
  The problem I couldn't solve
&lt;/h2&gt;

&lt;p&gt;I was spending ~$1,800/month on Claude Code.&lt;/p&gt;

&lt;p&gt;I had no idea where the money was going. I had no idea which prompts were 4,000-token monstrosities, which ones were 200-token gems, or which ones I'd accidentally repeated 3 times this week.&lt;/p&gt;

&lt;p&gt;I tried the obvious tools first:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;mitmproxy&lt;/strong&gt; — didn't work. Claude Code (and Codex, DeepSeek, Kimi, GLM, etc.) all ignore &lt;code&gt;HTTP_PROXY&lt;/code&gt; because they're native CLIs that open HTTPS sockets directly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Charles&lt;/strong&gt; — same problem.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Langfuse / Helicone&lt;/strong&gt; — these are SaaS. You have to send your data to them. Not what I wanted.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Custom hooks&lt;/strong&gt; — limited to events the CLI exposes. I wanted the raw HTTP.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I wanted &lt;strong&gt;a local, open-source, zero-account way to see what my coding agent was doing&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The solution: a local reverse proxy on the loopback
&lt;/h2&gt;

&lt;p&gt;The insight: every coding agent CLI talks to &lt;code&gt;api.anthropic.com&lt;/code&gt; (or similar). If I make it talk to &lt;code&gt;http://127.0.0.1:port&lt;/code&gt; instead, and have a tiny proxy on that port forward to the real API, &lt;strong&gt;the local hop is plain HTTP&lt;/strong&gt; — easy to log, no CA cert, no TLS pinning pain.&lt;/p&gt;

&lt;p&gt;That's it. That's the whole trick.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i &lt;span class="nt"&gt;-g&lt;/span&gt; ccglass
ccglass claude
&lt;span class="c"&gt;# → opens http://localhost:8123 in your browser&lt;/span&gt;
&lt;span class="c"&gt;# → real-time dashboard of every request&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What I learned in 30 days
&lt;/h2&gt;

&lt;p&gt;After running every Claude Code session through it, I found:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. I had a 38% cache hit rate I didn't know about
&lt;/h3&gt;

&lt;p&gt;I was repeating myself in 38% of prompts and paying full price. The dashboard made it visible. I rewrote my CLAUDE.md to front-load context — cache hit rate jumped to 70%, monthly bill dropped 35%.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Per-provider cost varies 10x
&lt;/h3&gt;

&lt;p&gt;Same task:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Claude Sonnet 4.6: $0.42&lt;/li&gt;
&lt;li&gt;GPT-4o: $0.31&lt;/li&gt;
&lt;li&gt;DeepSeek: $0.04&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I started picking per-task. Anthropic for quality, DeepSeek for bulk.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Turn counts were higher than I thought
&lt;/h3&gt;

&lt;p&gt;Average 4.2 turns per task. After seeing the data, I rewrote my CLAUDE.md. Turn count dropped to 2.8. Less back-and-forth = less cost = faster delivery.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. MCP self-inspection is wild
&lt;/h3&gt;

&lt;p&gt;ccglass has an MCP server. When you run &lt;code&gt;ccglass claude&lt;/code&gt;, the agent can query its own request history &lt;em&gt;inside the chat&lt;/em&gt;. I asked Claude "what did I prompt you with 3 turns ago?" and it answered correctly.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's supported
&lt;/h2&gt;

&lt;p&gt;16+ providers out of the box:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Coding agents&lt;/strong&gt;: Claude Code, Codex, OpenCode, CodeBuddy, Reasonix&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pure LLM APIs&lt;/strong&gt;: Anthropic, OpenAI, DeepSeek, Kimi, GLM, OpenRouter&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cloud&lt;/strong&gt;: AWS Bedrock, GCP Vertex AI&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Local&lt;/strong&gt;: Ollama, LM Studio&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The limits (I want to be honest)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Cursor subscription models&lt;/strong&gt; can't be intercepted (they use a server-side proxy).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;VS Code Continue&lt;/strong&gt; with built-in models: same.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It's local-only by design.&lt;/strong&gt; No SaaS, no telemetry, no account. (If you want cloud, use Langfuse.)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Open source
&lt;/h2&gt;

&lt;p&gt;GitHub: &lt;a href="https://github.com/jianshuo/ccglass" rel="noopener noreferrer"&gt;https://github.com/jianshuo/ccglass&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;460+ stars at time of writing. MIT licensed. PRs welcome.&lt;/p&gt;

&lt;p&gt;If you ship with Claude Code / Codex / Kimi and have ever asked "where is my money going", try it once. The data is eye-opening.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>claudecode</category>
      <category>opensource</category>
      <category>devtools</category>
    </item>
    <item>
      <title>Make Your AI Coding Agent Transparent - See What It Actually Sends to the Model</title>
      <dc:creator>侯垒</dc:creator>
      <pubDate>Wed, 10 Jun 2026 02:46:06 +0000</pubDate>
      <link>https://dev.to/houleixx/make-your-ai-coding-agent-transparent-see-what-it-actually-sends-to-the-model-4inn</link>
      <guid>https://dev.to/houleixx/make-your-ai-coding-agent-transparent-see-what-it-actually-sends-to-the-model-4inn</guid>
      <description>&lt;p&gt;If you've been using AI coding agents like Claude Code or Codex, you know how powerful they can be. But they also feel like a black box. What's actually in that system prompt? How much context is being sent every turn? Where are all my tokens going?&lt;/p&gt;

&lt;p&gt;I recently found a tool called ccglass that answers these questions beautifully, and I wanted to share my experience.&lt;/p&gt;

&lt;p&gt;What is ccglass?&lt;br&gt;
ccglass is a lightweight local tool that acts as a reverse proxy between your AI coding agent and the model API. It intercepts all requests and responses, logs them, and displays them in a really nice web dashboard.&lt;/p&gt;

&lt;p&gt;ccglass Dashboard&lt;/p&gt;

&lt;p&gt;Getting Started&lt;br&gt;
Installation is simple (Node.js 18+ required):&lt;/p&gt;

&lt;p&gt;npm install -g ccglass&lt;/p&gt;

&lt;p&gt;Then just run it and pick your agent:&lt;/p&gt;

&lt;p&gt;ccglass&lt;/p&gt;

&lt;p&gt;Or specify directly:&lt;/p&gt;

&lt;p&gt;ccglass claude      # for Claude Code&lt;br&gt;
ccglass codex       # for Codex&lt;br&gt;
ccglass deepseek    # for DeepSeek-TUI&lt;/p&gt;

&lt;p&gt;It will:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Start a local proxy server&lt;/li&gt;
&lt;li&gt;Set the right environment variables automatically&lt;/li&gt;
&lt;li&gt;Launch the agent for you&lt;/li&gt;
&lt;li&gt;Open the web dashboard&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That's it! No CA certificates to install, no complicated setup.&lt;/p&gt;

&lt;p&gt;What You Can See&lt;/p&gt;

&lt;p&gt;The dashboard shows you everything:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The Full System Prompt&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is probably the most interesting part. You get to see how different agents frame their instructions to the model. Claude Code's system&lt;br&gt;
prompt is fascinating to read!&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Complete Message History&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;See the full context being sent each turn, how it evolves, and what gets kept vs. dropped.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Tool Schemas and Calls&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;See what tool definitions the agent provides to the model, and what tool calls the model makes in response.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Token and Cost Breakdown&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Know exactly how many tokens you're using, what's cached, and get cost estimates per request and per session.&lt;/p&gt;

&lt;p&gt;Token Summary &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcoqn2p5y4umhy7rglkxs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcoqn2p5y4umhy7rglkxs.png" alt=" " width="800" height="337"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Turn-by-Turn Diff View&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Compare requests to see exactly what changed between turns. Super useful for debugging why an agent started behaving differently.&lt;/p&gt;

&lt;p&gt;Supported Agents&lt;/p&gt;

&lt;p&gt;The list is pretty extensive:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Claude Code (including Bedrock and Vertex modes)&lt;/li&gt;
&lt;li&gt;Codex (OpenAI)&lt;/li&gt;
&lt;li&gt;DeepSeek-TUI and Reasonix&lt;/li&gt;
&lt;li&gt;Kimi (Moonshot)&lt;/li&gt;
&lt;li&gt;OpenCode&lt;/li&gt;
&lt;li&gt;Ollama&lt;/li&gt;
&lt;li&gt;OpenRouter&lt;/li&gt;
&lt;li&gt;GLM/Zhipu&lt;/li&gt;
&lt;li&gt;CodeBuddy (VS Code/JetBrains plugins)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;IDE Support&lt;/p&gt;

&lt;p&gt;If you use Cursor, Cline, Continue.dev, or similar IDEs that let you set a custom API base URL, you can use the proxy mode:&lt;/p&gt;

&lt;p&gt;ccglass proxy --provider openai&lt;/p&gt;

&lt;p&gt;Then just point your IDE's API base URL to the local proxy address it gives you.&lt;/p&gt;

&lt;p&gt;Why I Like This&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Learn from the best - See how production-grade agent systems are built&lt;/li&gt;
&lt;li&gt;Debug effectively - Understand why your agent is making certain choices&lt;/li&gt;
&lt;li&gt;Optimize costs - See where your tokens are actually going&lt;/li&gt;
&lt;li&gt;Local only - All logs stay on your machine (default redacts auth tokens)&lt;/li&gt;
&lt;li&gt;MIT licensed - Completely open source&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Pro Tip: Export for Documentation&lt;/p&gt;

&lt;p&gt;You can export any request to raw HTTP, Markdown, JSON, or HAR format:&lt;/p&gt;

&lt;p&gt;ccglass export / --format md&lt;/p&gt;

&lt;p&gt;Great for documentation, bug reports, or just saving interesting prompts.&lt;/p&gt;

&lt;p&gt;Try It Out&lt;/p&gt;

&lt;p&gt;If you're using any AI coding agent regularly, I highly recommend giving ccglass a try. It will change how you think about these tools.&lt;/p&gt;

&lt;p&gt;Install it now:&lt;/p&gt;

&lt;p&gt;npm install -g ccglass&lt;/p&gt;

&lt;p&gt;Check out the project: github.com/jianshuo/ccglass&lt;/p&gt;




&lt;h2&gt;
  
  
  What's your favorite AI coding agent? Have you found any good tools for understanding them better? Let me know in the comments!
&lt;/h2&gt;

</description>
      <category>agents</category>
      <category>ai</category>
      <category>monitoring</category>
      <category>tooling</category>
    </item>
  </channel>
</rss>
