GeezerVison is showing github.com — fix(provider-core): ACP sign-in failures tell the user to sign in (#2… · mattiaz9/t3code@8d5f21f
File treeExpand file treeCollapse file tree Open diff view settings apps/server/src/orchestration-v2/testkit packages/provider-core/src/server
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/testkit/AcpRegistryReplayFixtures.integration.test.ts +6-11Lines changed: 6 additions & 11 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -182,17 +182,12 @@ describe("ACP registry replay fixtures", () => { | 182 | 182 | const errors = projection.turnItems.filter((item) => item.type === "error"); | 183 | 183 | assert.lengthOf(errors, 1); | 184 | 184 | assert.equal(errors[0]?.failure.class, "provider_error"); | 185 | | - if (testCase.code === -32602) { | 186 | | - assert.equal( | 187 | | - errors[0]?.failure.message, | 188 | | - 'The agent did not accept the model "replay-model-b". Choose another model for this provider, then retry.', | 189 | | - ); | 190 | | - } else { | 191 | | - assert.match( | 192 | | - errors[0]?.failure.message ?? "", | 193 | | - /^Failed to open acpRegistry provider session \S+\.$/u, | 194 | | - ); | 195 | | - } | | 185 | + assert.equal( | | 186 | + errors[0]?.failure.message, | | 187 | + testCase.code === -32602 | | 188 | + ? 'The agent did not accept the model "replay-model-b". Choose another model for this provider, then retry.' | | 189 | + : "The provider needs you to sign in. Sign in from its provider settings or with its own CLI or app, then retry the turn.", | | 190 | + ); | 196 | 191 | }).pipe( | 197 | 192 | Effect.provide( | 198 | 193 | layerProviderReplay(scenario, AcpRegistryOrchestratorReplayHarness, { | |
Collapse file Copy file name to clipboardExpand all lines: packages/provider-core/src/server/failure.test.ts +18Lines changed: 18 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -165,6 +165,24 @@ it("names how the provider process exited and the stage it failed in, without it | 165 | 165 | ); | 166 | 166 | }); | 167 | 167 |
| | 168 | +it("tells the user to sign in only when an ACP agent answers auth_required", () => { | | 169 | + const providerSessionId = ProviderSessionId.make("provider-session:private-id"); | | 170 | + const sessionOpenFailure = (code: number) => ({ | | 171 | + _tag: "ProviderSessionOpenError", | | 172 | + cause: new ProviderAdapter.ProviderAdapterOpenSessionError({ | | 173 | + driver: ProviderDriverKind.make("acpRegistry"), | | 174 | + providerSessionId, | | 175 | + cause: Cause.fail({ _tag: "AcpRequestError", code, errorMessage: "Private agent text" }), | | 176 | + }), | | 177 | + }); | | 178 | + | | 179 | + assert.equal( | | 180 | + makeProviderFailure({ cause: Cause.fail(sessionOpenFailure(-32000)) }).message, | | 181 | + "The provider needs you to sign in. Sign in from its provider settings or with its own CLI or app, then retry the turn.", | | 182 | + ); | | 183 | + assert.isUndefined(knownProviderFailureMessage(sessionOpenFailure(-32603))); | | 184 | +}); | | 185 | + | 168 | 186 | it("keeps unrecognized reasons and provider text out of category messages", () => { | 169 | 187 | for (const cause of [ | 170 | 188 | "Private launch command", | |
Collapse file Copy file name to clipboardExpand all lines: packages/provider-core/src/server/failure.ts +8Lines changed: 8 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -158,6 +158,14 @@ function curatedCauseMessages(cause: unknown): { | 158 | 158 | category: categoryMessage(), | 159 | 159 | }; | 160 | 160 | } | | 161 | + // ACP reserves -32000 for auth_required; the agent's own text is not shown. | | 162 | + case "AcpRequestError": | | 163 | + if ((cause as Record<string, unknown>).code !== -32000) break; | | 164 | + return { | | 165 | + known: | | 166 | + "The provider needs you to sign in. Sign in from its provider settings or with its own CLI or app, then retry the turn.", | | 167 | + category: categoryMessage(), | | 168 | + }; | 161 | 169 | case "ContextHandoffDeliveryUncertainError": | 162 | 170 | return { | 163 | 171 | known: | |
|