{"record":{"id":"7807d42a372b7ee4","repo":"can1357/oh-my-pi","slug":"unsupported-pi-tiny-dtype-json-stringify-value","errorCode":null,"errorMessage":"Unsupported PI_TINY_DTYPE=${JSON.stringify(value)}. Use auto, fp32, fp16, q8, int8, uint8, q4, bnb4, q4f16, q2, q2f16, q1, or q1f16.","messagePattern":"Unsupported PI_TINY_DTYPE=(.+?)\\. Use auto, fp32, fp16, q8, int8, uint8, q4, bnb4, q4f16, q2, q2f16, q1, or q1f16\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tiny/dtype.ts","lineNumber":33,"sourceCode":"\tbnb4: true,\n\tq4f16: true,\n\tq2: true,\n\tq2f16: true,\n\tq1: true,\n\tq1f16: true,\n};\n\n/**\n * Validate and canonicalize a `PI_TINY_DTYPE` value. Returns `undefined` when\n * unset/blank so callers fall back to the per-model spec dtype, and throws on an\n * unrecognized value so a misconfiguration fails loudly instead of silently\n * loading a different precision than requested.\n */\nexport function normalizeTinyModelDtype(value: string | undefined): TinyModelDtype | undefined {\n\tconst raw = value?.trim().toLowerCase();\n\tif (!raw) return undefined;\n\tif (raw in DTYPE_VALUES) return raw as TinyModelDtype;\n\tthrow new Error(\n\t\t`Unsupported PI_TINY_DTYPE=${JSON.stringify(value)}. Use auto, fp32, fp16, q8, int8, uint8, q4, bnb4, q4f16, q2, q2f16, q1, or q1f16.`,\n\t);\n}\n\n/**\n * Resolve the `PI_TINY_DTYPE` override. `undefined` means \"use the per-model spec\n * dtype\" (currently `q4` for every shipped model); a concrete value overrides the\n * precision for whichever local tiny model loads.\n */\nexport function resolveTinyModelDtypeOverride(\n\tvalue: string | undefined = $env.PI_TINY_DTYPE,\n): TinyModelDtype | undefined {\n\treturn normalizeTinyModelDtype(value);\n}\n\n/** Sentinel `providers.tinyModelDtype` value meaning \"use each model's shipped dtype\". */\nexport const TINY_MODEL_DTYPE_DEFAULT = \"default\";\n","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tiny/dtype.ts#L15-L51","documentation":"normalizeTinyModelDtype validates the PI_TINY_DTYPE environment variable against the known quantization/precision values. Unknown values throw instead of falling back, because loading a different precision than requested wastes memory or breaks local model loading.","triggerScenarios":"Setting PI_TINY_DTYPE to an unrecognized string (e.g. `int4`, `q5`, `float16`) and resolving the dtype override.","commonSituations":"Using dtype names from other runtimes (torch `bfloat16`, llama.cpp `q5_k_m`) that aren't in the supported list; typos like `fp16 ` or `Q8` (casing is normalized, spelling must match exactly).","solutions":["Set PI_TINY_DTYPE to one of: auto, fp32, fp16, q8, int8, uint8, q4, bnb4, q4f16, q2, q2f16, q1, or q1f16","Use `auto` to follow the per-model spec's preferred dtype","Unset PI_TINY_DTYPE to use the per-model spec default"],"exampleFix":"// before\nexport PI_TINY_DTYPE=bfloat16\n// after\nexport PI_TINY_DTYPE=fp16","handlingStrategy":"validation","validationCode":"const DTYPES = [\"auto\",\"fp32\",\"fp16\",\"q8\",\"int8\",\"uint8\",\"q4\",\"bnb4\",\"q4f16\",\"q2\",\"q2f16\",\"q1\",\"q1f16\"];\nconst v = process.env.PI_TINY_DTYPE?.trim().toLowerCase();\nif (v && !DTYPES.includes(v)) throw new Error(`PI_TINY_DTYPE must be one of ${DTYPES.join(\", \")}`);","typeGuard":null,"tryCatchPattern":"try {\n\tconst dtype = normalizeTinyModelDtype(process.env.PI_TINY_DTYPE);\n} catch (err) {\n\tlogger.warn(\"Invalid PI_TINY_DTYPE, using per-model spec\", { value: process.env.PI_TINY_DTYPE });\n\treturn undefined;\n}","preventionTips":["Use only the listed dtype names; no torch/llama.cpp style names","Leave PI_TINY_DTYPE unset to follow the per-model spec","Validate env vars at startup"],"tags":["configuration","environment-variable","tiny-model","quantization"],"backgroundTag":"unsupported-env-var-value","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}