diff --git a/agents.py b/agents.py index 3420856..5ce9af7 100755 --- a/agents.py +++ b/agents.py @@ -757,6 +757,12 @@ def token_phase_flush(cfg, next_phase_id): fh.write(json.dumps(rec) + "\n") parts = ", ".join(f"{n}={per_agent[n]['total']:,}" for n in per_agent) log(f"[log_tokens] phase {rec['phase_id']}: {total['total']:,} tok in {dur}s ({parts})") + if next_phase_id is not None: + sf.write_text(json.dumps({"phase_id": next_phase_id, + "started": datetime.now().isoformat(timespec="seconds"), + "baseline": cur})) + else: + sf.unlink(missing_ok=True) # ── token logging granularity: per phase, or also per GATE (log_tokens) ──────────── # Phases are tracked per phase (token_phase_begin/flush). With token_granularity="gate" (the default) @@ -844,12 +850,6 @@ def gate_token_check(cfg): "started": datetime.now().isoformat(timespec="seconds"), "baseline": _token_cumulative(cfg)})) log(f"[log_tokens] tracking gate: {current}") - if next_phase_id is not None: - sf.write_text(json.dumps({"phase_id": next_phase_id, - "started": datetime.now().isoformat(timespec="seconds"), - "baseline": cur})) - else: - sf.unlink(missing_ok=True) def phase_advance_check(cfg): """On heavy tick: if the current phase is DONE, advance (or finish the sequence).