mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-08 23:33:16 +08:00
Drop dead admin/chat protocol fields and fix MCP specialist docs.
Align AIA_MCP_SPECIALISTS defaults, remove inherit/perm-ban/wire-effective noise from admin APIs, and stop echoing confirm_strategy/plan_agent_version on chat mode endpoints. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
454c841af7
commit
8fce428540
12 changed files with 47 additions and 169 deletions
|
|
@ -737,24 +737,12 @@ def _normalize_execution_mode(payload: dict[str, Any] | None) -> str:
|
|||
return raw if raw in {"agent", "plan"} else "agent"
|
||||
|
||||
|
||||
def _normalize_confirm_strategy(payload: dict[str, Any] | None) -> str:
|
||||
"""Plan-mode confirm gate removed; keep a fixed wire default for older clients."""
|
||||
del payload
|
||||
return "strict"
|
||||
|
||||
|
||||
def _normalize_plan_agent_version(payload: dict[str, Any] | None) -> str:
|
||||
"""Plan agent v2 removed; always wire as classic v1."""
|
||||
del payload
|
||||
return "v1"
|
||||
|
||||
|
||||
def _resolve_user_menu_chat_settings(
|
||||
*,
|
||||
store: SqliteStore,
|
||||
tenant_id: str,
|
||||
user_id: str,
|
||||
) -> tuple[str, str, str, str]:
|
||||
) -> tuple[str, str]:
|
||||
"""User-wide settings (⋯ menu): mode + specialist — all sessions share these keys."""
|
||||
user_mode_key = _chat_user_mode_setting_key(tenant_id=tenant_id, user_id=user_id, field="interaction_mode")
|
||||
user_specialist_key = _chat_user_mode_setting_key(tenant_id=tenant_id, user_id=user_id, field="specialist")
|
||||
|
|
@ -763,8 +751,7 @@ def _resolve_user_menu_chat_settings(
|
|||
interaction_mode = normalize_interaction_mode(mode_raw or "expert")
|
||||
specialist = normalize_requested_specialist(specialist_raw or "generalist")
|
||||
specialist = _apply_specialist_flags(store, specialist)
|
||||
# Legacy plan-mode fields kept as wire constants for older clients.
|
||||
return interaction_mode, specialist, "strict", "v1"
|
||||
return interaction_mode, specialist
|
||||
|
||||
|
||||
def _persist_user_menu_chat_settings(
|
||||
|
|
@ -774,10 +761,7 @@ def _persist_user_menu_chat_settings(
|
|||
user_id: str,
|
||||
interaction_mode: str,
|
||||
specialist: str,
|
||||
confirm_strategy: str,
|
||||
plan_agent_version: str,
|
||||
) -> None:
|
||||
del confirm_strategy, plan_agent_version
|
||||
store.set_setting(
|
||||
_chat_user_mode_setting_key(tenant_id=tenant_id, user_id=user_id, field="interaction_mode"),
|
||||
interaction_mode,
|
||||
|
|
@ -834,13 +818,13 @@ def _resolve_mode_settings(
|
|||
tenant_id: str,
|
||||
user_id: str,
|
||||
session_id: str,
|
||||
) -> tuple[str, str, str, str, str, str]:
|
||||
"""User-wide mode/specialist + session memory/exec (+ legacy confirm/plan_agent defaults) for gateway + REST send."""
|
||||
u_im, u_sp, u_cs, u_pav = _resolve_user_menu_chat_settings(store=store, tenant_id=tenant_id, user_id=user_id)
|
||||
) -> tuple[str, str, str, str]:
|
||||
"""User-wide mode/specialist + session memory/exec for gateway + REST send."""
|
||||
u_im, u_sp = _resolve_user_menu_chat_settings(store=store, tenant_id=tenant_id, user_id=user_id)
|
||||
s_mm, s_em = _resolve_session_dialog_chat_settings(
|
||||
store=store, tenant_id=tenant_id, user_id=user_id, session_id=str(session_id)
|
||||
)
|
||||
return u_im, u_sp, s_mm, s_em, u_cs, u_pav
|
||||
return u_im, u_sp, s_mm, s_em
|
||||
|
||||
|
||||
def _seed_new_session_dialog_from_user_defaults(
|
||||
|
|
@ -1255,21 +1239,16 @@ def include_chat_routes(router: APIRouter, *, resolve_auth: Callable[[SqliteStor
|
|||
s_mm, s_em = _resolve_session_dialog_chat_settings(
|
||||
store=store, tenant_id=tenant_id, user_id=user_id, session_id=str(session_id)
|
||||
)
|
||||
u_im, u_sp, u_cs, u_pav = _resolve_user_menu_chat_settings(store=store, tenant_id=tenant_id, user_id=user_id)
|
||||
u_im, u_sp = _resolve_user_menu_chat_settings(store=store, tenant_id=tenant_id, user_id=user_id)
|
||||
return {
|
||||
"ok": True,
|
||||
"interaction_mode": u_im,
|
||||
"specialist": u_sp,
|
||||
"memory_mode": s_mm,
|
||||
"execution_mode": s_em,
|
||||
"confirm_strategy": u_cs,
|
||||
"plan_agent_version": u_pav,
|
||||
"plan_agent_v2_globally_enabled": False,
|
||||
"global_menu": {
|
||||
"interaction_mode": u_im,
|
||||
"specialist": u_sp,
|
||||
"confirm_strategy": u_cs,
|
||||
"plan_agent_version": u_pav,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -1300,21 +1279,16 @@ def include_chat_routes(router: APIRouter, *, resolve_auth: Callable[[SqliteStor
|
|||
s_mm, s_em = _resolve_session_dialog_chat_settings(
|
||||
store=store, tenant_id=tenant_id, user_id=user_id, session_id=str(session_id)
|
||||
)
|
||||
u_im, u_sp, u_cs, u_pav = _resolve_user_menu_chat_settings(store=store, tenant_id=tenant_id, user_id=user_id)
|
||||
u_im, u_sp = _resolve_user_menu_chat_settings(store=store, tenant_id=tenant_id, user_id=user_id)
|
||||
return {
|
||||
"ok": True,
|
||||
"interaction_mode": u_im,
|
||||
"specialist": u_sp,
|
||||
"memory_mode": s_mm,
|
||||
"execution_mode": s_em,
|
||||
"confirm_strategy": u_cs,
|
||||
"plan_agent_version": u_pav,
|
||||
"plan_agent_v2_globally_enabled": False,
|
||||
"global_menu": {
|
||||
"interaction_mode": u_im,
|
||||
"specialist": u_sp,
|
||||
"confirm_strategy": u_cs,
|
||||
"plan_agent_version": u_pav,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -1326,14 +1300,11 @@ def include_chat_routes(router: APIRouter, *, resolve_auth: Callable[[SqliteStor
|
|||
ctx = resolve_auth(store, authorization)
|
||||
tenant_id = str(ctx.get("tenant_id") or "")
|
||||
user_id = str(ctx.get("user_id") or "")
|
||||
u_im, u_sp, u_cs, u_pav = _resolve_user_menu_chat_settings(store=store, tenant_id=tenant_id, user_id=user_id)
|
||||
u_im, u_sp = _resolve_user_menu_chat_settings(store=store, tenant_id=tenant_id, user_id=user_id)
|
||||
return {
|
||||
"ok": True,
|
||||
"interaction_mode": u_im,
|
||||
"specialist": u_sp,
|
||||
"confirm_strategy": u_cs,
|
||||
"plan_agent_version": u_pav,
|
||||
"plan_agent_v2_globally_enabled": False,
|
||||
}
|
||||
|
||||
@chat.post("/user-mode")
|
||||
|
|
@ -1349,27 +1320,18 @@ def include_chat_routes(router: APIRouter, *, resolve_auth: Callable[[SqliteStor
|
|||
interaction_mode = normalize_interaction_mode(payload.get("interaction_mode"))
|
||||
specialist = normalize_requested_specialist(payload.get("specialist"))
|
||||
specialist = _apply_specialist_flags(store, specialist)
|
||||
confirm_strategy = _normalize_confirm_strategy(payload)
|
||||
plan_agent_version = _normalize_plan_agent_version(payload)
|
||||
_persist_user_menu_chat_settings(
|
||||
store=store,
|
||||
tenant_id=tenant_id,
|
||||
user_id=user_id,
|
||||
interaction_mode=interaction_mode,
|
||||
specialist=specialist,
|
||||
confirm_strategy=confirm_strategy,
|
||||
plan_agent_version=plan_agent_version,
|
||||
)
|
||||
u_im, u_sp, u_cs, u_pav = _resolve_user_menu_chat_settings(store=store, tenant_id=tenant_id, user_id=user_id)
|
||||
# Plan mode removed; keep setting key cleared for leftover clients.
|
||||
store.set_setting("AIA_EXPERT_PLAN_AGENT_V2_ENABLED", "0")
|
||||
u_im, u_sp = _resolve_user_menu_chat_settings(store=store, tenant_id=tenant_id, user_id=user_id)
|
||||
return {
|
||||
"ok": True,
|
||||
"interaction_mode": u_im,
|
||||
"specialist": u_sp,
|
||||
"confirm_strategy": u_cs,
|
||||
"plan_agent_version": u_pav,
|
||||
"plan_agent_v2_globally_enabled": False,
|
||||
}
|
||||
|
||||
@chat.get("/admin/user-stats")
|
||||
|
|
@ -1945,42 +1907,33 @@ def include_chat_routes(router: APIRouter, *, resolve_auth: Callable[[SqliteStor
|
|||
memory_mode = _normalize_memory_mode(payload)
|
||||
execution_mode = _normalize_execution_mode(payload)
|
||||
if "interaction_mode" not in payload and "chat_mode" not in payload:
|
||||
interaction_mode, _, _, _, _, _ = _resolve_mode_settings(
|
||||
interaction_mode, _, _, _ = _resolve_mode_settings(
|
||||
store=store,
|
||||
tenant_id=tenant_id,
|
||||
user_id=user_id,
|
||||
session_id=str(session_id),
|
||||
)
|
||||
if "specialist" not in payload:
|
||||
_, selected_specialist, _, _, _, _ = _resolve_mode_settings(
|
||||
_, selected_specialist, _, _ = _resolve_mode_settings(
|
||||
store=store,
|
||||
tenant_id=tenant_id,
|
||||
user_id=user_id,
|
||||
session_id=str(session_id),
|
||||
)
|
||||
if "memory_mode" not in payload:
|
||||
_, _, memory_mode, _, _, _ = _resolve_mode_settings(
|
||||
_, _, memory_mode, _ = _resolve_mode_settings(
|
||||
store=store,
|
||||
tenant_id=tenant_id,
|
||||
user_id=user_id,
|
||||
session_id=str(session_id),
|
||||
)
|
||||
if "execution_mode" not in payload:
|
||||
_, _, _, execution_mode, _, _ = _resolve_mode_settings(
|
||||
_, _, _, execution_mode = _resolve_mode_settings(
|
||||
store=store,
|
||||
tenant_id=tenant_id,
|
||||
user_id=user_id,
|
||||
session_id=str(session_id),
|
||||
)
|
||||
if "plan_agent_version" not in payload:
|
||||
_, _, _, _, _, plan_agent_version = _resolve_mode_settings(
|
||||
store=store,
|
||||
tenant_id=tenant_id,
|
||||
user_id=user_id,
|
||||
session_id=str(session_id),
|
||||
)
|
||||
else:
|
||||
plan_agent_version = _normalize_plan_agent_version(payload)
|
||||
selected_specialist = _apply_specialist_flags(store, selected_specialist)
|
||||
if not text_raw and not attachments:
|
||||
raise HTTPException(status_code=400, detail="text_or_attachments_required")
|
||||
|
|
@ -2036,7 +1989,6 @@ def include_chat_routes(router: APIRouter, *, resolve_auth: Callable[[SqliteStor
|
|||
"selected_specialist": selected_specialist,
|
||||
"memory_mode": memory_mode,
|
||||
"execution_mode": execution_mode,
|
||||
"plan_agent_version": plan_agent_version,
|
||||
},
|
||||
)
|
||||
gw_result = gw.handle_turn(
|
||||
|
|
@ -2089,42 +2041,33 @@ def include_chat_routes(router: APIRouter, *, resolve_auth: Callable[[SqliteStor
|
|||
memory_mode = _normalize_memory_mode(payload)
|
||||
execution_mode = _normalize_execution_mode(payload)
|
||||
if "interaction_mode" not in payload and "chat_mode" not in payload:
|
||||
interaction_mode, _, _, _, _, _ = _resolve_mode_settings(
|
||||
interaction_mode, _, _, _ = _resolve_mode_settings(
|
||||
store=store,
|
||||
tenant_id=tenant_id,
|
||||
user_id=user_id,
|
||||
session_id=str(session_id),
|
||||
)
|
||||
if "specialist" not in payload:
|
||||
_, selected_specialist, _, _, _, _ = _resolve_mode_settings(
|
||||
_, selected_specialist, _, _ = _resolve_mode_settings(
|
||||
store=store,
|
||||
tenant_id=tenant_id,
|
||||
user_id=user_id,
|
||||
session_id=str(session_id),
|
||||
)
|
||||
if "memory_mode" not in payload:
|
||||
_, _, memory_mode, _, _, _ = _resolve_mode_settings(
|
||||
_, _, memory_mode, _ = _resolve_mode_settings(
|
||||
store=store,
|
||||
tenant_id=tenant_id,
|
||||
user_id=user_id,
|
||||
session_id=str(session_id),
|
||||
)
|
||||
if "execution_mode" not in payload:
|
||||
_, _, _, execution_mode, _, _ = _resolve_mode_settings(
|
||||
_, _, _, execution_mode = _resolve_mode_settings(
|
||||
store=store,
|
||||
tenant_id=tenant_id,
|
||||
user_id=user_id,
|
||||
session_id=str(session_id),
|
||||
)
|
||||
if "plan_agent_version" not in payload:
|
||||
_, _, _, _, _, plan_agent_version = _resolve_mode_settings(
|
||||
store=store,
|
||||
tenant_id=tenant_id,
|
||||
user_id=user_id,
|
||||
session_id=str(session_id),
|
||||
)
|
||||
else:
|
||||
plan_agent_version = _normalize_plan_agent_version(payload)
|
||||
selected_specialist = _apply_specialist_flags(store, selected_specialist)
|
||||
if not text_raw and not attachments:
|
||||
raise HTTPException(status_code=400, detail="text_or_attachments_required")
|
||||
|
|
@ -2169,7 +2112,6 @@ def include_chat_routes(router: APIRouter, *, resolve_auth: Callable[[SqliteStor
|
|||
"selected_specialist": selected_specialist,
|
||||
"memory_mode": memory_mode,
|
||||
"execution_mode": execution_mode,
|
||||
"plan_agent_version": plan_agent_version,
|
||||
}
|
||||
|
||||
_DONE = object()
|
||||
|
|
|
|||
|
|
@ -612,9 +612,7 @@ def build_admin_router() -> APIRouter:
|
|||
"removed_total": len(llm_plan.removed_names),
|
||||
"removed_mcp_total": len(llm_plan.removed_mcp_names),
|
||||
"changed_total": len(llm_plan.changed_names),
|
||||
"policy_perm_ban_9999": 0,
|
||||
"mcp_enabled": bool(llm_plan.mcp_enabled),
|
||||
"wire_policy_effective": False,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -625,7 +623,6 @@ def build_admin_router() -> APIRouter:
|
|||
"summary": {
|
||||
"total_internal_tools": total_internal,
|
||||
"total_wired_tools": total_wired,
|
||||
"total_perm_ban_9999": 0,
|
||||
},
|
||||
"items": items,
|
||||
}
|
||||
|
|
@ -665,8 +662,6 @@ def build_admin_router() -> APIRouter:
|
|||
"max_json_bytes": plan.max_json_bytes,
|
||||
"mcp_enabled": plan.mcp_enabled,
|
||||
"role_mode": plan.role_mode,
|
||||
"wire_policy_effective": plan.wire_policy_effective,
|
||||
"policy_keys": plan.policy_keys,
|
||||
"raw_count": len(plan.tools_raw),
|
||||
"wired_count": len(plan.tools_wired),
|
||||
"removed_mcp_names": plan.removed_mcp_names,
|
||||
|
|
|
|||
|
|
@ -347,7 +347,6 @@ def include_skill_routes(
|
|||
"enabled": bool(skill_role_binding_enabled(store=store)),
|
||||
"enabled_stored": bool(skill_role_binding_enabled_stored(store=store)),
|
||||
"enabled_env_present": bool(skill_role_binding_enabled_env_present()),
|
||||
"manager_inherit": False,
|
||||
"available_roles": roles,
|
||||
"installed_skills": items,
|
||||
"mapping": mapping,
|
||||
|
|
@ -385,7 +384,6 @@ def include_skill_routes(
|
|||
"enabled": bool(skill_role_binding_enabled(store=store)),
|
||||
"enabled_stored": bool(skill_role_binding_enabled_stored(store=store)),
|
||||
"enabled_env_present": bool(skill_role_binding_enabled_env_present()),
|
||||
"manager_inherit": False,
|
||||
"available_roles": roles,
|
||||
"mapping": mapping,
|
||||
}
|
||||
|
|
@ -409,7 +407,6 @@ def include_skill_routes(
|
|||
"total": 0,
|
||||
"workspace_total": 0,
|
||||
"workspace_direct": 0,
|
||||
"workspace_inherited_manager": 0,
|
||||
"mcp_total": 0,
|
||||
"tool_total": 0,
|
||||
"names_preview": [],
|
||||
|
|
@ -461,7 +458,6 @@ def include_skill_routes(
|
|||
"total": len(entries),
|
||||
"workspace_total": workspace_total,
|
||||
"workspace_direct": workspace_direct,
|
||||
"workspace_inherited_manager": 0,
|
||||
"workspace_resolved_tool_match": workspace_resolved_tool_match,
|
||||
"workspace_docs_only": workspace_docs_only,
|
||||
"mcp_total": mcp_total,
|
||||
|
|
|
|||
|
|
@ -8409,8 +8409,6 @@ async function renderSkills() {
|
|||
{
|
||||
removed_mcp_names: llmToolsState.removed_mcp_names,
|
||||
role_mode: resp.role_mode,
|
||||
wire_policy_effective: !!resp.wire_policy_effective,
|
||||
policy_keys: resp.policy_keys,
|
||||
skipped_public: resp.skipped_public || [],
|
||||
skipped_expert: resp.skipped_expert || [],
|
||||
},
|
||||
|
|
|
|||
|
|
@ -402,8 +402,6 @@ const CHAT_USER_MENU_MODE_KEY = "ops_chat_user_menu_mode";
|
|||
const CHAT_REASONING_TOGGLE_KEY = "ops_chat_reasoning_toggle";
|
||||
const EXECUTION_MODE_AGENT = "agent";
|
||||
const EXECUTION_MODE_PLAN = "plan";
|
||||
const CONFIRM_STRATEGY_STRICT = "strict";
|
||||
const PLAN_AGENT_V1 = "v1";
|
||||
/** Default on: reasoning/tool fold matches streamed behavior; new browsers have no localStorage yet. */
|
||||
const ADMIN_CHAT_SHOW_TOOL_OUTPUT_DEFAULT = true;
|
||||
const REASONING_BLOCK_MAX_CHARS = 12000;
|
||||
|
|
@ -3539,8 +3537,6 @@ async function renderChatUi() {
|
|||
const resp = await apiPost("/admin/api/chat/user-mode", {
|
||||
interaction_mode: "expert",
|
||||
specialist,
|
||||
confirm_strategy: CONFIRM_STRATEGY_STRICT,
|
||||
plan_agent_version: PLAN_AGENT_V1,
|
||||
});
|
||||
localStorage.setItem(CHAT_USER_MENU_MODE_KEY, specialist);
|
||||
globalMenuModeValue = specialist;
|
||||
|
|
@ -4422,7 +4418,6 @@ async function renderChatUi() {
|
|||
specialist: String(specialist || "generalist"),
|
||||
memory_mode: String(memoryMode || "default"),
|
||||
execution_mode: String(executionMode || "agent"),
|
||||
plan_agent_version: PLAN_AGENT_V1,
|
||||
lang: currentLang === "en" ? "en" : "zh",
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -67,9 +67,6 @@ def build_gateway_context(
|
|||
execution_mode = str(p.get("execution_mode") or "agent").strip().lower() or "agent"
|
||||
if execution_mode not in {"agent", "plan"}:
|
||||
execution_mode = "agent"
|
||||
plan_agent_version = str(p.get("plan_agent_version") or "v1").strip().lower() or "v1"
|
||||
if plan_agent_version != "v1":
|
||||
plan_agent_version = "v1"
|
||||
if interaction_mode != "expert":
|
||||
interaction_mode = "expert"
|
||||
raw_env = dict(p.get("relay_share_envelope") or {}) if isinstance(p.get("relay_share_envelope"), dict) else {}
|
||||
|
|
@ -82,7 +79,6 @@ def build_gateway_context(
|
|||
"interaction_mode": interaction_mode,
|
||||
"specialist": specialist,
|
||||
"execution_mode": execution_mode,
|
||||
"plan_agent_version": plan_agent_version,
|
||||
"relay_share_envelope": norm_env if ok_env else {},
|
||||
"acp_parent_run_id": str(p.get("acp_parent_run_id") or ""),
|
||||
"acp_child_run_id": str(p.get("acp_child_run_id") or ""),
|
||||
|
|
@ -106,9 +102,6 @@ def build_gateway_context(
|
|||
execution_mode = str(p.get("execution_mode") or "agent").strip().lower() or "agent"
|
||||
if execution_mode not in {"agent", "plan"}:
|
||||
execution_mode = "agent"
|
||||
plan_agent_version = str(p.get("plan_agent_version") or "v1").strip().lower() or "v1"
|
||||
if plan_agent_version != "v1":
|
||||
plan_agent_version = "v1"
|
||||
if interaction_mode != "expert":
|
||||
interaction_mode = "expert"
|
||||
raw_env = dict(p.get("relay_share_envelope") or {}) if isinstance(p.get("relay_share_envelope"), dict) else {}
|
||||
|
|
@ -121,7 +114,6 @@ def build_gateway_context(
|
|||
"interaction_mode": interaction_mode,
|
||||
"specialist": specialist,
|
||||
"execution_mode": execution_mode,
|
||||
"plan_agent_version": plan_agent_version,
|
||||
"relay_share_envelope": norm_env if ok_env else {},
|
||||
"acp_parent_run_id": str(p.get("acp_parent_run_id") or ""),
|
||||
"acp_child_run_id": str(p.get("acp_child_run_id") or ""),
|
||||
|
|
|
|||
|
|
@ -177,9 +177,6 @@ async def run_agent_turn_via_bridge(
|
|||
execution_mode = str(p.get("execution_mode") or "agent").strip().lower() or "agent"
|
||||
if execution_mode not in {"agent", "plan"}:
|
||||
execution_mode = "agent"
|
||||
plan_agent_version = str(p.get("plan_agent_version") or "v1").strip().lower() or "v1"
|
||||
if plan_agent_version != "v1":
|
||||
plan_agent_version = "v1"
|
||||
store = get_assistant_store()
|
||||
gw = OclawGateway(store=store)
|
||||
|
||||
|
|
@ -292,7 +289,6 @@ async def run_agent_turn_via_bridge(
|
|||
"interaction_mode": str(p.get("interaction_mode") or "expert"),
|
||||
"selected_specialist": str(p.get("specialist") or "generalist"),
|
||||
"execution_mode": execution_mode,
|
||||
"plan_agent_version": plan_agent_version,
|
||||
"relay_share_envelope": dict(p.get("relay_share_envelope") or {})
|
||||
if isinstance(p.get("relay_share_envelope"), dict)
|
||||
else {},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue