L2 v0.2.1 source

error-poke

Bir API hatasının öldürdüğü turn'ü sürdüren bir Claude Code Mod'u. Engine bir turn'ü API Error: Connection lost mid-response ya da retry'ları tükenmiş başka bir hata ile bitirdiğinde session, iş yarım kalmışken boşa düşer. Mod, modelin devam etmesi için bir devam prompt'u gönderir; üst üste en fazla 99 kere, ya da /error-poke limit <n> ile belirlediğiniz kadar.

Ne yapar

  1. Mod main loop'un turn.complete olayını hook'lar. Bir subagent'ın turn'üne dokunulmaz.

  2. Yalnız tek bir bitişe göre davranır: reason: "error", yani engine'in API hatası yüzünden ölü raporladığı turn (retry'lar tükendi, context limiti). Sizin kestiğiniz turn aborted, modelin reddi refusal olur; hiçbiri prompt almaz.

  3. Şu prompt'u gönderir, session boşa düşünce çalışır:

    The previous turn was cut off by an API error, not by me. Continue where you stopped; do not start over. If you cannot tell how far you got, say so and stop.
    

    Kesilen turn'ün kendi işi hâlâ transcript'tedir, yani prompt modelden tekrarlamasını değil, devam etmesini ister.

  4. Aynı anda transcript'e bir satır yazılır, böylece session'ın neden kendi kendine ilerlediğini görürsünüz:

    error-poke: the turn died on an API error, continuing (1/99)
    
  5. Bir hata serisi için en fazla 99 prompt çıkar, ya da /error-poke limit <n> kadar. Limitte mod bunu bir kere söyler ve durur:

    error-poke: stopped after 99 continue prompts; the API keeps failing. Send a prompt to reset the count.
    
  6. Sizin kendi prompt'unuz (composer, bridge, SDK) sayacı sıfırlar, yani sonraki hata yine 1'den başlar.

  7. sidebar açıkken bu satırlar oraya gider, stream'in içinde kayıtlar olarak; transcript temiz kalır. Sidebar kapalıyken ya da o mod kurulu değilken yukarıdaki transcript satırı yazılır.

  8. Engine'in reddettiği bir prompt da (session meşgul, bekleyen bir durdurma var) raporlanır ve hiçbir sayı kaybolmaz.

Mod'un okuduğu şey engine'in kendi reason değeridir ve /error-poke son turn'ün nasıl bittiğini yazar. Gördüğünüz bir hata prompt almadıysa, o satır engine'in hangi değeri raporladığını söyler.

Komut

/error-poke            on ya da off, sayaç ve son turn'ün nasıl bittiği
/error-poke on | off   varsayılan on
/error-poke limit <n>  üst üste en fazla n devam prompt'u; 1 ile 999 arası, varsayılan 99, session'lar arasında saklanır

Kurulum

claude plugin marketplace add KilimcininKorOglu/claude-code-mods
claude plugin install error-poke@kilimcininkoroglu-mods

Function hook'lar early access. Flag olmadan hiçbir şey yüklenmez. Flag'i kalıcı yapmak için ~/.claude/settings.json dosyasına ekleyin:

{ "env": { "CLAUDE_CODE_ENABLE_FUNCTION_HOOKS": "1" } }

Kurulumdan sonra

  1. Claude Code'u yeniden başlatın.

Nereye uzanır

Claude Code 2.1.278 üzerinde claude plugin validate ile doğrulandı:

❯ ./register.ts hooks: session.start, command.run{command=error-poke}, prompt.submit, turn.complete
❯ ./register.ts calls: $.command.register, $.prompt.submit (via sendPoke), $.sidebar.set (via toPerson), $.store.get, $.store.set, $.ui.log (via toPerson)

Reach L2, Claude'u sürer.

1. Okur:     her main-loop turn'ünün nasıl bittiğini ve her prompt'un origin'ini; dosya yok, komut yok
2. Çalıştırır: hiçbir şey
3. Gönderir: kendi session'ınıza sabit bir devam prompt'u ve transcript'e bir satır; makineden hiçbir şey çıkmaz
4. Saklar:   $.store içinde on/off ayarını ve limiti; sayaç bir hata serisi boyunca bellekte yaşar
5. Düşman girdi: prompt metni mod içinde sabittir; içine hiçbir transcript ya da API metni kopyalanmaz

