Skip to content

fix: SKILLOPT_SLEEP_PYTHON override + lookback_hours first-run fallback#74

Merged
Yif-Yang merged 4 commits into
microsoft:mainfrom
Yif-Yang:fix/python-path-and-lookback
Jun 20, 2026
Merged

fix: SKILLOPT_SLEEP_PYTHON override + lookback_hours first-run fallback#74
Yif-Yang merged 4 commits into
microsoft:mainfrom
Yif-Yang:fix/python-path-and-lookback

Conversation

@Yif-Yang

Copy link
Copy Markdown
Contributor

Summary

Two fixes from issue #57 community feedback:

1. SKILLOPT_SLEEP_PYTHON env var (issue #57 point 4)

macOS users with system Python 3.9 but a newer Python available elsewhere (e.g. Codex Desktop's bundled 3.12) had no way to tell the runner which Python to use.

Now: export SKILLOPT_SLEEP_PYTHON=/path/to/python3.12 overrides auto-detection. Applied to both plugins/run-sleep.sh and the bundled Claude Code plugin copy.

2. lookback_hours first-run fallback (issue #57 point 10)

Previously, the first run (no prior harvest recorded) scanned the entire transcript history — users with months of data triggered massive LLM mining. Now applies lookback_hours (default 72h) as a time cutoff on first run.

--lookback-hours 0 explicitly opts out (full history scan). Omitting the flag preserves the config default (72h).

Codex + GPT-5.5 review (4 rounds)

Round Finding Fix
1 Use supplied clock for cutoff (not wall time) ✅ Fixed
1 Harvest early-exit on old files ✅ Fixed → then reverted in round 2
2 mtime vs ended_at ordering mismatch — can't break ✅ Reverted to continue
2 --lookback-hours 0 clobbered by config default ✅ Use is not None and > 0
3 argparse default=0 makes omitted indistinguishable from explicit 0 ✅ Changed default to None
4 Clean pass — no issues found

Test plan

  • 139 tests pass
  • SKILLOPT_SLEEP_PYTHON=/usr/bin/python3 bash plugins/run-sleep.sh status works
  • First run with default config applies 72h lookback
  • --lookback-hours 0 scans full history
  • Deterministic test with clock parameter gets reproducible cutoff

🤖 Generated with Claude Code

carpedkm and others added 4 commits June 20, 2026 14:07
…llback

Two fixes from issue microsoft#57 feedback:

1. run-sleep.sh: support SKILLOPT_SLEEP_PYTHON env var to explicitly set
   the Python interpreter. Useful on macOS where system Python is 3.9 but
   a newer Python is available elsewhere (e.g. Codex Desktop's bundled
   Python 3.12). Applied to both the shared runner and the bundled
   Claude Code plugin copy.

2. cycle.py: on first run (no prior harvest recorded), apply the
   lookback_hours config (default 72h) as a time cutoff. Previously,
   first run scanned the entire transcript history, which could trigger
   massive LLM mining on users with months of session data.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- cycle.py: use supplied `clock` parameter (not wall time) for the
  lookback cutoff, so deterministic tests/experiments get reproducible
  harvest windows
- harvest.py: break (not continue) when a file is older than since_iso,
  since files are sorted newest-first by mtime — avoids scanning the
  entire transcript directory for quiet projects with large histories

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- harvest.py: revert break to continue — mtime ordering can diverge
  from embedded ended_at timestamps (copy/touch), so we must check all
  files rather than early-exiting on the first old one
- cycle.py: use `is not None and > 0` so lookback_hours=0 means
  "scan full history" (opt-out of the cutoff)
- __main__.py: propagate --lookback-hours 0 to config as explicit 0

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codex round 3: argparse default=0 made every CLI invocation without
--lookback-hours clobber the config's 72h default. Now default=None;
only explicit --lookback-hours N (including 0) overrides config.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Yif-Yang Yif-Yang merged commit fc1f827 into microsoft:main Jun 20, 2026
1 check was pending
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants