Repo for the Background Agents Rotation Project
- Python 3.10+
- Recommended (venv) and editable install:
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
pip install -e .Note: pip install -e . installs the precursor package in editable mode so imports/CLIs work during development.
- Copy
.env.exampleto.envand fill these keys:OPENAI_API_KEY— OpenAI API keyANTHROPIC_API_KEY- Anthropic API keyBRAVE_API_KEY- Brave Search API key (for adding web search to agents)CALENDAR_ICS— HTTPS ICS URL to your calendar feedGITHUB_TOKEN— GitHub Personal Access Token (repo scope)
- Node.js 18+ (for MCP servers and slides)
- Install via nvm or package manager; ensure
nodeandnpxare available. - Verify:
node --version && npx --version
- Install via nvm or package manager; ensure
- Docker (recommended for the coding agent)
- Required by OpenHands to run the sandbox container for code edits and PRs.
- Verify:
docker info
- Xcode 15+ (or Command Line Tools) on macOS
- Required to build and run the Swift app (
PrecursorApp).
- Required to build and run the Swift app (
Note on MCP server resilience: Each MCP server is started with a 60-second timeout (configurable via
server_startup_timeoutinsettings.yaml). Servers that fail or time out are skipped and the agent proceeds with whichever servers loaded successfully. Check agent logs for lines likemcp_loader: server 'X' failed to start — skippingto diagnose missing tools.
-
Open Outlook on the web:
outlook.office.com -
Go to Settings (⚙️) → View all Outlook settings → Calendar → Shared calendars.
-
Under Publish a calendar, choose your calendar → set permission (Can view all details) → click Publish.
Links: Share your calendar · Publishing overview -
Copy the ICS link (should end with
.ics). If it begins withwebcal://, change it tohttps://. -
Set this in your
.envas:
CALENDAR_ICS="https://…your_link.ics"
- Go to GitHub → Settings → Developer settings → Personal access tokens.
- Create a Fine-grained (preferred) token with access to the repos you’ll use.
- Set repository permissions:
- Contents: Read and write
- Pull requests: Read and write
- Workflows: Read and write
- Commit statuses: Read
- Metadata: Read
- (Optional) Issues: Read
- Copy the token and add to
.envasGITHUB_TOKEN. - Links: New fine-grained token · Classic tokens
- Open the Google Cloud Console.
- Create/select a project and enable the “Google Drive API” and the "Google Docs API"
- Create OAuth client credentials (Desktop app), download the JSON as
credentials.json. - Place
credentials.jsonat the project root (or setGOOGLE_CREDENTIALS_JSON). - On first use, you’ll be prompted to authorize; a
token.picklewill be created (or setGOOGLE_TOKEN_PICKLE).
Links: Enable Drive API · Credentials
Scopes required (add on the OAuth consent screen):
https://www.googleapis.com/auth/drivehttps://www.googleapis.com/auth/documents
Defaults for Google files are set in src/precursor/config/mcp_servers.yaml, so placing both files at the repo root works out of the box.
- Create a Brave Search API key and add to
.env:
BRAVE_API_KEY=your_key_here- No local install needed; the project uses the Brave Search MCP via
npx.
Docs: Brave Search API overview · Manage API keys
cd src/precursor/mcp_servers/slides
npm run setup- Install notifier:
brew install terminal-notifier- Build the app (once):
cd src/interface/PrecursorApp
swift buildsrc/precursor/config/projects.yaml- Add your projects under
projects:with a uniquenameand shortdescription. - Toggle
agent_enabledper project to allow background actions. - The CLI and scratchpad use the
nameexactly, so keep it stable.
- Add your projects under
src/precursor/config/user.yaml- Set
name, updatedescription, and refineagent_goals. nameis also injected asUSER_NAMEfor the GUM MCP.
- Set
src/precursor/config/settings.yaml- Tune decision-making:
value_weight,feasibility_weight,user_preference_alignment_weight. - Control deployment:
max_deployed_tasks,deployment_threshold,safety_threshold. - MCP startup:
server_startup_timeout(seconds; default 60). Increase on slow networks. - Raise thresholds to be more conservative; lower to be more active.
- Tune decision-making:
src/precursor/config/mcp_servers.yaml- Enable/disable servers under
servers:; no Python changes needed.
- Enable/disable servers under
All besides the MCP servers can actually be edited from the user interface.
- To override built-in config files, set:
PRECURSOR_PROJECTS_FILE,PRECURSOR_SETTINGS_FILE,PRECURSOR_MCP_SERVERS_FILE
- To change the scratchpad DB location:
PRECURSOR_SCRATCHPAD_DB=/path/to/scratchpad.db
- To customize slide export location (used by the slides MCP):
SLIDEV_DIR=/path/for/generated/slides
User profile is read from src/precursor/config/user.yaml (used to inject USER_NAME for the GUM server).
GUM mode streams your real-time context into the agent. Ensure .env is set (keys above), then:
python -m precursor.main --mode gum --log-level INFOOptional logging:
- Write processed events + final scratchpad to CSV:
python -m precursor.main --mode gum --output-csv dev/survey/pipeline_run.csv- Also log candidate tasks scored by the agent:
python -m precursor.main --mode gum --agent-output-csv dev/survey/pipeline_run.agent_candidates.csv- Log ALL proposed tasks with scores (one row per proposed task; includes columns: task_description, reasoning, scores, true_score, score_ratio, selected):
python -m precursor.main --mode gum --agent-proposals-csv dev/survey/pipeline_run.proposals.csv- Log high-level goals and their milestones (rows: project, goal, milestone):
python -m precursor.main --mode gum --agent-goals-milestones-csv dev/survey/pipeline_run.goals_milestones.csv- Save per-event screenshots (GUM mode) and include their paths in the CSV (
screenshot_path):
python -m precursor.main --mode gum --screenshot-dir dev/survey/screenshots --output-csv dev/survey/pipeline_run.csv- All logs + screenshots:
python -m precursor.main --mode gum --output-csv dev/survey/pipeline_run.csv --agent-output-csv dev/survey/pipeline_run.agent_candidates.csv --agent-proposals-csv dev/survey/pipeline_run.proposals.csv --agent-goals-milestones-csv dev/survey/pipeline_run.goals_milestones.csv --screenshot-dir dev/survey/screenshotsOther useful flags:
--no-deploy— score/log tasks without executing next steps--max-steps N— stop after N events--force-reset— delete the scratchpad DB on startup
If you see tasks being proposed in the logs but agents never produce results, the most common cause is one or more MCP servers failing to start. To diagnose:
-
Check agent logs in
~/Library/Application Support/precursor/logs/(macOS). Look for lines containingfailed to start — skippingor tracebacks right afterListToolsRequest/ListPromptsRequest. -
Common fixes by server:
Server Symptom Fix driveMissing credentials Place credentials.jsonat repo root and run once interactively to createtoken.pickle(see Google Drive section above)filesystemnpxnot foundInstall Node.js 18+ and ensure npxis on PATHwebsearchBrave API errors Set BRAVE_API_KEYin.envslidesnodenot found / module errorRun cd src/precursor/mcp_servers/slides && npm run setupcoderDocker not running Start Docker Desktop; also set GITHUB_TOKENin.envfetchModule not found pip install mcp-server-fetch -
Disable servers you don't need: edit
src/precursor/config/mcp_servers.yamland setenabled: falseon any server you haven't configured yet. The agent will run with whatever servers are available. -
Increase timeout on slow connections: set
server_startup_timeout: 120insettings.yaml(default is 60 seconds).