chronica_session_tick
Synchronize time-aware context and memory intervals before each Claude response to maintain persistent conversation continuity across sessions.
Instructions
【毎ターン・返答前に呼ぶ】MCPはサーバーからClaudeへ能動プッシュできないため、 ユーザーからメッセージを受け取ったら、返答を書く直前に必ず本ツールを呼ぶこと。 「常に許可」推奨。負荷は極小(短いJSONのみ)。
返却JSONの意味:
now_local: 現在のローカル日時(時分秒まで正確)
since_last_memory: 最後の記憶からの経過(「3日前」「数分前」「初回」など)→「何日ぶり」の根拠
last_topic_preview: 直近記憶の冒頭
season / time_of_day: 季節・時間帯
chronica_compose_opening は会話開始の挨拶用。2通目以降は本ツールで時刻・経過を毎回同期する。
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| thread_id | No | スレッドID(省略時は全体の直近記憶から経過を算出) |
Implementation Reference
- src/chronica/tools.py:449-455 (handler)Tool definition and dispatcher logic for "chronica_session_tick" in the MCP tool registry.
elif name == "chronica_session_tick": thread_id = arguments.get("thread_id") if arguments else None payload = session_tick_payload(store, thread_id) return [types.TextContent( type="text", text=json.dumps(payload, ensure_ascii=False) )] - src/chronica/opening.py:57-91 (helper)The actual implementation logic for the chronica_session_tick tool, which generates the session payload.
def session_tick_payload(store: Store, thread_id: Optional[str] = None) -> Dict[str, Any]: """ 各会話ターン用の軽量コンテキスト(JSON)。 MCP はホストに能動プッシュできないため、モデルが毎ターン呼ぶ前提で提供する。 """ now = datetime.now().astimezone() current_time = now.strftime("%Y-%m-%d %H:%M:%S") hour = now.hour if 5 <= hour < 11: time_of_day = "朝" elif 11 <= hour < 17: time_of_day = "昼" elif 17 <= hour < 21: time_of_day = "夕方" else: time_of_day = "夜" month = now.month if month in [12, 1, 2]: season = "冬" elif month in [3, 4, 5]: season = "春" elif month in [6, 7, 8]: season = "夏" else: season = "秋" time_expr, last_topic, _ = _memory_recency(store, thread_id, now) return { "now_local": current_time, "season": season, "time_of_day": time_of_day, "since_last_memory": time_expr, "last_topic_preview": last_topic, }