
























@@ -5,12 +5,14 @@ import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test, vi
55import type { ChannelPlugin } from "../channels/plugins/types.js";
66import { createChannelTestPluginBase } from "../test-utils/channel-plugins.js";
77import { waitForAgentCommandCall } from "./agent-command.test-helpers.js";
8+import { __resetModelCatalogCacheForTest as resetGatewayModelCatalogCacheForTest } from "./server-model-catalog.js";
89import { setRegistry } from "./server.agent.gateway-server-agent.mocks.js";
910import { createRegistry } from "./server.e2e-registry-helpers.js";
1011import {
1112agentCommand,
1213connectOk,
1314installGatewayTestHooks,
15+piSdkMock,
1416rpcReq,
1517startServerWithClient,
1618testState,
@@ -440,6 +442,69 @@ describe("gateway server agent", () => {
440442});
441443});
442444445+test("agent validates first image attachment against per-agent model for fresh sessions", async () => {
446+testState.agentConfig = { model: { primary: "ollama-cloud/deepseek-v4-flash" } };
447+testState.agentsConfig = {
448+list: [
449+{ id: "main", default: true },
450+{ id: "vision", model: "ollama-cloud/gemma4:31b" },
451+],
452+};
453+piSdkMock.enabled = true;
454+piSdkMock.models = [
455+{
456+id: "deepseek-v4-flash",
457+name: "DeepSeek V4 Flash",
458+provider: "ollama-cloud",
459+input: ["text"],
460+},
461+{
462+id: "gemma4:31b",
463+name: "Gemma 4 31B",
464+provider: "ollama-cloud",
465+input: ["text", "image"],
466+},
467+];
468+await resetGatewayModelCatalogCacheForTest();
469+470+await setTestSessionStore({
471+agentId: "vision",
472+entries: {
473+main: {
474+sessionId: "sess-vision-fresh-image",
475+updatedAt: Date.now(),
476+},
477+},
478+});
479+480+const res = await rpcReq(ws, "agent", {
481+message: "what is in the image?",
482+sessionKey: "agent:vision:main",
483+attachments: [
484+{
485+mimeType: "image/png",
486+fileName: "tiny.png",
487+content: BASE_IMAGE_PNG,
488+},
489+],
490+idempotencyKey: "idem-agent-vision-first-image",
491+});
492+expect(
493+res,
494+`agent RPC should accept image using per-agent vision model: ${JSON.stringify(res)}`,
495+).toMatchObject({ ok: true });
496+497+const call = await waitForAgentCommandCall("idem-agent-vision-first-image");
498+expect(call.sessionKey).toBe("agent:vision:main");
499+expect(call.images).toEqual([
500+expect.objectContaining({
501+type: "image",
502+mimeType: "image/png",
503+data: BASE_IMAGE_PNG,
504+}),
505+]);
506+});
507+443508test("agent errors when delivery requested and no last channel exists", async () => {
444509testState.allowFrom = ["+1555"];
445510try {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。