{"record":{"id":"8fe3fc3cf4888e9d","repo":"TencentCloud/TencentDB-Agent-Memory","slug":"team-id-is-required-for-effective-prompt-lookup","errorCode":null,"errorMessage":"team_id is required for effective prompt lookup","messagePattern":"team_id is required for effective prompt lookup","errorType":"validation","errorClass":"ParamError","httpStatus":null,"severity":"error","filePath":"sdk/memory-core/python/tencentdb_agent_memory/v3/memory_prompt.py","lineNumber":74,"sourceCode":"    def create(self, *, name: str, layer: str, prompt: str) -> Dict[str, Any]:\n        return self._stub.post(f\"{_ROOT}/create\", {\n            \"name\": _required(\"name\", name), \"layer\": layer, \"prompt\": _required(\"prompt\", prompt),\n        })\n\n    def get(self, memory_prompt_id: str) -> Dict[str, Any]:\n        return self._get(f\"{_ROOT}/get\", {\"memory_prompt_id\": _required(\"memory_prompt_id\", memory_prompt_id)})\n\n    def list(self, *, layer: Optional[str] = None, limit: Optional[int] = None,\n             offset: Optional[int] = None, time_order: Optional[str] = None) -> Dict[str, Any]:\n        return self._get(f\"{_ROOT}/get\", _strip_none({\n            \"layer\": layer, \"limit\": limit, \"offset\": offset, \"time_order\": time_order,\n        }))\n\n    def get_effective(self, *, layer: str, team_id: Optional[str] = None,\n                      agent_id: Optional[str] = None) -> Dict[str, Any]:\n        team, agent = team_id or self._team_id, agent_id or self._agent_id\n        if not team:\n            raise ParamError(\"team_id is required for effective prompt lookup\")\n        return self._get(f\"{_ROOT}/get\", _strip_none({\"team_id\": team, \"agent_id\": agent, \"layer\": layer}))\n\n    def update(self, memory_prompt_id: str, *, name: Optional[str] = None,\n               prompt: Optional[str] = None) -> Dict[str, Any]:\n        if name is None and prompt is None:\n            raise ParamError(\"name or prompt is required\")\n        return self._stub.post(f\"{_ROOT}/update\", _strip_none({\n            \"memory_prompt_id\": _required(\"memory_prompt_id\", memory_prompt_id), \"name\": name, \"prompt\": prompt,\n        }))\n\n    def delete(self, memory_prompt_ids: Iterable[str]) -> Dict[str, Any]:\n        return self._stub.post(f\"{_ROOT}/delete\", {\"memory_prompt_ids\": _ids(memory_prompt_ids, \"memory_prompt_ids\")})\n\n    def apply(self, memory_prompt_id: str, *, layer: str, team_id: Optional[str] = None,\n              agent_ids: Optional[List[str]] = None) -> Dict[str, Any]:\n        team = team_id or self._team_id\n        _target(team, agent_ids)\n        return self._stub.post(f\"{_ROOT}/set\", _strip_none({","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/3efcd317b84146d6a08518ac0f7ee7c8a8d200ec/sdk/memory-core/python/tencentdb_agent_memory/v3/memory_prompt.py#L56-L92","documentation":"get_effective resolves the effective prompt for a team/agent/layer combination; the API requires at least a team_id. If neither the explicit team_id argument nor the instance-level self._team_id (set at construction) yields a value, the client raises ParamError because the server cannot scope the lookup without it.","triggerScenarios":"Calling get_effective(layer=...) with no team_id argument on a client constructed without team_id, even if agent_id is provided.","commonSituations":"Scripts that construct MemoryPrompt without the optional team_id and later call get_effective; teams/instances renamed so the stored default team_id was dropped; snippets copied from examples that always pass team_id.","solutions":["Pass team_id explicitly: get_effective(layer=\"system\", team_id=\"my-team\").","Construct MemoryPrompt with a default team_id so it is inherited by every call.","If scoping per agent, still supply the owning team_id alongside agent_id."],"exampleFix":"# before\nclient = MemoryPrompt(endpoint=E, api_key=K, service_id=S)\nclient.get_effective(layer=\"system\")  # raises\n\n# after\nclient = MemoryPrompt(endpoint=E, api_key=K, service_id=S, team_id=\"my-team\")\nclient.get_effective(layer=\"system\")","handlingStrategy":"validation","validationCode":"team = team_id or client._team_id\nif not team:\n    raise ValueError(\"team_id is required for get_effective\")\nresult = client.get_effective(layer=layer, team_id=team, agent_id=agent_id)","typeGuard":"def is_nonempty_str(v: object) -> bool:\n    return isinstance(v, str) and bool(v.strip())","tryCatchPattern":"try:\n    prompt = client.get_effective(layer=\"system\", team_id=team_id)\nexcept ParamError as e:\n    logging.warning(\"Effective prompt lookup rejected: %s\", e)\n    prompt = None  # fall back to a default prompt","preventionTips":["Always set team_id when constructing the MemoryPrompt client.","Never rely on agent_id alone to scope lookups.","Document team_id as a mandatory parameter in internal wrappers around get_effective."],"tags":["python","parameter-validation","required-parameter","team-id"],"backgroundTag":"missing-required-argument","analyzedSha":"3efcd317b84146d6a08518ac0f7ee7c8a8d200ec","analyzedAt":"2026-09-01T05:44:22.276Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}