Stop automatic AI retry on failed posts

This commit is contained in:
Your Name
2026-07-30 08:55:39 +05:00
parent eb04005e23
commit 33c55074aa
4 changed files with 12 additions and 6 deletions
+6 -1
View File
@@ -786,10 +786,15 @@ AI получает JSON-массив:
- `status='storage_ready'`
- `qualification_status='accepted'`
- `rewrite_status is NULL/pending/failed`
- `rewrite_status is NULL/pending`
И переписать их в короткую публикацию для Telegram/VK-канала.
Важно: автоматический AI writer не должен забирать `rewrite_status='failed'`.
2026-07-30 один пост (`id=2348`) был платно отправлен в Sonnet 4.6 983 раза,
потому что failed снова попадал в claim и цикл сразу продолжал работу. Failed
посты нужно возвращать в `pending` только явным ручным действием.
### 10.2. Вход в модель
AI получает JSON-объект:
+2 -1
View File
@@ -1,6 +1,6 @@
# N8 Parser: current state
Last updated: 2026-07-29
Last updated: 2026-07-30
This file is the short handoff state for future Codex threads. Read this first before touching the project, so the whole chat history does not need to be carried forward.
@@ -102,6 +102,7 @@ As of 2026-07-29:
- Current live writer model setting checked on 2026-07-29: `ai_writer_model = anthropic/claude-sonnet-4-6`.
- Sonnet 4.6 can return `rewrites` as a JSON string instead of a list. `validate_rewrites()` in `src/vk_parser_app/workers/ai_writer.py` now parses stringified `rewrites` before validation.
- 2026-07-30 incident: post `2348` was retried 983 times by AI writer because automatic claim included `rewrite_status='failed'`; estimated internal cost was `$16.465977`. Live setting `ai_writer_enabled` was switched to `false` to stop spend. Automatic AI qualifier/writer claims must not include `failed`; failed posts require an explicit manual reset to `pending`.
## Prompt Architecture
+2 -2
View File
@@ -150,7 +150,7 @@ class AIQualifierWorker:
SELECT COUNT(*)
FROM raw_posts
WHERE status='storage_ready'
AND COALESCE(qualification_status, 'pending') IN ('pending', 'failed')
AND COALESCE(qualification_status, 'pending') = 'pending'
AND EXISTS (
SELECT 1
FROM raw_post_media m
@@ -178,7 +178,7 @@ class AIQualifierWorker:
SELECT id
FROM raw_posts
WHERE status='storage_ready'
AND COALESCE(qualification_status, 'pending') IN ('pending', 'failed')
AND COALESCE(qualification_status, 'pending') = 'pending'
AND EXISTS (
SELECT 1
FROM raw_post_media m
+2 -2
View File
@@ -234,7 +234,7 @@ class AIWriterWorker:
FROM raw_posts
WHERE status='storage_ready'
AND qualification_status='accepted'
AND COALESCE(rewrite_status, 'pending') IN ('pending', 'failed')
AND COALESCE(rewrite_status, 'pending') = 'pending'
AND EXISTS (
SELECT 1
FROM raw_post_media m
@@ -263,7 +263,7 @@ class AIWriterWorker:
FROM raw_posts
WHERE status='storage_ready'
AND qualification_status='accepted'
AND COALESCE(rewrite_status, 'pending') IN ('pending', 'failed')
AND COALESCE(rewrite_status, 'pending') = 'pending'
AND EXISTS (
SELECT 1
FROM raw_post_media m