Add reflection scheduler
Some checks failed
Tests / lint (pull_request) Failing after 17s
Tests / test (pull_request) Has been skipped

This commit is contained in:
2026-03-22 23:30:16 +00:00
parent 066e8bbb9c
commit 520cdb2b90

View File

@@ -232,6 +232,22 @@ _SYNTHESIZED_STATE: dict = {
}
async function _reflection_scheduler() -> None:
"""Background task: execute Timmy's self-reflection cycle every 4 hours."""
from timmy.reflection import reflection_engine
await asyncio.sleep(15) # Stagger after other schedulers
while True:
try:
await reflection_engine.reflect_once()
except Exception as exc:
logger.error("Reflection scheduler error: %s", exc)
await asyncio.sleep(4 * 3600)
async def _presence_watcher() -> None:
"""Background task: watch ~/.timmy/presence.json and broadcast changes via WS.
@@ -379,6 +395,7 @@ def _startup_background_tasks() -> list[asyncio.Task]:
asyncio.create_task(_thinking_scheduler()),
asyncio.create_task(_loop_qa_scheduler()),
asyncio.create_task(_presence_watcher()),
asyncio.create_task(_reflection_scheduler()),
asyncio.create_task(_start_chat_integrations_background()),
]