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 Capability Key Normalization

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

Overview

Canonical capability-key normalization that folds model id spelling variants to one key and resolves provider identity via evidence, eliminating the multi-spelling two-ladders bug.

Description

The agentty::capkey module is the canonical capability-key discipline. Every capability registry (declared reasoning, declared/learned effort sets) is a map keyed by strings. Three independent naming authorities produce those strings (agentty's provider registry, the provider's wire model ids, models.dev's community data) and none of them agree.

Three rules make this structural:

  • RULE 1 — one spelling: `norm_model()` lowercases, folds `.`, `_`, ` `, `:` to `-`, collapses runs, and strips `[1m]`/`[2m]` markers. "Kimi-K2.5", "kimi-k2-5" and "kimi k2.5" are the same key.
  • RULE 2 — one provider namespace: scoped keys always use agentty's provider id, never a third party's. `resolve_dev_provider()` anchors on identity evidence (exact id match, primary env var, API host substring).
  • RULE 3 — bare keys are consensus-only: a key without a provider scope may only be written through the merge-or-poison path.

`norm_row_id()` is the same as `norm_model()` but KEEPS the `[1m]`/`[2m]` marker — for row identity (picker dedup, selection) where the context variant is a distinct row, not a capability alias.

Usage

Import this when you need to: normalize a model id for a capability registry key, resolve a models.dev provider onto agentty's id, build scoped or bare keys, or dedup picker rows by identity.

Code Reference

Source Location

Signature

namespace agentty::capkey {

// RULE 1: canonical model spelling. Folds separators, strips [1m]/[2m].
[[nodiscard]] inline std::string norm_model(std::string_view id);

// Row identity: like norm_model but KEEPS [1m]/[2m] markers.
[[nodiscard]] inline std::string norm_row_id(std::string_view id);

// Bare tail of a possibly vendor-prefixed id, normalized.
[[nodiscard]] inline std::string norm_tail(std::string_view id);

// RULE 2: resolve models.dev provider onto agentty's id via identity evidence.
[[nodiscard]] inline std::string resolve_dev_provider(
    std::string_view dev_id, std::string_view dev_env0, std::string_view dev_api);

// Scope prefix for models.dev records (agentty id or inert "dev:<id>").
[[nodiscard]] inline std::string dev_scope(
    std::string_view dev_id, std::string_view dev_env0, std::string_view dev_api);

// Key assembly
[[nodiscard]] inline std::string scoped(std::string_view provider, std::string_view model);
[[nodiscard]] inline std::string bare(std::string_view model);
}

Import

#include "agentty/domain/capkey.hpp"

I/O Contract

Inputs

Name Type Required Description
id std::string_view Yes Model id (wire, picker, or models.dev)
dev_id / dev_env0 / dev_api std::string_view Yes (resolve) models.dev provider identity signals
provider / model std::string_view Yes (scoped) Provider id and model id for key assembly

Outputs

Name Type Description
norm_model() std::string Folded model key (separators collapsed, [1m] stripped)
norm_row_id() std::string Folded row key (separators collapsed, [1m] preserved)
resolve_dev_provider() std::string Agentty provider id, or "" (foreign)

Usage Examples

Normalize Model Ids

#include "agentty/domain/capkey.hpp"

// All three resolve to the same key:
agentty::capkey::norm_model("Kimi-K2.5");    // "kimi-k2-5"
agentty::capkey::norm_model("kimi_k2.5");    // "kimi-k2-5"
agentty::capkey::norm_model("kimi k2 5");    // "kimi-k2-5"

// [1m] marker stripped for capability lookups:
agentty::capkey::norm_model("claude-opus-4-8[1m]");  // "claude-opus-4-8"

// But preserved for row identity:
agentty::capkey::norm_row_id("claude-opus-4-8[1m]"); // "claude-opus-4-8[1m]"

Build Scoped Keys

// Scoped key: "anthropic/claude-opus-4-8"
auto key = agentty::capkey::scoped("anthropic", "claude-opus-4-8");

// Bare key (consensus-only writes):
auto bare = agentty::capkey::bare("mistralai/Mistral-Medium-3.5");
// → "mistral-medium-3-5"

Resolve models.dev Provider

// Identity evidence — env var is the strongest signal:
auto p = agentty::capkey::resolve_dev_provider("google", "GEMINI_API_KEY", "");
// → "gemini" (env var match)

auto p2 = agentty::capkey::resolve_dev_provider("unknown-aggregator", "", "");
// → "" → caller namespaces as "dev:unknown-aggregator" (inert)

Related Pages

Page Connections

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