トークン節約術を研究して全トークンを燃やした話
著者がトークン節約術を研究する過程で逆説的に全トークンを消費してしまったという、AI コスト管理の難しさを皮肉に描いた体験談である。
キーポイント
コスト削減研究のパラドックス
トークン使用量を減らすための調査自体が膨大なトークンを消費するという、目的と手段の矛盾が生じた事例。
リソース管理の難しさ
効率的な運用を目指す行為が、逆にリソース枯渇を招くという、AI 利用における逆説的なリスクを示している。
実証的教訓
理論上の最適化策を探す前に、実際の使用パターンやコスト構造を理解する重要性が浮き彫りになった。
重要な引用
I burned all my tokens researching how to save tokens
(12 minute read)
影響分析・編集コメントを表示
影響分析
この記事は、AI リソース管理における直感に反する現象を浮き彫りにし、コスト最適化の難しさを皮肉かつ具体的に伝えています。開発者や組織に対して、単なる節約策の追求ではなく、リソース消費のプロセス自体を監視・分析する重要性を再認識させる内容です。
編集コメント
「節約のために使う」という皮肉な状況は、AI コスト管理の難しさを象徴的に表しています。この事例は、効率化のための調査自体がリソースを消費するリスクを理解する上で有益です。
2026 年 7 月 19 日、Hacker News のトップページに掲載された記事
Quesma では AI エージェントの経済性について研究を進めています。具体的には、エージェントによるコーディングが実際にどれほどのコストを伴うのか、そしてそれをどうコントロールすべきかを追求しています。この研究の一環として、私が信頼できる知識基盤を構築するための独自のリサーチ環境(ディープ・リサーチ・セットアップ)を運用しています。しかし、その最初のバージョンは Claude Max 5x プランの制限枠をわずか 30 分で使い果たしてしまいました。
本稿では、このコストと信頼性の問題を、すでに契約しているサブスクリプションのみでどう解決したか、そしてあなたも同様の仕組みを構築できるのかについてお話しします。
私の目標は、「トークノミクス」と呼ばれる分野の全体像を把握することでした。どのような監視システムが存在し、チームは AI への支出をどのようにガバナンスしているのか。さらに、論文や実社会において実際に効果を発揮する最適化ツールとプラクティスは何か——それらすべてを知りたかったのです。
まずは定番の方法として、/deep-research コマンドを使ってみました。大きな問いを投げかけて実行させると、約 30 分後に制限に達し、数時間の待機を余儀なくされました。しかも、得られた結果はゼロでした。このランでは 111 のエージェントが起動され、検証のために 123 の主張がキューに入れられましたが、制限に到達する前に検証されたのはわずか 25 件。最終的な合成処理すら実行されることはありませんでした。
これは私にとって非常にリアルな体験となりました。そして少し皮肉なことに、トークンの最適化方法を発見している最中に、すでにその最適化自体を迫られることになったのです。まさに「やりながら学ぶ」状況でした。
既に契約しているサブスクリプションをすべて活用する
Claude Fable 5 が公開されてから 30 分経っても、/deep-research を使えば莫大なトークンを消費するだけで結果が得られない場合、どうすれば研究を効果的に進められるでしょうか。そこで私は、すでに所有し、支払い済みのツールを見直しました。Claude、Codex、Antigravity——これら 3 つのサブスクリプションがあれば、理論上は追加費用なしでトークン使用量を 3 倍に増やせます。もしこれらのツールを共有メモリ機能で連携させればどうなるでしょうか。
私はすでに claude-mem プラグインを利用していたため、これを拡張して Codex と Antigravity もローカル環境で使用できるようにしました。これにより、3 つのツールがセッション中に共通のメモリを共有できるようになり、あるツールで学習した情報を他のツールも活用できます。
低コストモデルをサブエージェントとして活用する
私のデフォルト設定は Claude Code です。これをメインのハーン(制御基盤)として使いながら、手動で調査を進めているうちに、まさに今必要だった「モデルオーケストレーション」のパターンに気づきました。実は Fable をすべてのタスクに使わなくてもいいのです。Claude Opus 4.8、Claude Sonnet 5、GPT-5.5、Gemini 3.1 Pro は、すでに多くの用途で優れた性能を発揮するモデルです。

