Show OMP sign-in guidance when OMP reports no model selected (#26649)

* Recognize native chat sign-in failures across structured agents

* Fix authentication failures and chat sign-in guidance

* Preserve sign-in diagnostics and command retry context

* fix(native-chat): keep visible sign-in guidance and localize startup rows

* fix(native-chat): separate auth diagnostics from retry guidance

* test(native-chat): align startup guidance expectations

* fix(native-chat): treat OMP's signed-out 'No model selected' as not signed in

* fix(native-chat): start a new agent for the send after it reports not signed in

* fix(native-chat): scope the signed-out check by fence and read without a snapshot

* fix(native-chat): keep a signed-out agent while it owes work, and read only its own rows

* fix(native-chat): keep a signed-out agent that may owe a wake-up turn, and skip the check during a Stop
This commit is contained in:
Brennan Benson
2026-10-08 14:54:30 -07:00
committed by GitHub
parent ff4a51c872
commit 58a58f4e4e
2 changed files with 15 additions and 5 deletions
+10 -5
View File
@@ -9,6 +9,8 @@ import type { AcpDialect } from './acp-dialect'
// background launch results do not establish a process exit.
const textBlockSchema = z.looseObject({ type: z.literal('text'), text: z.string() })
const promptErrorDataSchema = z.looseObject({ details: z.string() })
// OMP's prompt check: no usable model (nothing signed in), or the selected model's provider has no key.
const SIGNED_OUT_DETAIL_PREFIXES = ['No model selected.\n\nUse /login', 'No API key found for ']
const toolResultSchema = z.looseObject({
content: z.array(z.unknown()),
details: z
@@ -95,9 +97,12 @@ function normalizeToolUpdate(update: ToolCallUpdate): ToolCallUpdate {
export const OMP_ACP_DIALECT: AcpDialect = {
normalizeToolUpdate,
promptErrorDetail: (error) => promptErrorDataSchema.safeParse(error.data).data?.details,
authenticationRequired: (error) =>
error.code === -32603 &&
promptErrorDataSchema
.safeParse(error.data)
.data?.details.startsWith('No API key found for ') === true
authenticationRequired: (error) => {
const details = promptErrorDataSchema.safeParse(error.data).data?.details
return (
error.code === -32603 &&
details !== undefined &&
SIGNED_OUT_DETAIL_PREFIXES.some((prefix) => details.startsWith(prefix))
)
}
}
@@ -99,6 +99,11 @@ it.each([
'No API key found for anthropic.\n\nUse /login, set an API key environment variable, or create /host/agent.db',
'notSignedIn'
],
[
'No model selected.\n\nUse /login, set an API key environment variable, or create /host/agent.db\n\nThen use /model to select a model.',
'notSignedIn'
],
['No model selected', undefined],
['Rate limit exceeded', undefined],
['Network connection failed', undefined],
['No API key found elsewhere', undefined]