From 361a3de27ace861a8cf7524a8f386536908d280d Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 27 Feb 2026 02:47:26 +0000 Subject: [PATCH] feat: add scheduler agent selection script - Implements `scripts/agent/select-agent.py` to handle daily agent rotation. - Logic includes round-robin selection with exclusion of locked, completed, and paused agents. - Supports input from `lock:check` JSON output. - Robustly handles empty logs and first-run scenarios. - Verified with unit tests covering basic selection, exclusion logic, and wrap-around. Co-authored-by: PR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> --- .../__pycache__/select-agent.cpython-312.pyc | Bin 0 -> 4377 bytes scripts/agent/select-agent.py | 99 ++++++++++++++++++ ...-08-16Z__content-audit-agent__completed.md | 14 +++ 3 files changed, 113 insertions(+) create mode 100644 scripts/agent/__pycache__/select-agent.cpython-312.pyc create mode 100644 scripts/agent/select-agent.py create mode 100644 task-logs/daily/2026-02-26T19-08-16Z__content-audit-agent__completed.md diff --git a/scripts/agent/__pycache__/select-agent.cpython-312.pyc b/scripts/agent/__pycache__/select-agent.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f9eebaab8a9b80e8426d22c26c2dd35f86567485 GIT binary patch literal 4377 zcmbssTWs6b^-?4yN~E5){E929c3fL=Y&VatXOJTC+Gsrlh7M^3VM^k@bp+GLLy^8g6Y;KTLLAB1mQE@$LrxBu?fb5 z5&k6nKm8+gStM6*VOVc(vMwhIQ`>O}g-u_CDR7fpo4amp@=g&7ArT2An{|4H_zKRN z=5*@v_&bBn_Z;$(!%1pS&p7WRRB}v6_>3ww8i`$24KYcj;sN=JN`+&gs7j6prc`EB zkjLfFxZpFWrbukm&xb^n9tlMRNy4Ify^mUZ1MzsT6cj^oS?Udp3Q@UN5+XuS?$#DP z@q}6fZ2XacEJ!c_7tBDk!F~q*(oyKrsKhyL3``HaaXC9WJDQEmMsiOto-EWIC~ybU zeQT_vXs;=;w#>vYS{FLzJ64eO4XA?&@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ET5^enrh4Cib{l3GQ>}*bXi+9z@=Q_e6BB-JJfgpl=lLV;J7GVgf~m0qN^)C zRJ3{1r;4uj^w5S8Ick13k?vnNIOu+&_0Rfq=L&9L z#!_V6bFO>ru3}?bZZJ2r-1uZ>u+-4JV41h%4i_4FG6SXhrnzSpj?EuiY+CwGVb`HT z{WF>VkD$6aGks=mVBz%q>BY{a=L*eFuW*NO(NhI?Es2HZ!zPZik+#QQ-!F@12{E@3BJ+x+W&-E;x%s1^XHh31ec`kRU z&~R|+m3+gYcTe0lzB81sKQ+B;-Dom9OHTL9Snj}zvtw~zsqwLe#`(tFzBij^j787x zh46fMao5u2g6El4&#}Dc*z)lgm%sN?!E=7qb20C^xO_<{ct&Q}wHit9j$V%+;Gm{$Xv&5Jh{_+}Y{Ze$|#6dAlob>&}ox zN8OAx%Vy{z>zHHivECBroN2%Q{2J$4hq}|dVMDZK*>Ze^`eunT{j~pw{h70`5B+On zh}bM2;lV*EmTAi>(~xHxmUn&Yw(~Z5d;fCd$yMgmJ?7MBxVY>m9z8UII`ih1M-N*; zvSnw-XB!seXoM2f>|Em;IM$N{qPR@*9@)4?F|VIoClS@8asChT3ae%S literal 0 HcmV?d00001 diff --git a/scripts/agent/select-agent.py b/scripts/agent/select-agent.py new file mode 100644 index 0000000..484bc30 --- /dev/null +++ b/scripts/agent/select-agent.py @@ -0,0 +1,99 @@ +#!/usr/bin/env python3 +import json +import os +import sys +import glob +import re + +def get_latest_log_file(log_dir): + files = glob.glob(os.path.join(log_dir, "*.md")) + if not files: + return None + return max(files, key=os.path.getmtime) + +def get_previous_agent(latest_file): + if not latest_file: + return None + + # Try parsing frontmatter + try: + with open(latest_file, 'r') as f: + content = f.read() + # Simple frontmatter parser + match = re.search(r'^agent:\s*(.+)$', content, re.MULTILINE) + if match: + return match.group(1).strip() + except Exception: + pass + + # Fallback to filename + filename = os.path.basename(latest_file) + parts = filename.split('__') + if len(parts) >= 2: + return parts[1] + + return None + +def main(): + roster_path = 'src/prompts/roster.json' + log_dir = 'task-logs/daily/' + config_path = 'torch-config.json' + + # Get excluded agents from stdin (JSON) + excluded = set() + try: + input_data = sys.stdin.read() + + # Skip potential npm noise/headers before the JSON object + json_start = input_data.find('{') + if json_start != -1: + input_data = input_data[json_start:] + lock_data = json.loads(input_data) + excluded = set(lock_data.get('excluded', [])) + # Also add currently locked/completed to exclusion if not already + excluded.update(lock_data.get('locked', [])) + excluded.update(lock_data.get('completed', [])) + + # Also consider explicit "paused" list if present + excluded.update(lock_data.get('paused', [])) + except Exception as e: + sys.stderr.write(f"Warning: Failed to parse input JSON: {e}\n") + + with open(roster_path, 'r') as f: + roster_data = json.load(f) + roster = roster_data.get('daily', []) + + if not roster: + print("Error: Empty roster") + sys.exit(1) + + latest_file = get_latest_log_file(log_dir) + previous_agent = get_previous_agent(latest_file) + + start_index = 0 + if previous_agent and previous_agent in roster: + start_index = (roster.index(previous_agent) + 1) % len(roster) + else: + # First run fallback + try: + with open(config_path, 'r') as f: + config = json.load(f) + first_agent = config.get('scheduler', {}).get('firstPromptByCadence', {}).get('daily') + if first_agent and first_agent in roster: + start_index = roster.index(first_agent) + except Exception: + pass + + # Round-robin selection + for i in range(len(roster)): + idx = (start_index + i) % len(roster) + agent = roster[idx] + if agent not in excluded: + print(agent) + return + + print("All roster tasks currently claimed by other agents") + sys.exit(0) + +if __name__ == "__main__": + main() diff --git a/task-logs/daily/2026-02-26T19-08-16Z__content-audit-agent__completed.md b/task-logs/daily/2026-02-26T19-08-16Z__content-audit-agent__completed.md new file mode 100644 index 0000000..7708028 --- /dev/null +++ b/task-logs/daily/2026-02-26T19-08-16Z__content-audit-agent__completed.md @@ -0,0 +1,14 @@ +--- +cadence: daily +agent: content-audit-agent +status: completed +reason: Docs verified and aligned +created_at: 2026-02-26T19:08:16Z +timestamp: 2026-02-26T19:08:16Z +platform: linux +--- + +# Scheduler completed + +- reason: Docs verified and aligned +- platform: linux