JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
fix(memory): OFFICE_ACE_DEPLOYMENT 改从 effective_tip 读取
zhouguohao6627117a2dfe
diff --git a/jiuwenswarm/agents/harness/common/memory/external_memory_builder.py b/jiuwenswarm/agents/harness/common/memory/external_memory_builder.pyindex 3c726277c9..497e8e60ed 100644--- a/jiuwenswarm/agents/harness/common/memory/external_memory_builder.py+++ b/jiuwenswarm/agents/harness/common/memory/external_memory_builder.py@@ -17,6 +17,7 @@ import osfrom typing import Any, Dict, Optionalfrom .external_memory_config import (+ is_cloud_deployment,build_openjiuwen_provider_config,get_external_memory_config,)@@ -216,16 +217,6 @@ def _build_lakebase_provider(ext_cfg: Dict[str, Any]):return provider-def _is_cloud_deployment() -> bool:- """True if running in cloud deployment form.-- 云端(``OFFICE_ACE_DEPLOYMENT=cloud``)与 PC 端(``pc`` 或缺省)的区分:- * 云端:记忆搜索走 AgentArts SDK,sync_turn 不上报(由 relay-claw 直报)。- * PC 端:记忆搜索走 chat-service appapi,sync_turn 走 pc-threads 上报。- """- return os.environ.get("OFFICE_ACE_DEPLOYMENT", "pc").strip().lower() == "cloud"--def _build_officeace_cloud_provider(ext_cfg: Dict[str, Any],):@@ -257,7 +248,7 @@ def _build_officeace_cloud_provider(space_id = oa_cfg.get("space_id") or os.environ.get("AGENTARTS_MEMORY_SPACE_ID", "")actor_id = ext_cfg.get("user_id") or ""- if _is_cloud_deployment():+ if is_cloud_deployment():from openjiuwen.core.memory.external.office_ace_memory_cloud_provider import (OfficeAceMemoryCloudProvider,)diff --git a/jiuwenswarm/agents/harness/common/memory/external_memory_config.py b/jiuwenswarm/agents/harness/common/memory/external_memory_config.pyindex 1c9a0eb8aa..285dd84084 100644--- a/jiuwenswarm/agents/harness/common/memory/external_memory_config.py+++ b/jiuwenswarm/agents/harness/common/memory/external_memory_config.py@@ -94,12 +94,24 @@ def is_external_memory_enabled(config: Optional[Dict[str, Any]] = None) -> bool:return bool(get_external_memory_config(config).get("provider"))-def _is_cloud_deployment() -> bool:+def is_cloud_deployment() -> bool:"""True iff ``OFFICE_ACE_DEPLOYMENT=cloud``(OfficeAce 云服务)。未设置或其他值视为 PC 端(向后兼容)。++ ``OFFICE_ACE_DEPLOYMENT`` 属于 BUSINESS_MIRROR_KEYS,bare 值在+ ``ingest_bare_business_into_tip`` 后被从 ``os.environ`` 搬到 per-agent+ tip 并 pop。因此优先从 ``effective_tip`` 读,``os.environ`` 仅作兜底+ (bare 尚未被 ingest 的早期阶段)。"""- return os.environ.get("OFFICE_ACE_DEPLOYMENT", "pc").strip().lower() == "cloud"+ try:+ from jiuwenswarm.common.local_env_config import effective_tip++ tip_val = str(effective_tip().get("OFFICE_ACE_DEPLOYMENT") or "")+ except Exception:+ tip_val = ""+ val = tip_val or os.environ.get("OFFICE_ACE_DEPLOYMENT", "pc")+ return val.strip().lower() == "cloud"def get_office_ace_user_profile_config(@@ -137,7 +149,7 @@ def get_office_ace_user_profile_config(user_id = str(ext.get("user_id") or "").strip() or _DEFAULT_USER# 云端:凭证回落到 AgentArts Memory(与对话上报同源)- if _is_cloud_deployment():+ if is_cloud_deployment():if not endpoint:endpoint = os.environ.get("AGENTARTS_MEMORY_BASE_URL", "").strip()if not api_key:@@ -146,7 +158,7 @@ def get_office_ace_user_profile_config(# space_id:cloud 端 internal 接口 path 需要(/v1/core/internal/spaces/{space_id}/...),# pc 端 appapi 接口不需要。优先取 office_ace_user_profile 段,cloud 回落 AGENTARTS_MEMORY_SPACE_ID。space_id = str(up.get("space_id") or "").strip()- if _is_cloud_deployment() and not space_id:+ if is_cloud_deployment() and not space_id:space_id = os.environ.get("AGENTARTS_MEMORY_SPACE_ID", "").strip()# 启用条件:external memory 开启 + provider=officeace_cloud + 凭证齐全。diff --git a/jiuwenswarm/agents/harness/common/rails/office_ace_user_profile/fetcher.py b/jiuwenswarm/agents/harness/common/rails/office_ace_user_profile/fetcher.pyindex 7a9c02a85e..255eb59e89 100644--- a/jiuwenswarm/agents/harness/common/rails/office_ace_user_profile/fetcher.py+++ b/jiuwenswarm/agents/harness/common/rails/office_ace_user_profile/fetcher.py@@ -28,6 +28,8 @@ from typing import Optionalimport httpx+from jiuwenswarm.agents.harness.common.memory.external_memory_config import is_cloud_deployment+logger = logging.getLogger(__name__)# 设计文档约束:画像大小硬上限 256KB@@ -123,7 +125,7 @@ class UserProfileFetcher:"Accept": "application/json",}# pc 端 appapi 用 X-Chat-User-Id 头传递用户身份;cloud 端 internal 用 path actor_id。- if not self._is_cloud():+ if not is_cloud_deployment():headers["X-Chat-User-Id"] = self.config.user_idheaders["Authorization"] = f"OfficeAceToken {self.config.api_key}"@@ -204,7 +206,7 @@ class UserProfileFetcher:def _is_configured(self) -> bool:# cloud 端 internal 接口还需 space_id(path 参数)- if self._is_cloud():+ if is_cloud_deployment():return bool(self.config.endpointand self.config.api_key@@ -217,14 +219,9 @@ class UserProfileFetcher:and self.config.user_id,)- @staticmethod- def _is_cloud() -> bool:- """True iff OFFICE_ACE_DEPLOYMENT=cloud。"""- return os.environ.get("OFFICE_ACE_DEPLOYMENT", "pc").strip().lower() == "cloud"-def _build_url(self) -> str:base = self.config.endpoint.rstrip("/")- if self._is_cloud():+ if is_cloud_deployment():# api-memory-access-internal.yaml:# GET /v1/core/internal/spaces/{space_id}/memory-user-profile/{actor_id}actor_id = self.config.user_id