TencentCloud/TencentDB-Agent-Memory · error · ParamError
service_id must be provided
Error message
service_id must be provided
What it means
MemoryPrompt's sync client __init__ raises ParamError when neither a stub nor a service_id is supplied. The HTTP stub needs the service_id to route requests to the correct TencentDB memory service, so without it the client cannot be constructed. This is a fail-fast constructor guard, not a runtime/network failure.
Source
Thrown at sdk/memory-core/python/tencentdb_agent_memory/v3/memory_prompt.py:47
def _target(team_id: Optional[str], agent_ids: Optional[List[str]]) -> None:
if agent_ids is not None:
_ids(agent_ids, "agent_ids")
if not team_id:
raise ParamError("team_id is required with agent_ids")
class MemoryPromptClient:
"""Synchronous Prompt CRUD, target binding, resolution and setting-log client."""
def __init__(self, endpoint: str = "", api_key: str = "", service_id: Optional[str] = None,
*, team_id: Optional[str] = None, agent_id: Optional[str] = None,
timeout: float = 30, verify: bool = True, stub: Optional[Stub] = None) -> None:
if stub is not None:
self._stub = stub
else:
if not service_id:
raise ParamError("service_id must be provided")
self._stub = HttpStub(endpoint, api_key, service_id, timeout=timeout, verify=verify)
self._team_id = team_id
self._agent_id = agent_id
def _get(self, path: str, query: Dict[str, Any]) -> Dict[str, Any]:
method = getattr(self._stub, "get", None)
return method(path, query) if method else self._stub.post(path, query)
def create(self, *, name: str, layer: str, prompt: str) -> Dict[str, Any]:
return self._stub.post(f"{_ROOT}/create", {
"name": _required("name", name), "layer": layer, "prompt": _required("prompt", prompt),
})
def get(self, memory_prompt_id: str) -> Dict[str, Any]:
return self._get(f"{_ROOT}/get", {"memory_prompt_id": _required("memory_prompt_id", memory_prompt_id)})
def list(self, *, layer: Optional[str] = None, limit: Optional[int] = None,
offset: Optional[int] = None, time_order: Optional[str] = None) -> Dict[str, Any]:View on GitHub (pinned to 3efcd317b8)
Solutions
- Pass the service_id string to the MemoryPrompt constructor.
- Load it from an environment variable and assert it is non-empty before constructing the client.
- If testing or using custom transport, inject a stub object instead of endpoint/api_key/service_id.
Example fix
# before client = MemoryPrompt(endpoint=ENDPOINT, api_key=API_KEY, team_id="t1") # after client = MemoryPrompt(endpoint=ENDPOINT, api_key=API_KEY, service_id="my-service-id", team_id="t1")
Defensive patterns
Strategy: validation
Validate before calling
service_id = os.getenv("TDB_MEMORY_SERVICE_ID", "").strip()
if not service_id:
raise ValueError("TDB_MEMORY_SERVICE_ID is required to build MemoryPrompt")
client = MemoryPrompt(endpoint=ENDPOINT, api_key=API_KEY, service_id=service_id) Type guard
def has_service_id(cfg: dict) -> bool:
return isinstance(cfg.get("service_id"), str) and bool(cfg["service_id"].strip()) Try / catch
try:
client = MemoryPrompt(endpoint=E, api_key=K, service_id=S)
except ParamError as e:
logging.error("Client init failed: %s", e)
raise SystemExit(2) Prevention
- Centralize client construction in one factory that validates all required config.
- Fail fast on empty env vars at startup rather than at first API call.
- Prefer explicit constructor arguments over partially-populated config dicts.
When it happens
Trigger: Instantiating the sync MemoryPrompt class without passing service_id while also omitting the stub argument (e.g. MemoryPrompt(endpoint=..., api_key=...) or service_id=None/"").
Common situations: Developers assume api_key and endpoint are enough (like other SDKs), copy setup code that pulls service_id from an env var that is unset, or migrate from a stub-based setup to direct HTTP and forget the new required parameter.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- {name} must be a non-empty string
- {name} must be a non-empty string
- {name} must be a non-empty list of non-empty strings
- team_id is required with agent_ids
- team_id is required for effective prompt lookup
AI-assisted analysis of TencentCloud/TencentDB-Agent-Memory@3efcd317b8 (2026-09-01).
Data as JSON: /api/errors/a317026d9870ac38.
Report an issue: GitHub.