惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
T
The Blog of Author Tim Ferriss
F
Fortinet All Blogs
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
阮一峰的网络日志
阮一峰的网络日志
The GitHub Blog
The GitHub Blog
Y
Y Combinator Blog
MyScale Blog
MyScale Blog
雷峰网
雷峰网
博客园 - 叶小钗
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
GbyAI
GbyAI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 三生石上(FineUI控件)
云风的 BLOG
云风的 BLOG
V
V2EX
宝玉的分享
宝玉的分享
酷 壳 – CoolShell
酷 壳 – CoolShell
N
Netflix TechBlog - Medium
Vercel News
Vercel News
美团技术团队
人人都是产品经理
人人都是产品经理
The Cloudflare Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(amazon-bedrock): skip auto memory embeddings without ...
steipete · 2026-04-25 · via Recent Commits to openclaw:main

@@ -0,0 +1,100 @@

1+

import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";

2+3+

const hasAwsCredentialsMock = vi.hoisted(() => vi.fn());

4+

const createBedrockEmbeddingProviderMock = vi.hoisted(() => vi.fn());

5+6+

vi.mock("./embedding-provider.js", async (importOriginal) => {

7+

const actual = await importOriginal<typeof import("./embedding-provider.js")>();

8+

return {

9+

...actual,

10+

hasAwsCredentials: hasAwsCredentialsMock,

11+

createBedrockEmbeddingProvider: createBedrockEmbeddingProviderMock,

12+

};

13+

});

14+15+

import { bedrockMemoryEmbeddingProviderAdapter } from "./memory-embedding-adapter.js";

16+17+

function defaultCreateOptions() {

18+

return {

19+

config: {} as Record<string, unknown>,

20+

agentDir: "/tmp/test-agent",

21+

model: "",

22+

};

23+

}

24+25+

function stubCreate(client: { region: string; model: string; dimensions?: number }) {

26+

createBedrockEmbeddingProviderMock.mockResolvedValue({

27+

provider: {

28+

id: "bedrock",

29+

model: client.model,

30+

embedQuery: async () => [],

31+

embedBatch: async () => [],

32+

},

33+

client,

34+

});

35+

}

36+37+

describe("bedrockMemoryEmbeddingProviderAdapter", () => {

38+

beforeEach(() => {

39+

hasAwsCredentialsMock.mockReset();

40+

createBedrockEmbeddingProviderMock.mockReset();

41+

});

42+43+

afterEach(() => {

44+

vi.restoreAllMocks();

45+

});

46+47+

it("registers the expected adapter metadata", () => {

48+

expect(bedrockMemoryEmbeddingProviderAdapter.id).toBe("bedrock");

49+

expect(bedrockMemoryEmbeddingProviderAdapter.transport).toBe("remote");

50+

expect(bedrockMemoryEmbeddingProviderAdapter.authProviderId).toBe("amazon-bedrock");

51+

expect(bedrockMemoryEmbeddingProviderAdapter.autoSelectPriority).toBe(60);

52+

expect(bedrockMemoryEmbeddingProviderAdapter.allowExplicitWhenConfiguredAuto).toBe(true);

53+

});

54+55+

it("throws a missing-api-key sentinel error when AWS credentials are unavailable", async () => {

56+

hasAwsCredentialsMock.mockResolvedValue(false);

57+58+

await expect(

59+

bedrockMemoryEmbeddingProviderAdapter.create(defaultCreateOptions()),

60+

).rejects.toThrow(/No API key found for provider "bedrock"/);

61+

await expect(

62+

bedrockMemoryEmbeddingProviderAdapter.create(defaultCreateOptions()),

63+

).rejects.toThrow(/AWS credentials are not available/);

64+65+

expect(createBedrockEmbeddingProviderMock).not.toHaveBeenCalled();

66+

});

67+68+

it("creates the provider when AWS credentials are available", async () => {

69+

hasAwsCredentialsMock.mockResolvedValue(true);

70+

stubCreate({ region: "us-east-1", model: "amazon.titan-embed-text-v2:0", dimensions: 1024 });

71+72+

const result = await bedrockMemoryEmbeddingProviderAdapter.create(defaultCreateOptions());

73+74+

expect(result.provider?.id).toBe("bedrock");

75+

expect(result.runtime).toEqual({

76+

id: "bedrock",

77+

cacheKeyData: {

78+

provider: "bedrock",

79+

region: "us-east-1",

80+

model: "amazon.titan-embed-text-v2:0",

81+

dimensions: 1024,

82+

},

83+

});

84+

expect(createBedrockEmbeddingProviderMock).toHaveBeenCalledOnce();

85+

});

86+87+

it("lets the auto-select loop skip bedrock when credentials are unavailable", async () => {

88+

hasAwsCredentialsMock.mockResolvedValue(false);

89+90+

let thrown: unknown;

91+

try {

92+

await bedrockMemoryEmbeddingProviderAdapter.create(defaultCreateOptions());

93+

} catch (err) {

94+

thrown = err;

95+

}

96+97+

expect(thrown).toBeInstanceOf(Error);

98+

expect(bedrockMemoryEmbeddingProviderAdapter.shouldContinueAutoSelection?.(thrown)).toBe(true);

99+

});

100+

});