mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 04:40:45 +08:00
重构主控编排与运行时预热链路,统一工作区提示词/专家调度协议并补齐 wiki 记忆注入与写回闭环。
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。 Made-with: Cursor
This commit is contained in:
parent
4a23b715a2
commit
dbbe3add6a
14438 changed files with 2693620 additions and 2546 deletions
|
|
@ -10,6 +10,7 @@ from oclaw.runtime.agents.network_ops_agent import NetworkOpsAgent
|
|||
from oclaw.runtime.agents.specialist_agent import SpecialistProfile
|
||||
from oclaw.runtime.agents.specialists import (
|
||||
AGENT_PROFILE_BINDINGS_KEY,
|
||||
normalize_specialist_id,
|
||||
AGENT_ROLE_IDS,
|
||||
MANAGER_AGENT_ID,
|
||||
SPECIALIST_IDS,
|
||||
|
|
@ -213,26 +214,12 @@ def _build_executor_components(
|
|||
except Exception:
|
||||
pass
|
||||
specialist_profiles = {
|
||||
"ops": SpecialistProfile(
|
||||
name="ops",
|
||||
system_prefix=default_system_prefix_for_specialist("ops", lang),
|
||||
tool_tags=default_tool_tags_for_specialist("ops"),
|
||||
),
|
||||
"generalist": SpecialistProfile(
|
||||
name="generalist",
|
||||
system_prefix=default_system_prefix_for_specialist("generalist", lang),
|
||||
tool_tags=default_tool_tags_for_specialist("generalist"),
|
||||
),
|
||||
"image": SpecialistProfile(
|
||||
name="image",
|
||||
system_prefix=default_system_prefix_for_specialist("image", lang),
|
||||
tool_tags=default_tool_tags_for_specialist("image"),
|
||||
),
|
||||
"memory_curator": SpecialistProfile(
|
||||
name="memory_curator",
|
||||
system_prefix=default_system_prefix_for_specialist("memory_curator", lang),
|
||||
tool_tags=default_tool_tags_for_specialist("memory_curator"),
|
||||
),
|
||||
sid: SpecialistProfile(
|
||||
name=sid,
|
||||
system_prefix=default_system_prefix_for_specialist(sid, lang),
|
||||
tool_tags=default_tool_tags_for_specialist(sid),
|
||||
)
|
||||
for sid in SPECIALIST_IDS
|
||||
}
|
||||
return (
|
||||
base_agent,
|
||||
|
|
@ -299,7 +286,7 @@ def build_gateway_executor(
|
|||
viewer_username=viewer_username,
|
||||
viewer_tenant_id=viewer_tenant_id,
|
||||
)
|
||||
sid = str(specialist or "").strip().lower() or "generalist"
|
||||
sid = normalize_specialist_id(specialist)
|
||||
if sid not in specialist_profiles:
|
||||
sid = "generalist"
|
||||
prof = specialist_profiles.get(sid) or specialist_profiles["generalist"]
|
||||
|
|
|
|||
|
|
@ -3,11 +3,16 @@ from __future__ import annotations
|
|||
from typing import Any
|
||||
|
||||
from oclaw.runtime.chat.agent import Agent
|
||||
from oclaw.runtime.agent_context import build_role_system_context
|
||||
from oclaw.platform.persistence.sqlite_store import SqliteStore
|
||||
from oclaw.prompts.loader import render_runtime_prompt
|
||||
from oclaw.prompts.loader import render_prompt
|
||||
from oclaw.runtime.tools import default_registry
|
||||
|
||||
NETWORK_SYSTEM_PROMPT_ZH = render_runtime_prompt("roles/specialists/ops/system.md", strict=True)
|
||||
NETWORK_SYSTEM_PROMPT_ZH = render_prompt(
|
||||
"agents/network_ops_system.zh.md",
|
||||
variables={"ROLE_SYSTEM_CONTEXT": build_role_system_context("ops")},
|
||||
strict=True,
|
||||
)
|
||||
|
||||
|
||||
class NetworkOpsAgent(Agent):
|
||||
|
|
@ -36,7 +41,7 @@ class NetworkOpsAgent(Agent):
|
|||
store=store,
|
||||
tools=tools,
|
||||
model=model,
|
||||
system_prompt=(system_prompt or render_runtime_prompt("roles/specialists/ops/system.md", strict=True)),
|
||||
system_prompt=(system_prompt or NETWORK_SYSTEM_PROMPT_ZH),
|
||||
lang=lang,
|
||||
llm_profile_mode=llm_profile_mode,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import json
|
|||
from typing import Any
|
||||
|
||||
from oclaw.runtime.agent_context import build_role_system_context
|
||||
from oclaw.runtime.workspaces.experts import discover_specialist_ids_from_workspaces
|
||||
|
||||
|
||||
SpecialistId = str
|
||||
|
|
@ -38,37 +39,52 @@ SPECIALISTS: dict[SpecialistId, SpecialistConfig] = {
|
|||
expert_name="generalist",
|
||||
default_tool_tags=None,
|
||||
),
|
||||
"memory_curator": SpecialistConfig(
|
||||
specialist_id="memory_curator",
|
||||
expert_name="memory_curator",
|
||||
"memory": SpecialistConfig(
|
||||
specialist_id="memory",
|
||||
expert_name="memory",
|
||||
default_tool_tags=None,
|
||||
),
|
||||
}
|
||||
SPECIALIST_IDS: tuple[SpecialistId, ...] = tuple(SPECIALISTS.keys())
|
||||
|
||||
def discover_specialist_ids() -> tuple[SpecialistId, ...]:
|
||||
return discover_specialist_ids_from_workspaces(base_order=("generalist", "ops", "image", "memory"))
|
||||
|
||||
|
||||
SPECIALIST_IDS: tuple[SpecialistId, ...] = discover_specialist_ids()
|
||||
AGENT_ROLE_IDS: tuple[AgentRoleId, ...] = (MANAGER_AGENT_ID, *SPECIALIST_IDS)
|
||||
|
||||
|
||||
def expert_name_for_specialist(specialist_id: SpecialistId) -> str:
|
||||
cfg = SPECIALISTS.get(specialist_id) or SPECIALISTS["generalist"]
|
||||
sid = normalize_specialist_id(specialist_id)
|
||||
cfg = SPECIALISTS.get(sid) or SPECIALISTS["generalist"]
|
||||
return cfg.expert_name
|
||||
|
||||
|
||||
def default_tool_tags_for_specialist(specialist_id: SpecialistId) -> frozenset[str] | None:
|
||||
cfg = SPECIALISTS.get(specialist_id) or SPECIALISTS["generalist"]
|
||||
sid = normalize_specialist_id(specialist_id)
|
||||
cfg = SPECIALISTS.get(sid) or SPECIALISTS["generalist"]
|
||||
return cfg.default_tool_tags
|
||||
|
||||
|
||||
def default_system_prefix_for_specialist(specialist_id: SpecialistId, lang: str = "zh") -> str:
|
||||
sid = (specialist_id or "").strip().lower() or "generalist"
|
||||
cfg = SPECIALISTS.get(sid) or SPECIALISTS["generalist"]
|
||||
sid = normalize_specialist_id(specialist_id)
|
||||
_ = (lang or "zh").strip().lower()
|
||||
return build_role_system_context(cfg.specialist_id)
|
||||
return build_role_system_context(sid)
|
||||
|
||||
|
||||
def model_role_for_specialist(specialist_id: SpecialistId) -> AgentRoleId:
|
||||
sid = normalize_specialist_id(specialist_id)
|
||||
if sid in SPECIALIST_IDS:
|
||||
return sid
|
||||
return "generalist"
|
||||
|
||||
|
||||
def normalize_specialist_id(specialist_id: SpecialistId | None) -> SpecialistId:
|
||||
sid = (specialist_id or "").strip().lower()
|
||||
if sid in SPECIALISTS:
|
||||
return sid
|
||||
if sid in discover_specialist_ids():
|
||||
return sid
|
||||
return "generalist"
|
||||
|
||||
|
||||
|
|
@ -117,7 +133,9 @@ __all__ = [
|
|||
"SPECIALIST_IDS",
|
||||
"default_system_prefix_for_specialist",
|
||||
"default_tool_tags_for_specialist",
|
||||
"discover_specialist_ids",
|
||||
"expert_name_for_specialist",
|
||||
"model_role_for_specialist",
|
||||
"normalize_specialist_id",
|
||||
"parse_agent_profile_bindings",
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue