TencentCloud/TencentDB-Agent-Memory · error · ParamError

v3 MemoryClient requires non-empty {', '.join(missing)} at c

Error message

v3 MemoryClient requires non-empty {', '.join(missing)} at construction time

What it means

v3 MemoryClient requires team_id, agent_id, and user_id — the isolation triple — to be non-empty at construction time. Rather than failing later with a server 422, _validate_construction raises ParamError immediately listing every missing field.

Source

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

    if len(deduped) > max_items:
        raise ParamError(f"{field} accepts at most {max_items} items, got {len(deduped)}")
    return deduped


def _validate_construction(team_id: str, agent_id: str, user_id: str) -> None:
    """v3 构造时 team+agent+user 必填,任一缺失立刻 ParamError,避免 422 才暴露。

    session_id 不在构造时强校验(L2/L3 接口不需要);L0/L1 方法调用时再单独校验。
    """
    missing = [
        name for name, val in (
            ("team_id", team_id),
            ("agent_id", agent_id),
            ("user_id", user_id),
        ) if not val
    ]
    if missing:
        raise ParamError(
            f"v3 MemoryClient requires non-empty {', '.join(missing)} at construction time"
        )


class _IsolationCtx:
    """Carrier for the v3 isolation context. Internal only; exposed via with_isolation()."""

    __slots__ = ("team_id", "agent_id", "user_id", "session_id", "task_id")

    def __init__(
        self,
        team_id: str,
        agent_id: str,
        user_id: str,
        session_id: Optional[str] = None,
        task_id: Optional[str] = None,
    ) -> None:
        self.team_id = team_id

View on GitHub (pinned to 3efcd317b8)

Solutions

  1. Pass non-empty team_id, agent_id, and user_id to the constructor
  2. Verify the env/config values actually populate (e.g. os.environ['TEAM_ID'] not '')
  3. For isolated sub-clients use with_isolation() supplying all three values
  4. Print the config object before constructing to confirm no blank fields

Example fix

// before
client = MemoryClient(endpoint=ep, api_key=key, service_id=sid, team_id=os.getenv("TEAM_ID"))
# after
team_id = os.environ["TEAM_ID"]  # fail fast if unset
agent_id = os.environ["AGENT_ID"]
user_id = os.environ["USER_ID"]
client = MemoryClient(endpoint=ep, api_key=key, service_id=sid,
                      team_id=team_id, agent_id=agent_id, user_id=user_id)
Defensive patterns

Strategy: validation

Validate before calling

def build_client(cfg):
    missing = [k for k in ("team_id", "agent_id", "user_id") if not cfg.get(k)]
    if missing:
        raise ValueError(f"missing config: {missing}")
    return MemoryClient(..., **{k: cfg[k] for k in ("team_id", "agent_id", "user_id")})

Try / catch

try:
    client = MemoryClient(...)
except ParamError as e:
    raise ConfigError(f"client construction failed: {e}") from e

Prevention

When it happens

Trigger: Instantiating MemoryClient or AsyncMemoryClient with empty-string or None team_id/agent_id/user_id, or with_isolation() with any of the triple omitted/blank. Only fields that are falsy are reported; all missing ones are named in the message.

Common situations: Config read from env vars where a var is unset/empty; copy-pasting a client snippet from another project without the team/agent ids; upgrading from an API version where these were optional; template rendering leaving placeholders empty.

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/44b09e66a3e88767. Report an issue: GitHub.