In Python (3 and 2), Node.js (JavaScript), Bun and Lua, a global discord object holds the context of the tag run. In Python it is a dict (discord["user"]["id"]), in Node.js and Bun an object (discord.user.id) and in Lua a table (discord.user.id). Deno, TypeScript and the other languages do not get it.
Most fields are read-only snapshots: changing them does nothing. Only variables, storage and blobs are written back when the program exits normally. In Node.js that happens on the beforeExit event, so calling process.exit() or crashing skips saving; in Python it happens at exit, so os._exit() skips it. Changing the working folder can also stop the save from being found.
storage and blobs are only loaded when the code contains the word storage or blob (in any case, even in a comment). Otherwise they arrive empty and nothing written to them is saved, the same as code run outside a saved tag.
variables contains the tag's variables at the moment the code started (including private ones like __args and __files). After the run, every key that does not start with __ is set as a TagScript variable, converted to text and cut to 1 MB, following the usual variable rules (names up to 64 characters, up to 100 variables). Removing a key in code does not delete the TagScript variable; use {delete} for that.
storage holds the tag's persistent storage for the current user, channel, server and global scopes, the same data {getuser}, {getchannel}, {getserver} and {getglobal} read. Each scope is written back as a whole: keys you delete are removed, and setting a scope to {} (or None/null in Python and Node.js) clears it. Values are saved as text: a number 5 becomes "5", and a dict, list or object is saved as its JSON text (parse it again when you read it back).
Storage written from code has extra rules: each scope can hold at most 5 keys, keys can be up to 128 characters and values up to 16,384 characters. Breaking one stops the tag with an error. {setuser} and friends enforce the same 5-key limit, so storage written outside code can never block a code run. Empty values do not count toward the limit.
blobs hold one larger value per scope (user, channel, server, global), up to 256 KB each, and can only be used from code. A blob arrives as bytes in Python, a Buffer in Node.js and a string in Lua, or as None/null when empty. You can assign bytes, a string, or any other value (which is saved as JSON text); set it to None/null to clear it. In Lua, setting a blob or storage scope to nil keeps the old value, so assign an empty string or table instead.
Storage and blobs only exist when running a saved tag. Aliases share their main tag's data. When code runs outside a saved tag, both start empty and changes are thrown away.