Provides per-request UTC date context for LLM agents to ground responses in time.
# Source: https://github.com/CopilotKit/OpenTag | License: MIT | Copyright 2026 CopilotKit
# Provided via justclaw.it.com; keep this notice with the code.
"""Per-request calendar context for the agent."""
from datetime import datetime, timezone
from langchain.agents.middleware import dynamic_prompt
from langchain.agents.middleware.types import ModelRequest
from langchain_core.messages import SystemMessage
def current_date_context(now: datetime | None = None) -> str:
"""Return authoritative UTC date guidance for the model."""
current = now or datetime.now(timezone.utc)
if current.tzinfo is None:
current = current.replace(tzinfo=timezone.utc)
current = current.astimezone(timezone.utc)
formatted_date = f"{current.strftime('%B')} {current.day}, {current.year}"
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key