Add reflection scheduler
This commit is contained in:
@@ -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()),
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user