From 076973426184790c18067c009e07c17239985d1e Mon Sep 17 00:00:00 2001 From: mango Date: Sun, 22 Feb 2026 18:24:25 +0800 Subject: [PATCH] fix: session count + remove oc_dir bug --- agent/agent.sh | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/agent/agent.sh b/agent/agent.sh index 60818ea..f704832 100755 --- a/agent/agent.sh +++ b/agent/agent.sh @@ -143,18 +143,11 @@ else: gw = bool(run('pgrep -f "openclaw"')) daemon = gw # if openclaw is running, both are likely up -# Sessions - search for session files +# Sessions - count jsonl files in agents/*/sessions/ sessions = 0 oc_dir = os.path.expanduser('~/.openclaw') -for sf in [os.path.join(oc_dir,'sessions.json'), os.path.join(oc_dir,'data','sessions.json')]: - if os.path.exists(sf): - try: sessions = len(json.load(open(sf))); break - except: pass -# Fallback: count session dirs -if sessions == 0: - sess_dir = os.path.join(oc_dir,'sessions') - if os.path.isdir(sess_dir): - sessions = len([d for d in os.listdir(sess_dir) if os.path.isdir(os.path.join(sess_dir,d))]) +for sd in glob.glob(os.path.join(oc_dir,'agents','*','sessions')): + sessions += len(glob.glob(os.path.join(sd,'*.jsonl'))) # Token usage from session jsonl files tok_today=tok_week=tok_month=0