feat: 智能体创建流程优化与管理员记忆页面

- 创建智能体页面:保存后自动跳转列表页、技能列表增加搜索过滤框
- Bootstrap 模式:开放全部技能可见性,注入专属提示词(skill_list 匹配意图、禁止 skill_manage)
- 管理员记忆页面:新增 AdminMemoryPage 及路由,支持查看/编辑用户记忆条目
- 内存配置与管理员用户接口同步更新

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
xuhdandClaude Sonnet 4.6 committed 2026-05-21 11:43:59 +08:00
1 parent 18c2a4122f
commit 3748513996
12 files changed
+692 -143

No files matched your search

@@ -375,7 +375,7 @@ def _make_lead_agent(config: RunnableConfig, *, app_config: AppConfig):
config["metadata"] = {}
if is_bootstrap:
runtime_available_skills: list[str] | None = ["bootstrap"]
runtime_available_skills: list[str] | None = None # all enabled skills visible in bootstrap
elif agent_config:
# Custom agents must use an explicit allowlist. If omitted, default to none.
runtime_available_skills = list(agent_config.skills or [])
@@ -416,7 +416,8 @@ def _make_lead_agent(config: RunnableConfig, *, app_config: AppConfig):
max_concurrent_subagents=max_concurrent_subagents,
writing_mode=writing_mode,
writing_artifact_path=writing_artifact_path,
available_skills=set(["bootstrap"]),
available_skills=None,
is_bootstrap=True,
app_config=resolved_app_config,
),
state_schema=ThreadState,
@@ -496,6 +496,8 @@ You: "Deploying to staging..." [proceed]
{skills_section}
{bootstrap_section}
{deferred_tools_section}
{writing_mode_section}
@@ -819,6 +821,27 @@ def _build_custom_mounts_section(*, app_config: AppConfig | None = None) -> str:
return f"\n**Custom Mounted Directories:**\n{mounts_list}\n- If the user needs files outside `/mnt/user-data`, use these absolute container paths directly when they match the requested directory"
def _build_bootstrap_section() -> str:
return """<bootstrap_agent_creation>
你正在帮助用户创建一个自定义智能体。
**技能匹配规则(必须遵守):**
1. 先调用 `skill_list` 查看用户当前所有可用技能及其描述。
2. 根据用户对新智能体的描述/意图,从已有技能中选出最相关的 1-5 个技能名称(skill name,使用 hyphen-case)。
3. 将选出的技能名称填入 `setup_agent` 的 `skills` 参数。
4. **严禁在本次创建流程中调用 `skill_manage`(创建、编辑或删除技能)**。如用户提出需要新技能,请告知他们创建完智能体后再单独创建。
5. 如果没有任何技能与用户意图相关,可将 `skills` 设为空列表,并向用户说明原因。
**工作流程:**
1. 与用户充分沟通,明确新智能体的用途、专长和边界。
2. 调用 `skill_list` 列出现有技能。
3. 在思考中匹配技能,选出最合适的。
4. 草拟 SOUL.md(定义智能体的人设、工作方式、输出要求)。
5. 向用户确认配置后,调用 `setup_agent` 提交。
</bootstrap_agent_creation>
"""
def apply_prompt_template(
subagent_enabled: bool = False,
max_concurrent_subagents: int = 3,
@@ -828,6 +851,7 @@ def apply_prompt_template(
writing_mode: bool = False,
writing_artifact_path: str | None = None,
available_skills: set[str] | None = None,
is_bootstrap: bool = False,
app_config: AppConfig | None = None,
) -> str:
storage_agent_id = agent_id if agent_id is not None else agent_name
@@ -857,6 +881,9 @@ def apply_prompt_template(
else ""
)
# Bootstrap section: skill-matching guidance (only in agent creation flow)
bootstrap_section = _build_bootstrap_section() if is_bootstrap else ""
# Get skills section
skills_section = get_skills_prompt_section(available_skills, app_config=app_config)
@@ -902,6 +929,7 @@ Writing mode is enabled for this run.
agent_name=agent_name or storage_agent_id or "CM 助手",
soul=get_agent_soul(storage_agent_id),
skills_section=skills_section,
bootstrap_section=bootstrap_section,
deferred_tools_section=deferred_tools_section,
writing_mode_section=writing_mode_section,
memory_context=memory_context,
@@ -73,7 +73,7 @@ class HindsightMemoryConfig(BaseModel):
description="agent 私有工作 bank 命名模板",
)
memory_mode: str = Field(
default="context",
default="hybrid",
description="工具暴露策略:context(仅自动) / tools(仅工具) / hybrid(两者)",
)
bank_mission: str = Field(default="", description="reflect 推理的身份/框架描述")
@@ -136,13 +136,15 @@ class MemoryConfig(BaseModel):
# 不在此表中的字段必须改 config.yaml 并重启 (例如 provider / api_key / 字符配额)。
USER_WRITABLE_FIELDS: frozenset[str] = frozenset(
{
"injection.enabled",
# injection.enabled and injection.include_builtin are always ON;
# removing them from the whitelist makes _filter_to_whitelist drop
# any per-user override for these fields, so stored "false" values
# in existing memory_config.json files are silently ignored.
"injection.max_tokens",
"injection.include_builtin",
"injection.include_hindsight",
"hindsight.memory_mode",
# hindsight.memory_mode is fixed to "hybrid"; not user-writable.
# hindsight.bank_mission is fixed; not user-writable.
"hindsight.recall_budget",
"hindsight.bank_mission",
}
)