Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:1ay1 Agentty Entitlement Registry

From Leeroopedia
Knowledge Sources
Domains Auth, Entitlement
Last Updated 2026-10-28 12:00 GMT

Overview

Account-scoped entitlement fact registry keyed by (provider, account, model), replacing a single account-blind bool that lost facts on every account switch.

Description

The agentty::domain::entitlement module is the account-scoped entitlement fact registry. It separates three things that are easy to conflate: IDENTITY (what a model IS), CAPABILITY (what a model CAN do), and ENTITLEMENT (what THIS SUBSCRIPTION may do). Identity and capability are account-blind on purpose; entitlement is account-scoped.

This started as `Settings::context_1m_blocked`, one global bool. Account-scoped truth in an account-blind box meant the account-switch reducer manually cleared the flag on every switch — ping-pong between a Max account (1M works) and a Pro account (blocked) re-discovered the same 400 forever. Keyed storage fixes that AND deletes the special case: there is nothing to reset on a switch, because the other account's facts were never in the way.

Key shape: `"<provider>\x1f<account>\x1f<folded-model>"` (model-scoped) or `"<provider>\x1f<account>"` (account-wide). US (0x1f) as separator because account labels are user-typed and a typeable separator is a key-collision bug. Only NEGATIVE facts are recorded (absent = not known to be blocked).

Usage

Import this when you need to: check if an account is entitled to a feature, record a learned rejection (HTTP 400), or forget an account's facts on sign-out.

Code Reference

Source Location

Signature

namespace agentty::domain::entitlement {

inline constexpr char kSep = '\x1f';

enum class Fact : std::uint8_t {
    Context1M,       // Anthropic 1M-context beta rejected for this subscription
    VisionOrgPolicy, // Copilot org has vision disabled (account-wide)
};

[[nodiscard]] constexpr std::string_view tag(Fact f) noexcept;

[[nodiscard]] inline std::string key_for(Fact f, std::string_view provider,
    std::string_view account, std::string_view model_id = {});

using Store = std::map<std::string, bool>;  // key → blocked (negative facts only)

[[nodiscard]] inline bool blocked(const Store& s, Fact f,
    std::string_view provider, std::string_view account,
    std::string_view model_id = {});

inline bool record_blocked(Store& s, Fact f,
    std::string_view provider, std::string_view account,
    std::string_view model_id = {});

inline void forget_account(Store& s, std::string_view provider,
    std::string_view account);
}

Import

#include "agentty/domain/entitlement.hpp"

I/O Contract

Inputs

Name Type Required Description
Fact enum Yes Which entitlement fact (Context1M, VisionOrgPolicy)
provider std::string_view Yes Agentty provider id
account std::string_view Yes Active account label ("" = single account)
model_id std::string_view No Model id (empty = account-wide fact)

Outputs

Name Type Description
blocked() bool True if this (fact, provider, account, model) is known to be blocked
record_blocked() bool True if NEW information was recorded
forget_account() void Drops all facts for one (provider, account) — sign-out hook

Usage Examples

Record and Check a Rejection

#include "agentty/domain/entitlement.hpp"

agentty::domain::entitlement::Store store;

// After a 400 "long context beta not available":
bool new_fact = agentty::domain::entitlement::record_blocked(
    store, agentty::domain::entitlement::Fact::Context1M,
    "anthropic", "work", "claude-opus-4-5");
// new_fact = true (first time)

// Check before offering [1m] variants:
bool blocked = agentty::domain::entitlement::blocked(
    store, agentty::domain::entitlement::Fact::Context1M,
    "anthropic", "work", "claude-opus-4-5");
// blocked = true → don't show [1m] picker rows

Account Switch (No Reset Needed)

// Switching to "personal" — the "work" account's facts stay keyed,
// so switching back doesn't re-discover the same 400.
// Only sign-OUT forgets:
agentty::domain::entitlement::forget_account(store, "anthropic", "work");

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment