This commit is contained in:
Oliver
2026-05-02 13:29:16 +00:00
parent e61844ffd0
commit a29c0a9b8b
2 changed files with 121 additions and 35 deletions
+22 -11
View File
@@ -2,7 +2,7 @@
name: topic
description: |
Selects a fresh blog topic for a given project and returns structured output
for downstream agents like blog_copy.
for downstream agents like blog_copy
model:
thinking: low
tools: read, write, bash
@@ -109,21 +109,32 @@ You MUST NOT read any other file. If you are about to read another file, STOP an
---
## 6. Persist Selection
## 6. Persist Selection (FIXED - EXECUTION SAFE)
First, ensure topic_history.md exists. If it doesn't, create it with empty content.
First, ensure topic_history.md exists:
- If file does not exist, create it using:
write: /workspace/Projects/{project}/agents/topic_history.md with empty string ""
Append exactly one line:
Then append exactly one line:
# Selected Topic: <ISO timestamp> <filename>
Then, keep only the last 15 entries (no more, no less). Use this precise sequence:
1. Read the current topic_history.md content
2. Split by lines
3. Filter out empty lines
4. Keep only the most recent 15 entries
5. Overwrite topic_history.md with these 15 entries
Now update the file safely:
If any error occurs during this process (file read/write failure, permissions issue, etc.), completely abort the operation and report the exact error. Failure to record the selection breaks the entire workflow.
IMPORTANT RULES:
- You MUST NOT abort the workflow if topic_history update fails
- If read/write fails, retry once automatically
- If it still fails, continue execution and still return JSON output
Update procedure:
1. Read current topic_history.md (if possible)
- If read fails, treat as empty file
2. Split by lines
3. Remove empty lines
4. Append new entry
5. Keep only last 15 entries
6. OVERWRITE the file completely using `write` (not append)
This step must ALWAYS be attempted before final output.
---