Claude Code をハーンとして、ネイティブの Claude エージェントに加え、Codex と Antrigavity をヘッドレスのサブエージェントとして配置し、すべてが claude-mem でメモリを共有する構成です。
いくつかのベンチマークとコスト分析を確認しました。ターミナルやエージェント作業については主に Terminal-Bench を、エンドツーエンドのソフトウェアエンジニアリングには SWE-bench Pro を、性能と価格の全体像を把握するには Artificial Analysis を参照しました。これらを絶対的な真実として扱うつもりはありません。ベンチマークはそれぞれ独自の指標を測るものであり、数値も月ごとに変動します。必要なのは「どのモデルが何に得意か」を示す大まかな出発点だけで、当初から複数のモデルを組み合わせて実験する予定でしたし、実際の運用後に構成を見直すことも想定していました。
| ロール | モデル | 選定理由 |
|---|---|---|
| 検索 (Find) | Claude Sonnet 5 | エージェント系ベンチマークに強く、大量実行にもコスト面で耐えられる |
| 検証 (Verify) | Claude Opus 4.8 | Claude シリーズの中で最も精度が高い。検索よりも正確な確認が必要になる場面で活躍 |
| 判断・計画 (Judge & plan) | Claude Fable 5 | コストが最も高いため、計画立案、タスク分解、および紛争解決に限定して使用 |
| 小規模処理 (Small stuff) | Claude Haiku 4.5 | 抽出や書式変換には安価で高速。ただし多段階の作業には不向き |
| ツール実行 (Run tools) | Codex (GPT-5.5) | ターミナル系ベンチマークに非常に強く、ツールの複製・インストール・実行・検査を得意とする |
| 第二意見 (Second opinion) | Antigravity (Gemini 3.1 Pro) | 異なるモデルファミリーのため、同じ盲点を持つことがない |
この構成は最初から決まっていたわけではありません。実際の運用で弱点が露呈した際に何度か調整し、その失敗経験をもとにフォールバックルールも策定しました。
ここで最も素晴らしいのは、Codex と Antigravity を Fable がオーケストレーションする Claude のサブエージェントとして活用した点です。両者のヘッドレス機能を最大限に生かしています。
なぜこれが魅力的なのかと言えば、トークン消費が Codex と Antigravity のサブスクリプションから賄われるため、追加費用がかからないのに、即座に利用可能な知能リソースを大幅に増やせるからです。
肝となるのは、Claude エージェントが他のコマンドと同様に呼び出せる小さな Bash スクリプトです。
run-cli: 他ベンダーの CLI をヘッドレスなサブエージェントとして呼び出す
usage: run-cli <codex|antigravity> "<プロンプト>"
VENDOR="$1"; PROMPT="$2"
case "$VENDOR" in
codex) OUT="$(codex exec --sandbox read-only "$PROMPT")" ;;
antigravity) OUT="$(agy --model "Gemini 3.1 Pro (High)" -p "$PROMPT")" ;;
esac
echo "$OUT"
echo "$OUT" | claude-mem-save -s "$VENDOR" # 共有メモリ(ローカル拡張版の claude-mem)に保存
このラッパーは出力を監視し、「利用制限」や「クレジット切れ」といったメッセージを検出すると、特別な終了コードを返します。これが Claude モデルへの自動フォールバックを実現する仕組みです。オーケストレーターがそのシグナルを検知すると、Claude エージェントに処理を引き継ぎます。
もう一つ重要なのは、役割ごとにモデルを固定することです。サブエージェントはデフォルトで親のモデルを継承するため、これを怠った結果、私は Fable の利用制限をわずか 30 分で使い果たしてしまいました。
この手法を導入したおかげで、Fable のみを使用していた当初に比べて、3 つのサブスクリプションいずれかが上限に達するまでの稼働時間を単純計算で約 10 倍延長できました。具体的には、以前は 30 分しか続けられなかった研究が、追加費用を一切かけずに数時間にわたって継続できるようになったのです。もし Codex や Antigravity がそれぞれの利用制限に到達しても、フレームワークは自動的に Claude モデルへ切り替わるため、調査自体が止まることはありません。
ハルシネーション(幻覚)の削減
コストの問題は最初の課題でしたが、2 つ目の問題は信頼性でした。私の研究フレームワークが登場する前は、すべての処理を Fable に任せていたため、一見すると確かな根拠があるように見えるが実際には誤りであるという発見に遭遇することがありました。例えば、リポジトリのライセンス情報が間違っていたり、出典のない節約額の数値を提示したり、引用したページに記載されていない数字を挙げていたりするケースです。
こうしたハルシネーションを防ぐため、研究フレームワーク内に「共有前に必ず通過しなければならない」という明確なルールを実装しました。主なルールは以下の通りです。
- 主張を発見した者が自ら検証することはなく、別のモデルまたはエージェントがリンク、引用、数値を確認する。
- URL と一次情報源からの引用がない限り、知識ベースに記録しない。
- ソースページに記載されていない数字を述べてはいけない。
このルールリストは最初から設計されたものではなく、研究の過程で徐々に成長したものです。検証プロセスで新たな種類のミスが検出されるたびに、そのルールをプロンプトに追加していくのです。このようなフレームワークが真に効果を発揮するのは、継続的にチューニングし続ける場合に限られます。発見された知見を見直し、無効なルールを除外してフィードバックループに戻すことが重要です。
/deep-research は最後に実行する
コスト管理と信頼性の確保が整った後、残る最後のピースがこの物語の発端となった「/deep-research」ツールです。まだ開発中の段階ですが、最初のステップではなく最終ステップとして位置づけられています。毎日終了時には、すでに検証を通過した知見に対してこのツールを実行します。盲目的に調査するのではなく、既存の知見を深掘りし、不要な情報を整理整頓し、フレームワークが見逃していたギャップを埋めようとするのです。また、この方法ではトークン使用量も削減できます。なぜなら、インターネットを探索するのではなく、固定された主張リストに基づいて処理を行うからです。
最終実行では 61 個のエージェントが稼働し、22 分間で完了しました。これに対し、最初の日は 111 個のエージェントが約 30 分でトークン制限をすべて使い果たしてしまい、レポートすら作成できませんでした。同じツールでも、扱う作業の規模が全く異なるのです。

