earendil-works/pi · error · Error

Invalid Copilot models response

Error message

Invalid Copilot models response

What it means

Error "Invalid Copilot models response" thrown in earendil-works/pi.

Source

Thrown at packages/ai/src/auth/oauth/github-copilot.ts:96

function getGitHubCopilotBaseUrl(token?: string, enterpriseDomain?: string): string {
	// If we have a token, extract the base URL from proxy-ep
	if (token) {
		const urlFromToken = getBaseUrlFromToken(token);
		if (urlFromToken) return urlFromToken;
	}
	// Fallback for enterprise or if token parsing fails
	if (enterpriseDomain) return `https://copilot-api.${enterpriseDomain}`;
	return "https://api.individual.githubcopilot.com";
}

function asRecord(value: unknown): Record<string, unknown> | undefined {
	return value && typeof value === "object" ? (value as Record<string, unknown>) : undefined;
}

function parseGitHubCopilotModelCatalog(raw: unknown, allowPolicyFallback: boolean) {
	const data = asRecord(raw)?.data;
	if (!Array.isArray(data)) {
		throw new Error("Invalid Copilot models response");
	}

	const accountModels = data.flatMap((rawItem) => {
		const item = asRecord(rawItem);
		const id = item?.id;
		if (!item || typeof id !== "string") return [];

		const capabilities = asRecord(item.capabilities);
		const supports = asRecord(capabilities?.supports);
		if (supports?.tool_calls === false) return [];

		return [
			{
				id,
				pickerEnabled: item.model_picker_enabled === true,
				policyState: asRecord(item.policy)?.state,
			},
		];

View on GitHub (pinned to 4af9d21d3b)

Solutions

  1. Retry; if persistent, the Copilot models API shape changed and the parser needs an update.

When it happens

Trigger: Thrown at packages/ai/src/auth/oauth/github-copilot.ts:96 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24). Data as JSON: /api/errors/54cadb4c08aa81db. Report an issue: GitHub.