TencentCloud/TencentDB-Agent-Memory · error · ParamError

service_id must be provided

Error message

service_id must be provided

What it means

MemoryClient.__init__ only builds an HttpStub when no stub is injected; in that path service_id is mandatory because it identifies the service consumed by the gateway. A missing/empty service_id raises ParamError before any connection is attempted.

Source

Thrown at sdk/memory-core/python/tencentdb_agent_memory/v3/client.py:189

        api_key: str = "",
        service_id: Optional[str] = None,
        *,
        team_id: str = "",
        agent_id: str = "",
        user_id: str = "",
        session_id: Optional[str] = None,
        task_id: Optional[str] = None,
        user_key: Optional[str] = None,
        timeout: float = 30,
        verify: bool = True,
        stub: Optional[Stub] = None,
    ) -> None:
        _validate_construction(team_id, agent_id, user_id)
        if stub is not None:
            self._stub = stub
        else:
            if not service_id:
                raise ParamError("service_id must be provided")
            # user_key 可选:内核不做用户级鉴权,但前置网关/面板可能需要
            # 调用方身份,这里保持与 MetadataClient 一致的透传能力。
            self._stub = HttpStub(
                endpoint, api_key, service_id,
                timeout=timeout, verify=verify, user_key=user_key,
            )
        self._iso = _IsolationCtx(team_id, agent_id, user_id, session_id, task_id)

    # -- isolation overrides ------------------------------------------------

    def with_isolation(
        self,
        *,
        team_id: Optional[str] = None,
        agent_id: Optional[str] = None,
        user_id: Optional[str] = None,
        session_id: Any = _UNSET,
        task_id: Any = _UNSET,

View on GitHub (pinned to 3efcd317b8)

Solutions

  1. Pass a non-empty service_id to the constructor
  2. Load it from config/env with a startup check (fail fast if blank)
  3. For unit tests, inject a stub=... explicitly so service_id is not required
  4. Verify you are not confusing service_id with team_id/agent_id

Example fix

// before
client = MemoryClient(endpoint=ep, api_key=key, service_id=os.getenv("SVC", ""), ...)
// after
service_id = os.environ["SERVICE_ID"]
client = MemoryClient(endpoint=ep, api_key=key, service_id=service_id, ...)
Defensive patterns

Strategy: validation

Validate before calling

if not service_id:
    raise ValueError("service_id must be set before building MemoryClient")

Try / catch

try:
    client = MemoryClient(...)
except ParamError as e:
    if "service_id" in str(e):
        service_id = prompt_or_env("SERVICE_ID")
        client = MemoryClient(..., service_id=service_id)

Prevention

When it happens

Trigger: Constructing MemoryClient without service_id (or with empty string) while leaving stub=None (the default); building a client from partial config where service_id was dropped.

Common situations: Env var for service_id unset; confusing service_id with api_key or team_id; code copied from tests that inject a stub, run in production without one.

Understand the failure class

Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.

Related errors


AI-assisted analysis of TencentCloud/TencentDB-Agent-Memory@3efcd317b8 (2026-09-01). Data as JSON: /api/errors/7d28dedd3cfdd289. Report an issue: GitHub.