{"record":{"id":"daad2fa791c42c01","repo":"coleam00/Archon","slug":"invalid-pi-model-ref-modelref-expected-form","errorCode":null,"errorMessage":"Invalid Pi model ref: '${modelRef}'. Expected format '<pi-provider-id>/<model-id>' (e.g. 'google/gemini-2.5-pro').","messagePattern":"Invalid Pi model ref: '(.+?)'\\. Expected format '<pi-provider-id>/<model-id>' \\(e\\.g\\. 'google/gemini-2\\.5-pro'\\)\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/providers/src/community/pi/provider.ts","lineNumber":406,"sourceCode":"          getLog().info({ modelRef }, 'pi.model_defaulted_from_settings');\n        }\n      } catch (err) {\n        // Non-fatal: settings.json may be absent (user never ran `pi`) or\n        // unreadable. Fall through to the explicit \"requires a model\" error\n        // below rather than swallowing the missing-model condition.\n        getLog().debug({ err }, 'pi.settings_default_model_read_failed');\n      }\n    }\n    if (!modelRef) {\n      throw new Error(\n        'Pi provider requires a model. Set `model` on the workflow node or `assistants.pi.model` in .archon/config.yaml, ' +\n          'or select a default model in the `pi` CLI (writes defaultProvider/defaultModel to ~/.pi/agent/settings.json). ' +\n          \"Format: '<pi-provider-id>/<model-id>' (e.g. 'google/gemini-2.5-pro').\"\n      );\n    }\n    const parsed = parsePiModelRef(modelRef);\n    if (!parsed) {\n      throw new Error(\n        `Invalid Pi model ref: '${modelRef}'. Expected format '<pi-provider-id>/<model-id>' (e.g. 'google/gemini-2.5-pro').`\n      );\n    }\n\n    // 2. Build ModelRuntime + ModelRegistry. Both read on every sendQuery —\n    //    user edits to auth.json or models.json take effect without restart.\n    //    The registry is a thin facade over the runtime — extension providers\n    //    call registerProvider() on it during bindExtensions() to add their\n    //    models (phase 2 resolution).\n    const envVarName = PI_PROVIDER_ENV_VARS[parsed.provider];\n    const oauthVarName = PI_OAUTH_ENV_VARS[parsed.provider];\n    let modelRuntime: Awaited<ReturnType<typeof piCodingAgent.ModelRuntime.create>>;\n    let modelRegistry: InstanceType<typeof piCodingAgent.ModelRegistry>;\n    // For custom (non-built-in) Pi providers, build a per-call `models.json`\n    // with `${VAR}` references substituted against the per-call env. The\n    // SDK's session-auth path resolves `${VAR}` from `process.env`, which\n    // Archon deliberately keeps empty (per-call secrets ride on\n    // `requestOptions.env`); pre-substituting into a per-call file closes","sourceCodeStart":388,"sourceCodeEnd":424,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/providers/src/community/pi/provider.ts#L388-L424","documentation":"A model reference was supplied but parsePiModelRef could not parse it into provider/modelId. The ref must be '<pi-provider-id>/<model-id>'. This is a fail-fast on malformed configuration before any session is built.","triggerScenarios":"sendQuery receiving modelRef values like 'gemini-2.5-pro' (no slash), 'google/gemini/2.5' variants the parser rejects, whitespace-only strings, or a full URL pasted into the model field.","commonSituations":"Users copying just the model id from a provider console, quoting/escaping issues leaving stray characters, or putting a provider name only ('google').","solutions":["Use the exact '<provider>/<model>' form, e.g. 'google/gemini-2.5-pro'","Check for stray whitespace, quotes, or extra slashes in the model value","Confirm the provider id matches a Pi provider id (run `pi` to list them)"],"exampleFix":"// before\nmodel: 'gemini-2.5-pro'\n// after\nmodel: 'google/gemini-2.5-pro'","handlingStrategy":"validation","validationCode":"const PI_MODEL_REF = /^[^/\\s]+\\/[^/\\s]+$/;\nif (!PI_MODEL_REF.test(modelRef ?? '')) {\n  throw new Error(`Bad Pi model ref '${modelRef}': use '<provider>/<model-id>'`);\n}","typeGuard":"function isPiModelRef(v: unknown): v is string {\n  return typeof v === 'string' && /^[^/\\s]+\\/[^/\\s]+$/.test(v);\n}","tryCatchPattern":"try {\n  await sendQuery(q);\n} catch (err) {\n  if (err.message.startsWith('Invalid Pi model ref')) {\n    console.error(err.message); // message already contains the expected format\n  }\n  throw err;\n}","preventionTips":["Store model refs as full '<provider>/<model-id>' strings in config","Validate model values with a regex in config-loading code","Copy provider/model ids from `pi`'s model list, not from provider consoles"],"tags":["configuration","model","validation"],"backgroundTag":"invalid-model-reference-format","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}