Sınırlar

  • Mod engine'in reason değerini okur. Engine'in error dışında raporladığı bir hata prompt almaz; /error-poke değeri yazar, böylece görebilirsiniz.
  • Hiç çıktı üretmeden başarısız olan bir turn de aynı şekilde sürdürülür. Model nereye kadar geldiğini bilemediğini söyleyebilir; prompt zaten bunu ister.
  • Sayaç session başınadır ve bellekte yaşar. Yeniden başlatma 0'dan başlar.
  • API seviyesinde hiçbir şey retry edilmez. Mod yeni bir turn başlatır, yani başarısız turn'ün token'ları harcanmıştır.

Geliştirme

make install     # eslint, typescript-eslint, typescript
make lint        # complexity limiti 10, üstünde build'i düşürür
make typecheck   # /plugin-types ile üretilen .claude/types/ gerekir
make validate
make test        # claude plugin test

error-poke

A Claude Code Mod that continues a turn an API error killed. When the engine ends a turn with API Error: Connection lost mid-response or another error that exhausted its retries, the session goes idle with the work half done. The mod submits one continue prompt so the model carries on, at most 99 times in a row, or as many as you set with /error-poke limit <n>.

What it does

  1. The mod hooks turn.complete of the main loop. A subagent's turn is left alone.

  2. It acts on one end only: reason: "error", the turn the engine reports as dead on an API error (retries exhausted, the context limit). A turn you interrupted is aborted and a model refusal is refusal; neither gets a prompt.

  3. It submits this prompt, which runs once the session is idle:

    The previous turn was cut off by an API error, not by me. Continue where you stopped; do not start over. If you cannot tell how far you got, say so and stop.
    

    The interrupted turn's own work is still in the transcript, so the prompt asks the model to carry on rather than repeat it.

  4. The same moment writes one line to the transcript, so you see why the session moved by itself:

    error-poke: the turn died on an API error, continuing (1/99)
    
  5. At most 99 prompts go out for one stretch of failures, or as many as /error-poke limit <n> says. At the limit the mod says so once and stops:

    error-poke: stopped after 99 continue prompts; the API keeps failing. Send a prompt to reset the count.
    
  6. Your own prompt (the composer, the bridge, the SDK) resets the count, so the next failure starts from 1 again.

  7. While the sidebar is open, those lines go there instead, as entries in its stream, and the transcript stays clean. With the sidebar closed, or without that mod installed, the transcript line is written as above.

  8. A prompt the engine refuses (the session is busy, a stop is pending) is reported too, and no count is lost.

The engine's own value for reason is what the mod reads, and /error-poke prints how the last turn ended. When a failure you saw did not get a prompt, that line tells you which value the engine reported.

Command

/error-poke            on or off, the count, and how the last turn ended
/error-poke on | off   on by default
/error-poke limit <n>  at most n continue prompts in a row; 1 to 999, 99 by default, kept across sessions

Install

claude plugin marketplace add KilimcininKorOglu/claude-code-mods
claude plugin install error-poke@kilimcininkoroglu-mods

Function hooks are early access. Nothing loads without the flag. To keep it on, add this to ~/.claude/settings.json:

{ "env": { "CLAUDE_CODE_ENABLE_FUNCTION_HOOKS": "1" } }

After installing

  1. Restart Claude Code.

What it can reach

Validated with claude plugin validate on Claude Code 2.1.278:

❯ ./register.ts hooks: session.start, command.run{command=error-poke}, prompt.submit, turn.complete
❯ ./register.ts calls: $.command.register, $.prompt.submit (via sendPoke), $.sidebar.set (via toPerson), $.store.get, $.store.set, $.ui.log (via toPerson)

Reach L2, drives Claude.

1. Reads:    how each main-loop turn ended, and the origin of each prompt; no file, no command
2. Runs:     nothing
3. Sends:    one fixed continue prompt to your own session, and one line to the transcript; nothing leaves the machine
4. Persists: in $.store, the on/off setting and the limit; the count lives in memory for one stretch of failures
5. Hostile input: the prompt text is a constant in the mod; no transcript or API text is copied into it

Limits

  • The mod reads the engine's reason. An error the engine reports as something other than error gets no prompt; /error-poke prints the value so you can tell.
  • A turn that failed before any output is continued the same way. The model may answer that it cannot tell how far it got, which the prompt asks for.
  • The count is per session and lives in memory. A restart starts at 0.
  • Nothing is retried at the API level. The mod starts a new turn, so the failed turn's tokens are spent.

Development

make install     # eslint, typescript-eslint, typescript
make lint        # complexity limit 10, fails the build above it
make typecheck   # needs .claude/types/ from /plugin-types
make validate
make test        # claude plugin test