docs: add CRITICAL batch API duplicate warning to cost benchmark
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -148,3 +148,37 @@ Token-Verbrauch (Stichprobe 20 Requests):
|
|||||||
4. **Backfill lohnt sich nicht** — Der Overhead (DB-Updates, Monitoring, Fehlerbehandlung) ueberwiegt die minimale Ersparnis
|
4. **Backfill lohnt sich nicht** — Der Overhead (DB-Updates, Monitoring, Fehlerbehandlung) ueberwiegt die minimale Ersparnis
|
||||||
5. **Mac Mini (qwen3) ist zu langsam** — 77h fuer 20k Controls, und schwaechere Qualitaet bei applicability
|
5. **Mac Mini (qwen3) ist zu langsam** — 77h fuer 20k Controls, und schwaechere Qualitaet bei applicability
|
||||||
6. **v4-Prompt ist der Sweet Spot** — Alle Felder in einem Call, konsistente Qualitaet, akzeptable Kosten
|
6. **v4-Prompt ist der Sweet Spot** — Alle Felder in einem Call, konsistente Qualitaet, akzeptable Kosten
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## KRITISCH: Duplikat-Batch-Schutz
|
||||||
|
|
||||||
|
!!! danger "Batch API Duplikat-Fehler (2026-04-27) — $170 Mehrkosten"
|
||||||
|
`curl` meldete einen Timeout/Parse-Error obwohl der Server den Batch bereits an Anthropic
|
||||||
|
gesendet hatte. Durch Retry-Versuche wurden **3 identische Batches** erstellt statt 1.
|
||||||
|
Die Anthropic Batch API ist NICHT idempotent — jeder POST erstellt einen neuen Batch.
|
||||||
|
Auch ein `cancel` stoppt nur unverarbeitete Requests — bereits laufende werden abgerechnet.
|
||||||
|
|
||||||
|
### Schutzmassnahmen (implementiert)
|
||||||
|
|
||||||
|
1. **Idempotency-Sperre im Submit-Endpoint** — Verweigert Submit wenn letzter Batch <10 Min alt
|
||||||
|
2. **NIEMALS `curl` fuer Batch-Submits** — Immer `python3 httpx` mit 600s Timeout
|
||||||
|
3. **Vor jedem Submit** Batch-Liste pruefen: `GET /v1/messages/batches?limit=3`
|
||||||
|
4. **Anthropic Dashboard** pruefen wenn Kosten unklar
|
||||||
|
|
||||||
|
### Korrekte Submit-Methode
|
||||||
|
|
||||||
|
```python
|
||||||
|
# RICHTIG — Python httpx mit langem Timeout, kein Retry
|
||||||
|
ssh macmini "/usr/local/bin/docker exec bp-core-control-pipeline python3 -c \"
|
||||||
|
import httpx
|
||||||
|
resp = httpx.post('http://127.0.0.1:8098/v1/canonical/generate/submit-pass0b',
|
||||||
|
json={'limit': 10000, 'batch_size': 5},
|
||||||
|
timeout=600)
|
||||||
|
print(resp.json())
|
||||||
|
\""
|
||||||
|
|
||||||
|
# FALSCH — curl mit Retry-Risiko
|
||||||
|
# curl -sf -X POST http://127.0.0.1:8098/v1/canonical/generate/submit-pass0b ...
|
||||||
|
# Bei Timeout → NICHT nochmal ausfuehren!
|
||||||
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user