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 Model Name Decoder

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

Overview

Single decoder that turns a model id into a structured display value with projection ladders, eliminating the six independent parsers that previously disagreed on what to call a model on screen.

Description

The ModelName decoder (in `agentty::model_name`) is the single source of truth for how a model id is presented to a human. It replaces six independent parsers (UI label functions, badge resolvers, version extractors, family classifiers) that drifted into disagreement — the composer chip, turn header, and picker each showed a different string for the same model.

The design is one decoder → structured value → presentation-only projections. `decode(id, server_name)` produces a `ModelName{ family, version, qualifier, annotation, color }`, and three projections (`full()`, `medium()`, `tiny()`) differ only in how much they drop. The decoder delegates family taxonomy to `ModelCapabilities::from_id` and adds only display concerns, so adding a family touches one function and one colour table — never a widget.

Usage

Import this when you need to render a model's human-readable name in any UI surface (picker rows, turn headers, composer chips, status bars). Use the projection matching your surface's width budget; the consteval proofs guarantee `tiny() ⊑ medium() ⊑ full()` so a narrow surface can never state something a wide one contradicts.

Code Reference

Source Location

Signature

namespace agentty::model_name {

// The decoded, presentation-ready value.
struct ModelName {
    std::string  name;        // family or id-derived name; NEVER empty
    std::string  version;     // normalized dotted version; "" = none
    std::string  qualifier;    // product qualifier (Codex Max, Chat)
    std::string  annotation;   // context/variant (1M, 2M)
    std::string  ns;           // routing namespace prefix
    maya::Color  color;        // family hue (theme SLOT)
    bool         family_known;

    std::string full()      const;  // "Opus 4.8 · 1M"
    std::string qualified() const;  // full() + namespace prefix
    std::string medium()    const;  // "Opus 4.8"
    std::string tiny()      const;  // "Opus"
};

// Total: never throws, never returns empty name for non-empty id.
[[nodiscard]] ModelName decode(std::string_view id,
                               std::string_view server_name = {});

// Family colour table (exhaustive switch, no default).
[[nodiscard]] constexpr maya::Color color_of(
    ModelCapabilities::Family f) noexcept;

// Canonical display spelling of a known family.
[[nodiscard]] constexpr std::string_view family_label(
    ModelCapabilities::Family f) noexcept;
}

Import

#include "agentty/domain/model_name.hpp"

I/O Contract

Inputs

Name Type Required Description
id std::string_view Yes The wire/selection model id, possibly carrying an agentty `[1m]`/`[2m]` marker, a provider namespace, or an Ollama `:tag`
server_name std::string_view No The provider's own display_name for this model; used ONLY to recover marketing aliases the id cannot reconstruct

Outputs

Name Type Description
ModelName struct Presentation-ready decoded value with name, version, qualifier, annotation, namespace, color, and family_known flag
full() std::string Complete display: "Opus 4.8 · 1M" — picker rows, command palette
medium() std::string Drops annotation: "Opus 4.8" — turn headers, composer chip
tiny() std::string Drops qualifier too: "Opus" — narrowest shed rung

Usage Examples

Basic Decode

#include "agentty/domain/model_name.hpp"

// Decode a known family id
auto name = agentty::model_name::decode("claude-opus-4-8");
// name.name == "Opus", version == "4.8", family_known == true

// Picker row — show everything
picker_row.set_text(name.full());        // "Opus 4.8 · 1M"

// Turn header — medium width
header.set_text(name.medium());         // "Opus 4.8"

// Status bar — narrowest
status.set_text(name.tiny());           // "Opus"

Unknown Family Degradation

// An id for a model the enum doesn't know yet
auto name = agentty::model_name::decode("claude-quasar-6");
// family_known == false, but name.name == "Quasar", version == "6"
// Renders identically to a known family — no raw wire id leaks
assert(!name.name.empty());  // TOTAL: every id yields a non-empty name

Security Boundary

// The id is NOT trusted — comes from provider APIs and user config.
// Control bytes and unbounded length are stripped at exactly one choke point.
auto name = agentty::model_name::decode("\x1b[31m");
// name.name is non-empty and contains NO control bytes
// A 4KB "name" is truncated on a UTF-8 boundary with an ellipsis

Related Pages

Page Connections

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