wi CLIThis page explains how agents are executed and scheduled, based on runtime/, bin/wi, docs/RUNNING_AGENTS.md, and docs/runbooks/scheduler.md.
runtime/)Key modules:
runtime/base.py — defines the agent contract:
AgentInput (payload, trigger, user_id, run_id, context).AgentOutput (ok flag, data, events, metrics, error).BaseAgent with:
id, dept, tier, skills class attributes.run(...) entrypoint that logs start/end, times execution, handles exceptions, and persists each run as JSON under settings.run_dir.handle(...) abstract method that concrete agents implement.compose_system(...) helper that prepends skill bodies via runtime.skills.compose.runtime/__main__.py — CLI entrypoint for python3 -m runtime:
list — discovers agents and prints AGENT / DEPT / TIER (with optional --tier).run — runs one agent once, with optional --payload JSON and --trigger label.run-all — runs every discovered agent once (optionally filtered by --tier).runtime/loader.py — discovery & dynamic import of agents from agents/<dept>/<id>/.runtime/skills.py — loads skill packs from skills/ and composes prompts.runtime/bus.py — intra-repo event bus (used for inter-agent handoffs).runtime/spawn.py — builds Copilot sub-agent briefs and maintains agents/registry.json.runtime/mc_bootstrap.py — seeds Mission Control projects and tasks from seeds/*.yaml.runtime/scheduler.py)The scheduler is a single-process loop that reads catalog.yaml and dispatches agents on a cadence derived from their triggers:.
TRIGGER_MAP maps trigger names like every_5min, hourly_cron, daily_9am_cron, weekly_cron, seasonal_campaign_cron, etc. to Cadence objects.Cadence has a human label and should_fire(now, last_fired) predicate.build_schedule):
catalog.yaml and iterates agents.tier.agents/*/<id>/agent.py.ScheduledAgent (id, tier, dept, cadence, trigger_label).dispatch):
python3 -m runtime run <agent_id> as a subprocess in the repo root.(ok, tail) with a timeout.run_loop):
mission_control.ensure_projects() and publishes cron jobs via mc_cron.publish_jobs.cadence.should_fire.fire agent=... trigger=....mc.start_task(...) (if enabled).dispatch(...) and measures duration.review or failed and short log tail.mc_cron.update_job_state.last_fired, fire_count, fail_count, last_error.CLI usage (from the module docstring and runbooks):
python3 -m runtime.scheduler --dry-run # print schedule and exit
python3 -m runtime.scheduler --once # fire every eligible agent once, then exit
python3 -m runtime.scheduler --tier P0 # restrict to one tier
python3 -m runtime.scheduler # foreground loop
The ./bin/wi script is the preferred entrypoint; see below.
wi Bash CLI (bin/wi)bin/wi is the unified human-facing CLI. It wraps the Python runtime and scheduler and provides a single command surface:
wi start — start scheduler in the background (scripts/start_scheduler.sh).wi stop — stop scheduler (scripts/stop_scheduler.sh).wi restart — stop + start.wi status — prints scheduler status (PID, uptime), last dispatches, log path.wi logs [-f] — tails the scheduler log from /tmp/wiseinvest-scheduler.log.wi list [--tier P0] — python3 -m runtime list.wi run <agent_id> [--payload '{}'] — python3 -m runtime run.wi run-all [--tier P0] — python3 -m runtime run-all.wi dry-run / wi once — python3 -m runtime.scheduler --dry-run|--once.wi brief <agent_id> — python3 -m runtime.spawn brief <id> (Copilot sub-agent brief).wi spawn-list — python3 -m runtime.spawn list.wi doctor — checks key environment variables and verifies agent discovery.Implementation details:
REPO_ROOT relative to its own path and cds there..env so downstream Python commands inherit API keys and integration tokens./tmp/wiseinvest-scheduler.pid and /tmp/wiseinvest-scheduler.log.For the operator-focused view of these commands, see docs/RUNNING_AGENTS.md.
For reboot persistence on macOS, the runbook recommends using deploy/launchd/in.wiseinvest.scheduler.plist:
cp deploy/launchd/in.wiseinvest.scheduler.plist ~/Library/LaunchAgents/
launchctl load ~/Library/LaunchAgents/in.wiseinvest.scheduler.plist
The plist configures KeepAlive=true and RunAtLoad=true, so the scheduler restarts on crash and at login. See docs/runbooks/scheduler.md for full details and cadence maps.