このパイプラインを一言で表すと、「発見→検証→評価→ツール実行→深層検証→ウィキへの公開」という流れです。
結果:信頼できるナレッジベースの構築
検証を通過した情報はすべて、私が Obsidian で管理している LLM ウィキに蓄積されます。このウィキは Karpathy の LLM ウィキパターン にインスパイアされたもので、リンクでつながる原子的なノート、自動で情報を収集するエージェント、そして私が設定したルールという 3 つの要素で成り立っています。運用から 1 週間が経過した現在、価格、ツール、ベンチマーク、プラクティスに関する数百件の検証済みノートが登録されています。

これまでに蓄積されたのは、価格やツール、ベンチマークに関する数百のノートです。
自動チェックだけでは不十分でした。かつて、私のトリアージルールが静かに Headroom の登録を拒否したことがありました。これは 56k スターを獲得し、同カテゴリで最大規模のプロジェクトの一つです。エージェントは検索と確認という役割を完璧に果たしましたが、検証プロセスも「プロジェクト自体は信頼できる」と判断しました。しかし、主張された節約額の数値が品質管理されていないことを示すチェック項目が正しく反応したため、私のルールが「未検証の主張がある場合は登録不可」という判断を下し、業界の半分以上が利用しているプロジェクトが私のナレッジベースから姿を消してしまいました。私がこれに気づいたのは 2 日後、「なぜこれを逃したのか?」と尋ねた時でした。
解決策は新しいルールの導入です。「主張」自体は拒否するが、「プロジェクト」の登録は許可するというルールです。エージェントには検索や確認の役割を任せることができますが、自分の設定したルールこそがバグである可能性に気づかせてくれるのは、人間である私しかいません。
質の高いナレッジベースを構築するには、人間の検証と調査の補完が必須です。AI だけの調査では品質が著しく低下する傾向があります。一方、人間だけで行うと速度が遅すぎます。最も効果的なのはハイブリッド型で、エージェントが重労働となる調査を担当し、そのパイプラインは人間が設計・常時改善します。人間は結果を検証し、不足している部分を補う役割を担います。
ナレッジベースから得られたいくつかの知見
トークン経済学というテーマは、私が想定していたよりも遥かに広範であることがわかりました。すでに蓄積されている内容の一部を紹介すると、特に驚いた点は以下の通りです。
- モデルそのものと同じくらい、それを動かす「ハルネス(環境)」も重要になります。Terminal-Bench の結果では、同じモデルでもハルネスの違いでトークン使用量が約 66 倍も変動しました。むしろ簡素な設定の方がスコアが高くなるケースさえあります。別の研究でも、ハルネスを変えるだけで同一モデルのスコアが約 54 ポイントも変動することが確認されています。私たち自身も、AI エージェントに「こんにちは」と挨拶する際の真のコストを検証した際、この現象を小さく体験しました。
コンテキスト圧縮は、コストを節約するどころか請求額を倍増させる可能性があります。"圧縮"という言葉から誤解されがちですが、これは無料ではありません。モデルが履歴を要約する必要があり、その要約自体もトークンを消費します。また、エージェントがまだ必要としているファイルを削除してしまうリスクもあり、結果としてエージェントは再度それらを読み込み、コンテキストが再び満杯になり、圧縮が再発するという悪循環に陥ります。
実際に記録された事例では、あるハーン(検証環境)が圧縮の閾値を調整したところ、1 セッションあたりの圧縮回数が 4 回から 12〜26 回へと急増。同じタスクを実行しても、トークン使用量は 8900 万から 1.6 億〜1.85 億に跳ね上がりました。
セッションの途中でツールを変更すると、請求が静かに再計算されることがあります。キャッシュからの読み出しは基本入力価格の約 0.1 倍で済みますが、キャッシュ無効化は階層的に行われます(ツール→システム→メッセージ)。セッション中にツールスキーマを 1 つ追加したり順序を入れ替えたりしただけで、キャッシュされたプレフィックス全体が全額請求の対象となります。エラー表示はなく、請求書だけが大きくなるのです。
トークンカウンターと実際の請求額は一致しません。ある事例では、計算上は月額 3.60 ドルと見込まれていたものが、実際には月額 25〜40 ドルの請求となりました。これはコンテキストの蓄積、リトライによる増幅、フレームワークのオーバーヘッド、単純なトークン見積もりでは捉えきれない評価呼び出しなどが複合した結果で、7〜11 倍もの乖離が生じています。
当社のフレームワークでは、これらのリスク要因の多くを「中程度の信頼度」としてタグ付けしています。通常は 1〜2 の確実な情報源に基づいていますが、確定的な結論であるかのように扱うのではなく、その不確実性を可視化し続ける方針です。
次の制限に到達する前に
必ず JSON 形式で返してください。translation フィールドのみ。他のフィールドは一切追加しないこと — 余計なフィールドを書こうとして本文がトークン上限で打ち切られる事故を防ぐため:
{"translation": "リライト全文"}
もし今日、深いリサーチのために利用制限を燃やしているなら、順序を逆転させてみてください。安価なモデルで見つけ出し、正確なモデルで検証し、最後に深いリサーチを行うのです。また、すでに支払っている知能の量も確認しましょう。各モデルに明確な役割を持たせた数種類のサブスクリプションを利用すれば、盲目的に使われる単一の最先端モデルよりもはるかに多くの成果が得られます。
もしご自身で研究パイプラインを構築中の方や、AI の利用料金が使用量の増加より早く膨らんでいるという方は、ぜひ声をかけてください。Hacker News や LinkedIn で議論に参加してください。
今後の投稿やリリースも楽しみにしていてください。
原文を表示
On the Hacker News front page on 19 Jul 2026
At Quesma we are researching the economics of AI agents: what agentic coding really costs and what you can do about it. For this research I am running my own deep research setup, a pipeline of agents that builds a knowledge base I can actually trust. The first version of this setup burned the whole limit of my Claude Max 5x plan in 30 minutes. This post is the story of how I fixed the cost and the trust, using only subscriptions I already pay for, and how you can build the same.
My goal was to understand the entire state of so-called tokenomics. I wanted to know what monitoring systems exist, how teams govern their AI spend, and which optimization tools and practices actually work, both in the papers and in the real world.
I started the usual way, with /deep-research. I gave it the big open question and let it run. After around 30 minutes of research, I hit a limit and had to wait a few hours for it to reset. And I had no results. The run launched 111 agents and queued 123 claims for verification, but only 25 got verified before the limit hit, and the final synthesis never ran.
So, it hit me personally. And this is a bit funny: from the very first day I had to optimize tokens while still discovering how to optimize tokens. Learning by doing.
Using every subscription I already pay for
If Claude Fable 5 is out after 30 minutes and /deep-research is consuming so many tokens without giving me any results, what can I do to make the research more effective? I started thinking about what kind of tools I already have and pay for. Claude, Codex, and Antigravity: 3 subscriptions, and in theory 3 times more tokens without paying anything extra. What if I use all of these tools together, with shared memory?
Since I am already using the claude-mem plugin I extended it to support Codex and Antigravity locally, so that all 3 tools can use shared memory during sessions. Whatever one tool learns, the others can use.
Cheaper models as subagents
My default setup is Claude Code, so I used it as the main harness. While doing the research manually, I discovered a model-orchestration pattern, which was exactly what I needed at that moment. We don’t really need Fable for everything: Claude Opus 4.8, Claude Sonnet 5, GPT-5.5, and Gemini 3.1 Pro are already excellent models for many tasks.

