@@ -278,21 +278,48 @@ describe("OpenAI-compatible embeddings HTTP API (e2e)", () => {
278278 } ) ;
279279
280280 it ( "supports base64 encoding and agent-scoped auth/config resolution" , async ( ) => {
281- const res = await postEmbeddings (
282- {
283- model : "openclaw/beta" ,
284- input : "hello" ,
285- encoding_format : "base64" ,
286- } ,
287- { "x-openclaw-agent-id" : "beta" } ,
288- ) ;
289- expect ( res . status ) . toBe ( 200 ) ;
290- const json = ( await res . json ( ) ) as { data ?: Array < { embedding ?: string } > } ;
291- expect ( typeof json . data ?. [ 0 ] ?. embedding ) . toBe ( "string" ) ;
292- expect ( createEmbeddingProviderMock ) . toHaveBeenCalled ( ) ;
293- const lastCall = latestCreateEmbeddingProviderOptions ( ) ;
294- expect ( typeof lastCall . model ) . toBe ( "string" ) ;
295- expect ( lastCall . agentDir ) . toBe ( resolveAgentDir ( { } , "beta" ) ) ;
281+ try {
282+ testState . agentsConfig = { list : [ { id : "main" } , { id : "beta" } ] } ;
283+ resetConfigRuntimeState ( ) ;
284+
285+ const res = await postEmbeddings (
286+ {
287+ model : "openclaw/beta" ,
288+ input : "hello" ,
289+ encoding_format : "base64" ,
290+ } ,
291+ { "x-openclaw-agent-id" : "beta" } ,
292+ ) ;
293+ expect ( res . status ) . toBe ( 200 ) ;
294+ const json = ( await res . json ( ) ) as { data ?: Array < { embedding ?: string } > } ;
295+ expect ( typeof json . data ?. [ 0 ] ?. embedding ) . toBe ( "string" ) ;
296+ expect ( createEmbeddingProviderMock ) . toHaveBeenCalled ( ) ;
297+ const lastCall = latestCreateEmbeddingProviderOptions ( ) ;
298+ expect ( typeof lastCall . model ) . toBe ( "string" ) ;
299+ expect ( lastCall . agentDir ) . toBe ( resolveAgentDir ( { } , "beta" ) ) ;
300+ } finally {
301+ testState . agentsConfig = undefined ;
302+ resetConfigRuntimeState ( ) ;
303+ }
304+ } ) ;
305+
306+ it ( "rejects explicit unknown agent ids" , async ( ) => {
307+ try {
308+ testState . agentsConfig = { list : [ { id : "main" } , { id : "beta" } ] } ;
309+ resetConfigRuntimeState ( ) ;
310+
311+ const header = await postEmbeddings (
312+ { model : "openclaw/default" , input : "hello" } ,
313+ { "x-openclaw-agent-id" : "missing-agent" } ,
314+ ) ;
315+ await expectInvalidEmbeddingRequest ( header , "Unknown agent 'missing-agent'." ) ;
316+
317+ const model = await postEmbeddings ( { model : "openclaw/missing-agent" , input : "hello" } ) ;
318+ await expectInvalidEmbeddingRequest ( model , "Unknown agent 'missing-agent'." ) ;
319+ } finally {
320+ testState . agentsConfig = undefined ;
321+ resetConfigRuntimeState ( ) ;
322+ }
296323 } ) ;
297324
298325 it ( "rejects invalid input shapes" , async ( ) => {
0 commit comments