From 520cdb2b90536d13a645df2d94f4434cbba69527 Mon Sep 17 00:00:00 2001 From: Google Gemini Date: Sun, 22 Mar 2026 23:30:16 +0000 Subject: [PATCH] Add reflection scheduler --- src/dashboard/app.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/dashboard/app.py b/src/dashboard/app.py index 7e1ccba9..092daeb7 100644 --- a/src/dashboard/app.py +++ b/src/dashboard/app.py @@ -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()), ]