A Filter Function that gives every LLM real-time and historical awareness of when things happened.
On every chat turn the model receives:
- The current wall-clock time — auto-detected from the user's timezone (Open WebUI already collects this at login).
- A chronological timeline of the past conversation — with each message's real timestamp pulled from Open WebUI's
chat_messagedatabase table.
# Temporal Awareness
The current time is: 2026-07-15 16:23:00 CEST.
Conversation timeline (each turn's real timestamp, oldest first):
- [2026-07-15 14:30:02 CEST] user: Hi, can you remind me what we discussed last week…
- [2026-07-15 14:30:45 CEST] assistant: Last week we outlined three pillars for Q3…
- [2026-07-15 16:21:11 CEST] user: Great. Now what about the budget?
- [2026-07-15 16:22:38 CEST] assistant: For the budget…
Use the timestamps above to reason about when each message was sent. When the user
asks about something that happened earlier, later, or "now", refer to this temporal context.
| Scenario | What happens |
|---|---|
| Page reload | Timestamps are fetched fresh from the DB on the next request. |
| Browser cache cleared | Same — DB is the source of truth. |
| Open WebUI server restart | Filter reloads from request.app.state.FUNCTIONS; DB still has everything. |
| New chat | Only "current time" is injected until a prior message exists. |
Direct API call (no chat_id) |
Only "current time" is injected. Timeline is skipped. |
Open WebUI's middleware.py strips timestamp from body["messages"] before inlet() runs. This filter works around that by calling Chats.get_messages_map_by_chat_id() directly — the same internal method Open WebUI uses to reconstruct conversation history, and it does include timestamp.
- Open Open WebUI as an admin.
- Admin Panel → Functions → Create
- ID:
time_awareness - Name:
Time Awareness - Paste the contents of
time_awareness.pyinto the editor. - Save
- Toggle Active ON.
- (Recommended) Click the globe icon to make it Global — applies to all models automatically.
https://raw.githubusercontent.com/open-webui-timeawareness/main/time_awareness.py
Admin Panel → Functions → Import from URL → paste → Save.
| Valve | Default | Description |
|---|---|---|
priority |
0 |
Filter ordering. Lower runs first. |
inject_current_time |
True |
Inject current wall-clock time. |
inject_message_timeline |
True |
Inject per-message timeline. |
time_format |
%Y-%m-%d %H:%M:%S %Z |
strftime format string. |
default_timezone |
UTC |
Fallback IANA timezone. |
max_timeline_messages |
50 |
Hard cap on past messages listed. |
timeline_preview_chars |
60 |
Characters of each message to include as preview. |
- Because
self.toggle = True, it appears as a clickable chip in the chat input bar. - Clicking opens the per-user valve modal where each user can enable/disable it per chat.
- Open WebUI ≥ 0.5.0 (uses
Chats.get_messages_map_by_chat_id). - All models — works with native and legacy function calling.
- No external dependencies — only stdlib (
zoneinfo,datetime) pluspydantic(already bundled).
MIT