Skip to content

modelRegistry.ts hardcodes sizeMb: 0 for all models and getModels() loses slug keys #21

@kessenma

Description

@kessenma

Before submitting a new issue

  • I tested using the latest version of the library, as the bug might be already fixed.
  • I tested using a supported version of react native.
  • I checked for possible duplicate issues, with possible answers.

Bug summary

The React Native SDK's modelRegistry.ts hardcodes sizeMb: 0 for every model, and getModels() returns Object.values() which strips the registry keys (slugs), making it impossible for consumers to know which model is which.

Root cause
In src/modelRegistry.ts, the fetchRegistry() function fetches from HuggingFace but never parses file sizes:

registry[key] = {
  quantization: {
    int4: {
      sizeMb: 0,  // ← hardcoded
      url: `${base}-int4.zip`,
    },
    int8: {
      sizeMb: 0,  // ← hardcoded
      url: `${base}-int8.zip`,
    },
  },
};

And getModels() discards the keys:

public async getModels(): Promise<CactusModel[]> {
  return Object.values(await getRegistry());
  //     ^^^^^^^^^^^^^ slug (the key) is lost
}

Impact
sizeMb is always 0 — apps cannot display model sizes to users.
Slugs are lost — CactusModel only contains quantization (with nested url and sizeMb). There's no slug, name, or any identifier on the returned objects, so consumers have to reverse-engineer slugs from download URLs.
Capability metadata missing — CactusModel in v1.7 no longer includes supports_tool_calling, supports_vision, name, etc. that existed in earlier versions.

Comparison with the Kotlin SDK
The Kotlin SDK (cactus-kotlin) doesn't have this issue because it uses a completely different backend. Instead of fetching from HuggingFace, it calls a Supabase edge function:

// Kotlin SDK — Supabase.kt
suspend fun fetchModels(): List<CactusModel> {
    val response = client.get("$SUPABASE_URL/functions/v1/get-models?sdk_name=kotlin&sdk_version=...")
    // ...
}

The Kotlin CactusModel has all the fields consumers need:

data class CactusModel(
    val created_at: String,
    val slug: String,
    val download_url: String,
    val size_mb: Int,              // ← actual size from backend
    val supports_tool_calling: Boolean,
    val supports_vision: Boolean,
    val name: String,
    var isDownloaded: Boolean = false,
    val quantization: Int = 8
)

Suggested fix
Either:

Use the same Supabase backend that the Kotlin SDK uses, which returns proper slug, name, size_mb, supports_tool_calling, supports_vision, and quantization per model.
Or at minimum, fix the two immediate bugs:
Parse file sizes from the HuggingFace API response (the siblings array contains LFS metadata)
Change getModels() to return Object.entries() (or a keyed object) so slugs are preserved
Re-add slug, name, and capability fields to the CactusModel type

Workaround
I'm currently calling the Supabase endpoint directly from my React Native app (same URL/key as the Kotlin SDK) to get proper model metadata, bypassing getModels() entirely.

Environment
cactus-react-native: ^1.7.0
React Native: 0.84
Compared against: cactus-kotlin (latest)

Library version

1.7

Environment info

System:
  OS: macOS 26.3
  CPU: (10) arm64 Apple M1 Max
  Memory: 112.84 MB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.18.2
    path: /Users/ke/.nvm/versions/node/v20.18.2/bin/node
  npm:
    version: 10.8.2
    path: /Users/ke/.nvm/versions/node/v20.18.2/bin/npm
SDKs:
  iOS SDK:
    Platforms:
      - iOS 26.2
      - macOS 26.2
  Android SDK:
    API Levels:
      - "35"
      - "36"
    Build Tools:
      - 35.0.0
      - 36.0.0
      - 36.1.0
IDEs:
  Android Studio: 2025.3 AI-253.29346.138.2531.14876573
  Xcode:
    version: 26.3/17C529
Languages:
  Java: 17.0.18
  Ruby: 3.4.2
npmPackages:
  react: 19.2.3
  react-native: 0.84.0

Steps to reproduce

  1. Install cactus-react-native@1.7.0
  2. Call getModels() and inspect the returned objects:
const cactusLM = new CactusLM();
const models = await cactusLM.getModels();
console.log(JSON.stringify(models[0], null, 2));


### Reproducible example repository

na

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions