feat: per-role tool lists and system prompt overlays
Each role in model_registry.json can now carry two optional keys:
system_append — injected into the system prompt at position 7 (after
memory, closest to the turn) for the active chat_role
tools — explicit tool allow-list; intersected with the user's
access-level filter so it can only restrict, never elevate
No changes needed for existing users — missing keys fall back to current
behavior. Add keys to a role to give it a specialty focus:
"coder": {
"primary": "claude_cli",
"system_append": "You are in code-specialist mode...",
"tools": ["web_search", "file_read", "shell_exec", "scratch_write"]
}
Changes:
- model_registry.py: get_role_config() returns system_append + tools
- context_loader.py: role_append param appended as "--- Role Context ---"
- tools/__init__.py: get_tools_for_role/get_openai_tools_for_role accept
optional tool_list and intersect with access-level filter
- orchestrator_engine.py: tool_list threaded through run/resume/checkpoint
- openai_orchestrator.py: tool_list threaded through run/resume/checkpoint;
_build_client now calls get_openai_tools_for_role instead of returning
unfiltered OPENAI_TOOL_SCHEMAS
- routers/orchestrator.py: pulls role_cfg for chat_role, passes both
role_append and tool_list to context loader and engine
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -17,6 +17,7 @@ def load_context(
|
||||
include_long: bool = True,
|
||||
include_mid: bool = True,
|
||||
include_short: bool = True,
|
||||
role_append: str = "",
|
||||
) -> str:
|
||||
"""
|
||||
Build the system-prompt context block for a given tier and memory toggles.
|
||||
@@ -28,6 +29,9 @@ def load_context(
|
||||
Tier 2 — + USER full + PROTOCOLS + memory (~5,000 tokens)
|
||||
Tier 3 — + last 2 raw session logs (~15,000 tokens)
|
||||
Tier 4 — + last 7 raw session logs (~50,000 tokens)
|
||||
|
||||
role_append — optional text injected last (closest to the turn),
|
||||
sourced from the active role's system_append config.
|
||||
"""
|
||||
inara_dir = persona_path()
|
||||
parts = []
|
||||
@@ -107,4 +111,8 @@ def load_context(
|
||||
for sf in session_files:
|
||||
parts.append(f"--- Session: {sf.name} ---\n{sf.read_text()}")
|
||||
|
||||
# ── 7. Role-specific instructions (always last — closest to the turn) ──
|
||||
if role_append and role_append.strip():
|
||||
parts.append(f"--- Role Context ---\n{role_append.strip()}")
|
||||
|
||||
return "\n\n".join(parts)
|
||||
|
||||
Reference in New Issue
Block a user