Context
Commit 2c93428 landed the cost-reduction baseline for Sprint 92. This issue captures:
- What changed in the code.
- The handoff queries a future infra-cost-optimizer agent should run to verify and tune.
- The one-liner resume path when
e5g / sgu become clinically active again.
Only q1b (Erika Fusekova) is currently clinically active; e5g (Peter) and sgu (Nora) are onboarded but not under treatment review.
What changed (2c93428)
PatientProfile.paused: bool added (non-destructive pause).
e5g and sgu marked paused=True in patient_context.py.
- Scheduler gate added at
scheduler.py:126 — paused patients contribute zero per-patient jobs.
- 14 agent crons rewritten to once-per-week at CEE night (02:00-03:00 UTC, stacked at 15-min offsets).
document_pipeline_drain agent added (runs daily 02:00 UTC for q1b only).
api_document_webhook now:
- Rejects paused patients with
202 skipped_patient_paused (no Claude spend).
- Out-of-window uploads enqueued into
pending_docs_queue agent_state; drain agent processes nightly.
- In-window uploads (00:00-04:00 UTC by default) dispatch immediately as before.
AUTONOMOUS_COST_LIMIT default lowered $5 → $3.
PAUSED_PATIENTS env var → hot-pause without redeploy.
DOC_WEBHOOK_CEE_NIGHT_HOURS env var → override the immediate-dispatch window (default 0-4).
Tests: 850 pass, ruff clean.
Railway env vars to set on the oncoteam service
| Var |
Value |
Why |
AUTONOMOUS_COST_LIMIT |
3.0 |
Matches the new default; lower than the $10 pressure-test value. |
PAUSED_PATIENTS |
e5g,sgu |
Belt-and-suspenders with code; allows hot-unpause via env. |
DOC_WEBHOOK_CEE_NIGHT_HOURS |
0-4 (optional, default) |
Covers 01:00-05:00 Bratislava year-round. |
Handoff — what the infra-cost-optimizer agent should check
1. Verify the spend drop (run 7 days post-deploy)
mcp__claude_ai_Oncofiles__search_conversations(tags=\"sys:agent-run\", limit=500) → sum cost:* tags per task:* tag. Expect total < $4 / week.
GET https://api.oncoteam.cloud/api/autonomous/cost — expect mtd_spend on pace for ≤ $15/mo.
mcp__claude_ai_Oncofiles__search_conversations(tags=\"sys:cost-alert\") — expect zero new alerts.
2. Check the drain queue
mcp__claude_ai_Oncofiles__get_agent_state(\"pending_docs_queue\") after 02:30 UTC — should be empty or very small (<3 docs).
- If the queue regularly grows >20 docs overnight, split the drain into two cron slots (02:00 + 03:00 UTC) or add per-doc concurrency.
3. Scheduler job census
GET /health → scheduler.jobs count. With q1b active only, expect exactly 20 jobs (18 per-patient for q1b + 2 system).
- Any
:e5g or :sgu job IDs indicate the pause gate regressed.
4. WhatsApp reactive path
- Send a test message to +421800223213. Expect a Haiku reply within ~6s.
- Confirm no background WhatsApp broadcasts to paused-patient phone numbers.
Tuning knobs (for the future infra-cost-optimizer)
- If weekly cadence is too sparse for research on q1b, bump
daily_research back to every 3 days (schedule_params={\"day\": \"*/3\", \"hour\": 2}).
- If
mtd_spend exceeds $5/mo, downgrade daily_research and trial_monitor to Haiku (set model=\"light\" in agent_registry.py). Keep Sonnet only for pre_cycle_check and weekly_briefing.
- If the drain queue regularly hits >20 entries, split into
document_pipeline_drain_a (02:00 UTC) / document_pipeline_drain_b (03:00 UTC).
Resume path (non-destructive)
When e5g or sgu become active again:
- Via env (hot, no redeploy): set Railway
PAUSED_PATIENTS=\"sgu\" (keep whichever stays paused) or remove entirely, then restart the service.
- Via code: flip
paused=False on the profile in src/oncoteam/patient_context.py, push, Railway redeploys.
Tokens, oncofiles data, agent_state, conversation history — all preserved. No migration.
Related
Context
Commit 2c93428 landed the cost-reduction baseline for Sprint 92. This issue captures:
e5g/sgubecome clinically active again.Only
q1b(Erika Fusekova) is currently clinically active;e5g(Peter) andsgu(Nora) are onboarded but not under treatment review.What changed (2c93428)
PatientProfile.paused: booladded (non-destructive pause).e5gandsgumarkedpaused=Trueinpatient_context.py.scheduler.py:126— paused patients contribute zero per-patient jobs.document_pipeline_drainagent added (runs daily 02:00 UTC for q1b only).api_document_webhooknow:202 skipped_patient_paused(no Claude spend).pending_docs_queueagent_state; drain agent processes nightly.AUTONOMOUS_COST_LIMITdefault lowered$5 → $3.PAUSED_PATIENTSenv var → hot-pause without redeploy.DOC_WEBHOOK_CEE_NIGHT_HOURSenv var → override the immediate-dispatch window (default0-4).Tests: 850 pass, ruff clean.
Railway env vars to set on the oncoteam service
AUTONOMOUS_COST_LIMIT3.0PAUSED_PATIENTSe5g,sguDOC_WEBHOOK_CEE_NIGHT_HOURS0-4(optional, default)Handoff — what the infra-cost-optimizer agent should check
1. Verify the spend drop (run 7 days post-deploy)
mcp__claude_ai_Oncofiles__search_conversations(tags=\"sys:agent-run\", limit=500)→ sumcost:*tags pertask:*tag. Expect total < $4 / week.GET https://api.oncoteam.cloud/api/autonomous/cost— expectmtd_spendon pace for ≤ $15/mo.mcp__claude_ai_Oncofiles__search_conversations(tags=\"sys:cost-alert\")— expect zero new alerts.2. Check the drain queue
mcp__claude_ai_Oncofiles__get_agent_state(\"pending_docs_queue\")after 02:30 UTC — should be empty or very small (<3 docs).3. Scheduler job census
GET /health→scheduler.jobscount. With q1b active only, expect exactly 20 jobs (18 per-patient for q1b + 2 system).:e5gor:sgujob IDs indicate the pause gate regressed.4. WhatsApp reactive path
Tuning knobs (for the future infra-cost-optimizer)
daily_researchback to every 3 days (schedule_params={\"day\": \"*/3\", \"hour\": 2}).mtd_spendexceeds $5/mo, downgradedaily_researchandtrial_monitorto Haiku (setmodel=\"light\"inagent_registry.py). Keep Sonnet only forpre_cycle_checkandweekly_briefing.document_pipeline_drain_a(02:00 UTC) /document_pipeline_drain_b(03:00 UTC).Resume path (non-destructive)
When
e5gorsgubecome active again:PAUSED_PATIENTS=\"sgu\"(keep whichever stays paused) or remove entirely, then restart the service.paused=Falseon the profile insrc/oncoteam/patient_context.py, push, Railway redeploys.Tokens, oncofiles data, agent_state, conversation history — all preserved. No migration.
Related