Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Cache the claude backend system prompt via Anthropic prompt caching

オープン 初心者向け
#4,835 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@Jvxoq がすでに取り組んでいます。

2026年10月28日 から。

  • #4855 @Jvxoq による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
76/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
ai, performance

調査の方向性

graphify/llm.py の _call_claude() から始め、Anthropic SDK が cache_control を含むシステムコンテンツブロックをどのように受け付けるか確認してください。説明に従って抽出用システムプロンプトにキャッシュを適用し、その後も呼び出しで同じプロンプトとメッセージ内容が使われることを確認してください。issue では、出力を変更せずにネイティブ Claude バックエンドでプロンプトキャッシュを有効にすることを完了条件としています。

索引モデルが issue の本文から書いたものです。

説明

Summary

extract --backend claude issues one messages.create call per file, and each call re-sends the fixed _extraction_system prompt at full input price. Marking the system block with Anthropic prompt caching (cache_control: ephemeral) bills that shared prefix at ~0.1× on reads after the first call. Output is unchanged — this is a billing/latency optimization only.

Where

graphify/llm.py, _call_claude() — system= is passed as a plain string, so the extraction system prompt is re-ingested on every per-file call.

Proposed change
diff
resp = client.messages.create(
model=model,
max_tokens=max_tokens,

  •    system=_extraction_system(deep=deep_mode),
    
  •    system=[{
    
  •        "type": "text",
    
  •        "text": _extraction_system(deep=deep_mode),
    
  •        "cache_control": {"type": "ephemeral"},
    
  •    }],
       messages=[{"role": "user", "content": _anthropic_content(user_message, images or [])}],
    
    )

The anthropic SDK already in use supports the content-block form of system with cache_control.

Why it helps

_extraction_system is identical across all per-file calls (only deep toggles). On a repo with N files the system prefix is paid N× at 1×; with caching it’s one write (1.25×) + (N−1) reads (0.1×) → ~90% off the system portion of input.

Caveats (for reviewers)
Only the system block is cacheable here; per-file user content isn’t reused.
Needs the system prompt ≥ the model’s min cacheable length (e.g. 512 tokens on recent Sonnet/Opus); below that it silently no-ops (cache_*_input_tokens = 0), no error.
With --max-concurrency > 1 the first wave of parallel calls misses (a cache entry is only available after the first response begins) — still a net win on multi-file runs.
5-min ephemeral TTL refreshes on each hit, so it stays warm through an active extraction.
Scoped to the native claude backend; the Bedrock path (system=[{"text": ...}]) uses a different caching mechanism and could be a follow-up.
Impact

Billing/latency only. No behavior change.

主要言語
Python
スター
124k
フォーク
11.9k
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Graphify-Labs/graphify のほかの issue

Graphify-Labs/graphify の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。