So I checked a few benchmarks and cost analyses, mostly Terminal-Bench for terminal and agentic work, SWE-bench Pro for end-to-end software engineering, and Artificial Analysis for a general view of performance and prices. I did not treat any of them as the final truth; benchmarks measure their own thing and the numbers move every month. I just needed a loose starting point for who is good at what, and using several different models was part of the experiment from the beginning; I expected to adjust the split after real runs anyway:
Role
Model
Why this one
Find
Claude Sonnet 5
Strong on agentic benchmarks and cheap enough to run in bulk
Verify
Claude Opus 4.8
The most accurate Claude worker; checking needs more accuracy than searching
Judge & plan
Claude Fable 5
The most expensive one, so it only plans, decomposes, and resolves disputes
Small stuff
Claude Haiku 4.5
Cheap and fast for extraction and formatting, too weak for multi-step work
Run tools
Codex (GPT-5.5)
Very strong on terminal benchmarks; clones, installs, runs, and inspects tools
Second opinion
Antigravity (Gemini 3.1 Pro)
A different model family, so it does not share the same blind spots
This split was not my first version; I adjusted it a few times when live runs showed weaknesses, and the fallback rules came from those failures.
The best thing here is that I prepared Codex and Antigravity to be used as Claude subagents, orchestrated by Fable, using the headless nature of both. Why is it cool? Because tokens are taken from the Codex and Antigravity subscriptions, so I was not paying extra, but I instantly had much more intelligence to use.
The whole trick is one small Bash script that my Claude agents can call like any other command:
# run-cli: call another vendor's CLI as a headless subagent
# usage: run-cli <codex|antigravity> "<prompt>"
VENDOR="$1"; PROMPT="$2"
case "$VENDOR" in
codex) OUT="$(codex exec --sandbox read-only "$PROMPT")" ;;
antigravity) OUT="$(agy --model "Gemini 3.1 Pro (High)" -p "$PROMPT")" ;;
esac
echo "$OUT"
echo "$OUT" | claude-mem-save -s "$VENDOR" # save to shared memory (my locally extended claude-mem)The wrapper also watches the output for “usage limit” and “out of credits” messages and returns a special exit code, and this is exactly how the automatic fallback to Claude models works: the orchestrator sees the signal and does the work with a Claude agent instead.
One more thing that really matters is to pin the model per role, because subagents inherit their parent’s model by default, and that is exactly how I burned my Fable limit in 30 minutes.
With this technique I was able to run the research continuously for roughly 10 times longer than initially with Fable only, measured simply as how long I can keep the agents working before any of the 3 subscriptions hits a limit. Before it was 30 minutes of research, now it is a few hours, without paying a single penny more. And when Codex or Antigravity hits its own limit, the framework simply falls back to Claude models, so the research does not stop.
Reducing hallucinations
Cost was only the first problem, the second one was trust. Before my research framework, when everything was done by Fable, I was sometimes getting findings that looked solid but were not true. For example, a wrong license on a repo, a savings figure with no source, or a number that was not on the cited page. To reduce hallucinations, I implemented explicit rules in the research framework that every finding must pass before it can be shared. A few of them:
- Whoever finds a claim never verifies it, a different model or agent checks the links, quotes, and numbers.
- Nothing lands in the knowledge base without a URL and a quote from the primary source.
- Never state a number the source page doesn’t contain.
This list was not designed upfront. It grew during the research, because every time verification caught a new class of mistake, the rule went back into the prompts. And such a framework is really effective only if you keep tuning it, so review the findings, flag the useless ones, and feed that back.
/deep-research goes last
With cost and trust handled, the last piece was the /deep-research tool that started this whole story. It is still in the pipeline, but as the last step, not the first. At the end of each day I run it over the findings that already survived verification, so instead of researching blindly it goes through the existing findings, deepens them, eliminates the mess, and tries to fill the gaps that the framework missed. It also uses fewer tokens this way, because it works through a fixed list of claims instead of exploring the internet. The last run used 61 agents and took 22 minutes. Compare that to day one, when 111 agents burned the whole limit in around 30 minutes and never produced the report. Same tool, just a much smaller job.

