{"record":{"id":"bbeb9fa816a9a74a","repo":"earendil-works/pi","slug":"authentication-failed-for-this-model-provider","errorCode":null,"errorMessage":"Authentication failed for \"${this.model.provider}\". Credentials may have expired or network is unavailable. Run '/login ${this.model.provider}' to re-authenticate.","messagePattern":"Authentication failed for \"(.+?)\"\\. Credentials may have expired or network is unavailable\\. Run '/login (.+?)' to re-authenticate\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/core/agent-session.ts","lineNumber":1207,"sourceCode":"\t\t\t\tpreflightResult?.(true);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Flush any pending bash messages before the new prompt\n\t\t\tthis._flushPendingBashMessages();\n\n\t\t\t// Validate model\n\t\t\tif (!this.model) {\n\t\t\t\tthrow new Error(formatNoModelSelectedMessage());\n\t\t\t}\n\n\t\t\tconst hasConfiguredAuth =\n\t\t\t\tthis._modelRuntime.hasConfiguredAuth(this.model.provider) ||\n\t\t\t\t(await this._modelRuntime.checkAuth(this.model.provider)) !== undefined;\n\t\t\tif (!hasConfiguredAuth) {\n\t\t\t\tconst isOAuth = this._modelRuntime.isUsingOAuth(this.model.provider);\n\t\t\t\tif (isOAuth) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Authentication failed for \"${this.model.provider}\". ` +\n\t\t\t\t\t\t\t`Credentials may have expired or network is unavailable. ` +\n\t\t\t\t\t\t\t`Run '/login ${this.model.provider}' to re-authenticate.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tthrow new Error(formatNoApiKeyFoundMessage(this.model.provider));\n\t\t\t}\n\n\t\t\t// Check if we need to compact before sending (catches aborted responses).\n\t\t\t// The user's new prompt is sent below, so do not call agent.continue() here.\n\t\t\tconst lastAssistant = this._findLastAssistantMessage();\n\t\t\tif (lastAssistant) {\n\t\t\t\tawait this._checkCompaction(lastAssistant, false);\n\t\t\t}\n\n\t\t\t// Build messages array (custom message if any, then user message)\n\t\t\tmessages = [];\n","sourceCodeStart":1189,"sourceCodeEnd":1225,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/coding-agent/src/core/agent-session.ts#L1189-L1225","documentation":"Error \"Authentication failed for \"${this.model.provider}\". Credentials may have expired or network is unavailable. Run '/login ${this.model.provider}' to re-authenticate.\" thrown in earendil-works/pi.","triggerScenarios":"Thrown at packages/coding-agent/src/core/agent-session.ts:1207 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4af9d21d3b4d664e4a29fcabfec85171077248e3","analyzedAt":"2026-08-24T13:07:14.692Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}