Commit Graph
1 Commits
Author SHA1 Message Date
yetone c158b0439c agent: the Codex daemon is looked at on magpie's writes, not every 15s (#3185)
KeepCodexDaemonCurrent read Codex's config.toml (four TOML reads, a hash
and the stash) every 15s for as long as magpie ran, to see whether
magpie had changed what Codex reads at start since its daemon started.
Only a write can make the daemon behind, and every one magpie makes,
Codex's config among them (edit's file writes), closes filememo.Written.
The loop now waits on that, looks once a minute (OthersEvery) for another
process's write, and every 15s only while the daemon is behind, for the
codex sessions on it to end. codexDaemonBehind's 45s freshness still
holds, since a behind daemon is still looked at every 15s.

Run at this head (rebased on origin/main):
- go test -timeout 45m ./internal/agent ok (212s).
- TestCodexDaemonLooksOnWrites -count=3 ok; red with the loop not
  waiting on Written ("looked at 0 times in 5s").
- gofmt clean; GOOS=linux / windows go vet -tags nogui ./internal/agent ok.
- Real gateway, sandbox HOME, idle, per-second wakeups over 120s after a
  90s warm-up: v0.1.1564 1.6/s with a burst every ~15s, this 1.4/s with
  no 15s period left (the sandbox has no Codex config, so this is the
  timer alone; with Codex set up each look also read its files).
2026-10-26 11:48:48 +08:00