The result: a knowledge base I can trust
Everything that survives verification lands in an LLM wiki I keep in Obsidian, inspired by Karpathy’s LLM wiki pattern: linked atomic notes, agents doing the sweeps, and me setting the rules. One week in, it holds hundreds of validated notes on pricing, tools, benchmarks, and practices.

Automated checks aren’t enough on their own. Once, my triage rule quietly rejected Headroom, a 56k-star project and one of the biggest in its category. The agents did everything right, verification confirmed the project is legit, and a claim check correctly flagged that its headline savings numbers were not quality-controlled. But my rule said “unvalidated claims mean no entry”, so a project half the industry uses was invisible in my knowledge base. I only noticed 2 days later, when I asked “how did we miss this?” The fix was a new rule: reject the claim, not the project. Agents can do the searching and checking, but no agent will ever tell you that your own rule is the bug.
If you want to build a quality knowledge base, human verification and research supplementation are mandatory. AI-only research can be really poor quality. Human-only research is too slow. The best way is a hybrid one: agents do the heavy research work, but they run on a pipeline crafted and constantly improved by a human. The human also verifies the results and fills the gaps.
A few findings from the knowledge base
The token economics topic turned out to be much larger than I expected. Here is a small sample of what is already inside, the findings that surprised me the most:
- Your harness can matter as much as your model. On Terminal-Bench the same model shows a ~66x token spread across different harnesses, and the thinner setups actually score higher, not lower. Another study measured a swing of about 54 percentage points on the same model, changing only the harness. We saw a small version of this ourselves when we checked the true cost of saying “Hi” to an AI agent.
- Context compaction can double your bill instead of saving it. Compaction sounds like compression, so it is easy to assume it is always good, but it is not free: the model has to summarize your history and that summarization call consumes tokens too. It can also evict files the agent still needs, so the agent re-reads them, the context fills up again, and compaction fires again. One documented regression shows how bad this loop can get: after a harness retuned its compaction threshold, it went from 4 to 12-26 compactions per session, and token usage on identical tasks went from 89 million to 160-185 million.
- One mid-session tool change silently re-bills everything. Cache reads cost about 0.1x of the base input price, but the cache invalidates as a hierarchy (tools, then system, then messages). Add or reorder a single tool schema in the middle of a session and the entire cached prefix re-bills at full price. You get no error, just a bigger invoice.
- Your token counter is not your invoice. In one documented case a calculated $3.60/month landed as a $25-40/month invoice, a 7-11x gap coming from context accumulation, retry amplification, framework overhead, and evaluation calls that a simple token estimate never captured.
Our framework tags most of these as medium confidence, usually 1 or 2 solid sources, and we keep that visible instead of pretending it is settled.
Before you burn your next limit
If you are burning your limits on deep research today, try reversing the order. Cheap models find, accurate models verify, and deep research goes last. And check how much intelligence you already pay for. A few subscriptions with a clear role for each model give you much more than one frontier model used blindly.
And if you are building your own research pipeline, or your AI bill grows faster than your usage, we would really like to hear from you. Join the discussion on Hacker News or LinkedIn.
Stay tuned for future posts and releases
関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み