mvanhorn/last30days-skill · error · RuntimeError
save_output: could not find a unique filename after 101 atte
Error message
save_output: could not find a unique filename after 101 attempts in {path} What it means
save_output() tries up to 101 candidate filenames (stem, stem-date, stem-date-1..99) using exclusive create; if every candidate already exists on disk it raises RuntimeError instead of overwriting a prior report. In practice this means the same topic was saved 101+ times into one directory.
Source
Thrown at skills/last30days/scripts/last30days.py:304
save_root = candidate.parent.resolve()
if save_root == Path(library.DEFAULT_MEMORY_DIR).expanduser().resolve():
library_index.sync_library(save_root)
else:
# A scoped save must sync a per-directory index with the
# same paths scoped search uses; syncing the shared DB
# from one scope's scan would prune other scopes' rows.
library_index.sync_library(
save_root,
save_root / "briefings",
db_path=save_root / ".last30days-library.db",
)
except (library_index.LibrarySearchUnavailable, OSError, sqlite3.DatabaseError):
# Saving research must not depend on the optional local index;
# `library search` reports a clear capability error on demand.
pass
return candidate
# Fallback: all 101 candidates existed (extremely unlikely).
raise RuntimeError(
f"save_output: could not find a unique filename after 101 attempts in {path}"
)
def save_rendered_output(
rendered_content: str,
output_file: str,
*,
private: bool = False,
) -> Path:
out_path = Path(output_file).expanduser().resolve()
_ensure_output_directory(out_path.parent, private=private)
if private and out_path.exists():
out_path.chmod(0o600)
fd = os.open(
out_path,
os.O_CREAT | os.O_TRUNC | os.O_WRONLY,
0o600 if private else 0o644,View on GitHub (pinned to c7460f6114)
Solutions
- Clean or archive old outputs for that topic in the save directory (or point --save-dir at a fresh directory).
- Lower run frequency or make the save path unique per run (include hour/minute in the topic slug or save dir).
- If overwrite semantics are acceptable, remove the stale dated files before re-running.
Example fix
# before cron: every 15 minutes, same save dir # after SAVE_DIR="runs/$(date +%Y%m%d-%H%M)" python3 last30days.py topic --save-dir "$SAVE_DIR"
Defensive patterns
Strategy: validation
Validate before calling
stem_candidates = 1 + 1 + 99 # engine probes at most 101 names per stem/date
existing = len(list(save_dir.glob(f'{stem}*')))
if existing >= 100:
raise RuntimeError(f'save dir saturated for stem {stem!r}; archive old outputs first') Try / catch
try:
path = save_output(content, out_file)
except RuntimeError:
out_file = str(Path(out_file).with_name(f"{Path(out_file).stem}-{os.getpid()}{Path(out_file).suffix}"))
path = save_output(content, out_file) Prevention
- Use per-run save directories for scheduled jobs.
- Archive or purge old outputs for a topic before high-frequency re-runs.
When it happens
Trigger: Repeatedly running the same topic on the same date into the same save dir (cron/monitor loop), so stem.md, stem-YYYY-MM-DD.md, and stem-YYYY-MM-DD-1..99.md all exist and os.O_CREAT|os.O_EXCL fails FileExistsError for all 101 candidates.
Common situations: A scheduled trend-monitor running many times per day; a retry loop re-saving after partial failures; two concurrent runs racing for the same filenames.
Related errors
- Could not find a unique discovery output filename
- [last30days] Cannot read --synthesis-file: {exc}\n
- [CompetitorsPlan] Cannot read plan file: {exc}\n
- [Planner] Cannot read --plan file: {exc}\n
- No handoff location available to write the nominations bundl
AI-assisted analysis of mvanhorn/last30days-skill@c7460f6114 (2026-08-15).
Data as JSON: /api/errors/0835b412e3ecbb81.
Report an issue: GitHub.