Skip to content

feat: add LLM_EVERY_N_SWEEPS to reduce API costs#58

Open
TheMMstick wants to merge 1 commit intocalesthio:masterfrom
TheMMstick:feat/llm-sweep-interval
Open

feat: add LLM_EVERY_N_SWEEPS to reduce API costs#58
TheMMstick wants to merge 1 commit intocalesthio:masterfrom
TheMMstick:feat/llm-sweep-interval

Conversation

@TheMMstick
Copy link

Summary

  • Adds LLM_EVERY_N_SWEEPS env var to decouple LLM analysis frequency from the data sweep interval
  • Between LLM runs, previous trade ideas are carried forward so the dashboard always has content
  • Defaults to 1 (every sweep) — fully backward compatible, no behavior change unless configured
  • Documented in .env.example and exposed via /api/health

Motivation

With 15-min sweeps and LLM enabled, the AI layer runs ~96 times/day. For many users this is unnecessarily frequent and costly. Setting LLM_EVERY_N_SWEEPS=12 reduces AI calls to ~8/day (every 3 hours) while keeping OSINT data fresh every 15 minutes.

Files changed

  • crucix.config.mjs — new llmEveryNSweeps config key
  • server.mjs — sweep counter + conditional LLM execution + health endpoint field
  • .env.example — documented the new option

Test plan

  • Default behavior (LLM_EVERY_N_SWEEPS=1 or unset): LLM runs every sweep as before
  • LLM_EVERY_N_SWEEPS=3: LLM runs on sweeps 3, 6, 9… and skips others with log message
  • Skipped sweeps carry forward previous ideas (dashboard still shows trade ideas)
  • /api/health returns llmEveryNSweeps field
  • Alert evaluation only fires on LLM sweeps

…frequency

Data sweeps and LLM analysis currently run at the same interval. For users
who want frequent OSINT data updates but less frequent (and costly) AI
analysis, this adds a new LLM_EVERY_N_SWEEPS env var that controls how
often the LLM runs relative to sweeps.

Example: REFRESH_INTERVAL_MINUTES=15 + LLM_EVERY_N_SWEEPS=12 gives data
every 15 min but AI analysis every 3 hours, reducing API costs ~12x.

Between LLM runs, previous trade ideas are carried forward so the
dashboard always has content. Default is 1 (every sweep), preserving
current behavior.
@TheMMstick TheMMstick requested a review from calesthio as a code owner March 20, 2026 10:46
@calesthio
Copy link
Owner

I haven't been able to get to this yet because work has been busy, but I definitely plan to review it over the weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants