Require Scope • AI Agent SDK
require_scope: Enforce that at least one scope identifier is provided.
require_scope
Function
</div>
This function is defined in the protocols module.
Enforce that at least one scope identifier is provided.
Shared helper so every knowledge adapter enforces the same tenant-scope contract (mem0 already did via its own `_check_scope). Without this, an unscoped call that raises ScopeRequiredError` on the mem0 backend would silently return or wipe every tenant’s data on the Chroma/SQLite backends — a data-loss/leak hazard depending purely on which backend is installed.
Signature
def require_scope(user_id: Any, agent_id: Any, run_id: Any, operation: str, backend: str) -> NoneParameters
AnyNo description available.
AnyNo description available.
AnyNo description available.
strNo description available.
strNo description available.
Exceptions
ScopeRequiredError
If none of user_id/agent_id/run_id is provided.
Uses
ScopeRequiredError
Source
View on GitHubpraisonaiagents/knowledge/protocols.py at line 202