{"record":{"id":"9a82807705ad16ce","repo":"TencentCloud/TencentDB-Agent-Memory","slug":"team-id-is-required-with-agent-ids","errorCode":null,"errorMessage":"team_id is required with agent_ids","messagePattern":"team_id is required with agent_ids","errorType":"validation","errorClass":"ParamError","httpStatus":null,"severity":"error","filePath":"sdk/memory-core/python/tencentdb_agent_memory/v3/memory_prompt.py","lineNumber":34,"sourceCode":"\ndef _required(name: str, value: str) -> str:\n    if not isinstance(value, str) or not value.strip():\n        raise ParamError(f\"{name} must be a non-empty string\")\n    return value\n\n\ndef _ids(values: Iterable[str], name: str) -> List[str]:\n    result = list(dict.fromkeys(values))\n    if not result or any(not isinstance(item, str) or not item.strip() for item in result):\n        raise ParamError(f\"{name} must be a non-empty list of non-empty strings\")\n    return result\n\n\ndef _target(team_id: Optional[str], agent_ids: Optional[List[str]]) -> None:\n    if agent_ids is not None:\n        _ids(agent_ids, \"agent_ids\")\n        if not team_id:\n            raise ParamError(\"team_id is required with agent_ids\")\n\n\nclass MemoryPromptClient:\n    \"\"\"Synchronous Prompt CRUD, target binding, resolution and setting-log client.\"\"\"\n\n    def __init__(self, endpoint: str = \"\", api_key: str = \"\", service_id: Optional[str] = None,\n                 *, team_id: Optional[str] = None, agent_id: Optional[str] = None,\n                 timeout: float = 30, verify: bool = True, stub: Optional[Stub] = None) -> None:\n        if stub is not None:\n            self._stub = stub\n        else:\n            if not service_id:\n                raise ParamError(\"service_id must be provided\")\n            self._stub = HttpStub(endpoint, api_key, service_id, timeout=timeout, verify=verify)\n        self._team_id = team_id\n        self._agent_id = agent_id\n\n    def _get(self, path: str, query: Dict[str, Any]) -> Dict[str, Any]:","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/3efcd317b84146d6a08518ac0f7ee7c8a8d200ec/sdk/memory-core/python/tencentdb_agent_memory/v3/memory_prompt.py#L16-L52","documentation":"_target in memory_prompt.py enforces that agent-scoped prompt operations (apply, clear) supply a team_id whenever agent_ids is given: agent-level targeting requires the team context, so a falsy team_id raises this ParamError.","triggerScenarios":"apply(team_id=None, agent_ids=['a1']) or clear(agent_ids=[...]) without team_id — i.e. agent_ids provided while team_id is None or empty string.","commonSituations":"Multi-tenant setups where the team id was not propagated to the prompt client call; callers assuming service-level default team; refactor dropping a team_id argument from the call signature.","solutions":["Pass team_id together with agent_ids in apply/clear calls","Use team-only targeting (team_id without agent_ids) if you intend the whole team","Load the team id from your tenant context/config before calling"],"exampleFix":"// before\nclient.apply(agent_ids=['agent-1'])\n// after\nclient.apply(team_id='team-42', agent_ids=['agent-1'])","handlingStrategy":"validation","validationCode":"if agent_ids is not None and not team_id:\n    raise ValueError('team_id is required when targeting agent_ids')","typeGuard":"def valid_agent_target(team_id, agent_ids) -> bool:\n    return agent_ids is None or bool(team_id and str(team_id).strip())","tryCatchPattern":"try:\n    client.apply(team_id=team_id, agent_ids=agent_ids)\nexcept ParamError as e:\n    logger.error('prompt target misconfigured: %s', e)","preventionTips":["Always carry team_id through your tenant context alongside agent ids","Decide team-wide vs agent-scoped targeting before calling apply/clear","Validate the team_id/agent_ids pairing in your API wrapper layer"],"tags":["python","parameter-validation","multi-tenancy"],"backgroundTag":"missing-required-argument","analyzedSha":"3efcd317b84146d6a08518ac0f7ee7c8a8d200ec","analyzedAt":"2026-09-01T05:44:22.276Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}