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:
@@ -313,6 +313,14 @@ def _render(username: str, success: str = "", error: str = "") -> str:
|
||||
f'<textarea class="rcp-textarea" data-role="{role}" rows="3" '
|
||||
f'placeholder="Extra instructions injected into the system prompt when this role is active…"></textarea>'
|
||||
f'</div>'
|
||||
f'<div class="rcp-field rcp-field-inline">'
|
||||
f'<label class="rcp-check">'
|
||||
f'<input type="checkbox" class="rcp-datetime-cb" data-role="{role}" checked>'
|
||||
f' Inject current date & time into system prompt'
|
||||
f'</label>'
|
||||
f'<span class="rcp-hint" style="display:block;margin-top:0.2rem">'
|
||||
f'Disable for pure processing roles (summarizer, classifier, translator)</span>'
|
||||
f'</div>'
|
||||
f'<div class="rcp-field">'
|
||||
f'<label class="rcp-label">Tool allow-list '
|
||||
f'<span class="rcp-hint">— all checked means no restriction (use all accessible tools)</span></label>'
|
||||
@@ -332,8 +340,9 @@ def _render(username: str, success: str = "", error: str = "") -> str:
|
||||
|
||||
role_config_data_js = _json.dumps({
|
||||
role: {
|
||||
"system_append": roles.get(role, {}).get("system_append", ""),
|
||||
"tools": roles.get(role, {}).get("tools") or None,
|
||||
"system_append": roles.get(role, {}).get("system_append", ""),
|
||||
"tools": roles.get(role, {}).get("tools") or None,
|
||||
"inject_datetime": roles.get(role, {}).get("inject_datetime", True),
|
||||
}
|
||||
for role in app_settings.get_defined_roles()
|
||||
})
|
||||
@@ -574,10 +583,11 @@ async def set_role(request: Request) -> JSONResponse:
|
||||
|
||||
@router.post("/api/models/role-config")
|
||||
async def set_role_config(request: Request) -> JSONResponse:
|
||||
"""AJAX: save system_append and tool allow-list for a role.
|
||||
"""AJAX: save system_append, tool allow-list, and inject_datetime flag for a role.
|
||||
|
||||
Body: {"role": "coder", "system_append": "...", "tools": ["web_search", ...] | null}
|
||||
Body: {"role": "coder", "system_append": "...", "tools": [...] | null, "inject_datetime": true}
|
||||
tools=null clears the allow-list (role uses all accessible tools).
|
||||
inject_datetime=false suppresses the date/time header for pure processing roles.
|
||||
"""
|
||||
username = _get_user(request)
|
||||
if not username:
|
||||
@@ -587,18 +597,19 @@ async def set_role_config(request: Request) -> JSONResponse:
|
||||
except Exception:
|
||||
return JSONResponse({"error": "Invalid JSON"}, status_code=400)
|
||||
|
||||
role = body.get("role", "").strip()
|
||||
system_append = body.get("system_append", "")
|
||||
tools = body.get("tools") # list[str] or None
|
||||
role = body.get("role", "").strip()
|
||||
system_append = body.get("system_append", "")
|
||||
tools = body.get("tools") # list[str] or None
|
||||
inject_datetime = body.get("inject_datetime", True)
|
||||
|
||||
if not role:
|
||||
return JSONResponse({"error": "role is required"}, status_code=400)
|
||||
if tools is not None and not isinstance(tools, list):
|
||||
return JSONResponse({"error": "tools must be a list or null"}, status_code=400)
|
||||
|
||||
reg.set_role_config(username, role, system_append, tools)
|
||||
logger.info("role config saved: %s %s (tools=%s)", username, role,
|
||||
len(tools) if tools is not None else "all")
|
||||
reg.set_role_config(username, role, system_append, tools, inject_datetime=bool(inject_datetime))
|
||||
logger.info("role config saved: %s %s (tools=%s inject_datetime=%s)",
|
||||
username, role, len(tools) if tools is not None else "all", inject_datetime)
|
||||
return JSONResponse({"ok": True})
|
||||
|
||||
|
||||
|
||||
@@ -203,6 +203,7 @@ async def _run_job(job_id: str, req: OrchestrateRequest, user: str) -> None:
|
||||
include_mid=req.include_mid,
|
||||
include_short=req.include_short,
|
||||
role_append=role_cfg.get("system_append", ""),
|
||||
inject_datetime=role_cfg.get("inject_datetime", True),
|
||||
)
|
||||
|
||||
session_id = req.session_id or generate_session_id()
|
||||
|
||||
Reference in New Issue
Block a user