feat: per-role inject_datetime toggle for system prompt
Each role can now disable the current date/time header injected into the system prompt. Default is true (all existing roles unchanged). Useful for pure processing roles (summarizer, classifier, translator) where temporal context is irrelevant or could cause unexpected model behavior. Changes: - model_registry: set_role_config/get_role_config gain inject_datetime field - context_loader: load_context gains inject_datetime param (default True) - orchestrator router: passes inject_datetime from role_cfg to load_context - local_llm router: reads inject_datetime from POST body, passes to registry; role_config_data_js includes the field - local_llm.html: checkbox in role config panel; populate on open, save on submit Session logs still timestamp every turn (HH:MM header in YYYY-MM-DD.md files) regardless of this setting — the toggle only affects the system prompt header. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -416,17 +416,25 @@ def get_best_local_model(username: str, role: str = "chat") -> dict | None:
|
||||
return None
|
||||
|
||||
|
||||
def set_role_config(username: str, role: str, system_append: str, tools: list[str] | None) -> None:
|
||||
"""Save system_append and tools allow-list for a role.
|
||||
def set_role_config(
|
||||
username: str,
|
||||
role: str,
|
||||
system_append: str,
|
||||
tools: list[str] | None,
|
||||
inject_datetime: bool = True,
|
||||
) -> None:
|
||||
"""Save system_append, tools allow-list, and inject_datetime flag for a role.
|
||||
|
||||
tools=None clears the allow-list (role uses all accessible tools).
|
||||
tools=[] would mean no tools at all — validate in the caller if that's undesired.
|
||||
inject_datetime=False suppresses the current date/time from the system prompt
|
||||
for this role — useful for pure processing roles (summarizer, classifier, etc.).
|
||||
"""
|
||||
data = _load(username)
|
||||
roles = data.setdefault("roles", {})
|
||||
if role not in roles:
|
||||
roles[role] = {}
|
||||
roles[role]["system_append"] = system_append.strip()
|
||||
roles[role]["inject_datetime"] = inject_datetime
|
||||
if tools is None:
|
||||
roles[role].pop("tools", None)
|
||||
else:
|
||||
@@ -436,17 +444,19 @@ def set_role_config(username: str, role: str, system_append: str, tools: list[st
|
||||
|
||||
def get_role_config(username: str, role: str) -> dict:
|
||||
"""
|
||||
Return supplemental config for a role: system_append and tools.
|
||||
Return supplemental config for a role: system_append, tools, and inject_datetime.
|
||||
|
||||
Both keys are optional in the registry — missing means "use defaults":
|
||||
system_append: str — appended to the system prompt for this role
|
||||
All keys are optional in the registry — missing means "use defaults":
|
||||
system_append: str — appended to the system prompt for this role
|
||||
tools: list[str] | None — explicit tool allow-list (None = no restriction)
|
||||
inject_datetime: bool — whether to inject current date/time (default True)
|
||||
"""
|
||||
registry = _load(username)
|
||||
role_cfg = registry.get("roles", {}).get(role, {})
|
||||
return {
|
||||
"system_append": role_cfg.get("system_append", ""),
|
||||
"tools": role_cfg.get("tools") or None,
|
||||
"system_append": role_cfg.get("system_append", ""),
|
||||
"tools": role_cfg.get("tools") or None,
|
||||
"inject_datetime": role_cfg.get("inject_datetime", True),
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user