🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix: support Nano Banana 2.1 and render images in multi-step replies (#20516)
YuTengjinge420c2d7816e
diff --git a/locales/en-US/models.json b/locales/en-US/models.jsonindex a39cb91c25c..82fdfb8ffb0 100644--- a/locales/en-US/models.json+++ b/locales/en-US/models.json@@ -837,6 +837,8 @@"lobehub.gemini-3.6-flash.description": "Gemini 3.6 Flash balances speed with intelligence for strong agentic, coding, and multimodal performance with improved token efficiency.","lobehub.gemini-3.7-flash.description": "Gemini 3.7 Flash is Google's most capable Flash model, built for complex coding, agentic workflows, and reliable multi-step execution.","lobehub.gemini-3.8-flash.description": "Google's most intelligent Flash model, tuned for long-horizon coding and autonomous agents — faster first token and less verbose than 3.7 Flash at the same price.",+ "lobehub.gemini-nano-banana-2.1.description": "Successor to Nano Banana 2 at roughly half the per-image price, with sharper text rendering and steadier multi-turn character consistency.",+ "lobehub.gemini-nano-banana-2.1:image.description": "Successor to Nano Banana 2 at roughly half the per-image price, with sharper text rendering and steadier multi-turn character consistency.","lobehub.glm-5.1.description": "Zai's latest flagship model, aligned with Claude Opus 4.6 on overall and coding capabilities. Excels at long-horizon tasks with autonomous work up to 8 hours, an ideal foundation for Autonomous Agents and long-horizon Coding Agents.","lobehub.glm-5.2.description": "GLM-5.2 is the first open-source model to approach the performance of the latest-generation Claude Opus released in the same period.","lobehub.glm-5.3-flash.description": "The first GLM-5 that can see — stronger than GLM-5.2, coding that approaches Opus 4.8, at about one-tenth the flagship price.",diff --git a/locales/zh-CN/models.json b/locales/zh-CN/models.jsonindex e70c3ee9ecb..6d3f765db73 100644--- a/locales/zh-CN/models.json+++ b/locales/zh-CN/models.json@@ -837,6 +837,8 @@"lobehub.gemini-3.6-flash.description": "Gemini 3.6 Flash 在速度与智能之间实现平衡,适用于强大的智能代理、编码和多模态性能,并提高了令牌效率。","lobehub.gemini-3.7-flash.description": "Gemini 3.7 Flash 是 Google 最强的 Flash 模型,面向复杂编程、智能体工作流和可靠的多步执行。","lobehub.gemini-3.8-flash.description": "Google 最聪明的 Flash 模型,专为长程编程和自主智能体调优——首字更快、输出更精简,价格与 3.7 Flash 持平。",+ "lobehub.gemini-nano-banana-2.1.description": "Nano Banana 2 的继任者,单张图片价格约为其一半,文字渲染更清晰,多轮对话中的角色一致性更稳定。",+ "lobehub.gemini-nano-banana-2.1:image.description": "Nano Banana 2 的继任者,单张图片价格约为其一半,文字渲染更清晰,多轮对话中的角色一致性更稳定。","lobehub.glm-5.1.description": "Zai 的最新旗舰模型,在整体和编码能力上与 Claude Opus 4.6 对齐。擅长长时间任务,支持长达 8 小时的自主工作,是自主代理和长时间编码代理的理想基础。","lobehub.glm-5.2.description": "GLM-5.2 是首个接近同期发布的最新一代 Claude Opus 性能的开源模型。","lobehub.glm-5.3-flash.description": "GLM-5 系列第一款能看图的模型。比 GLM-5.2 更强,编码逼近 Opus 4.8,价格却只有旗舰的十分之一。",diff --git a/packages/locales/src/lobehubOnlineModelDescriptions.ts b/packages/locales/src/lobehubOnlineModelDescriptions.tsindex f8cd054af89..ec38a4c5825 100644--- a/packages/locales/src/lobehubOnlineModelDescriptions.ts+++ b/packages/locales/src/lobehubOnlineModelDescriptions.ts@@ -66,6 +66,10 @@ export const lobeHubOnlineModelDescriptions = {'Gemini 3.1 Flash Image (Nano Banana 2) delivers Pro-level image quality at Flash speed with multimodal chat support.','lobehub.gemini-3.1-flash-image.description':'Gemini 3.1 Flash Image (Nano Banana 2) delivers Pro-level image quality at Flash speed with multimodal chat support.',+ 'lobehub.gemini-nano-banana-2.1.description':+ 'Successor to Nano Banana 2 at roughly half the per-image price, with sharper text rendering and steadier multi-turn character consistency.',+ 'lobehub.gemini-nano-banana-2.1:image.description':+ 'Successor to Nano Banana 2 at roughly half the per-image price, with sharper text rendering and steadier multi-turn character consistency.','lobehub.gemini-3.1-flash-lite-image:image.description':"Gemini 3.1 Flash Lite Image (Nano Banana 2 Lite) is Google's fastest and most cost-efficient image generation model, built for high-volume generation and editing.",'lobehub.gemini-3.1-flash-lite-image.description':diff --git a/packages/model-runtime/src/providers/google/createImage.test.ts b/packages/model-runtime/src/providers/google/createImage.test.tsindex a9cf2f0eadd..c6cd67f3e6a 100644--- a/packages/model-runtime/src/providers/google/createImage.test.ts+++ b/packages/model-runtime/src/providers/google/createImage.test.ts@@ -413,6 +413,52 @@ describe('createGoogleImage', () => {});});+ it('should return the final image instead of an interim thought image', async () => {+ // Nano Banana 2.1 on Vertex AI returns a draft `thought` image before the final image.+ const mockContentResponse = {+ candidates: [+ {+ content: {+ parts: [+ { inlineData: { data: 'draft-image', mimeType: 'image/png' }, thought: true },+ { inlineData: { data: 'final-image', mimeType: 'image/png' } },+ ],+ },+ },+ ],+ };+ vi.spyOn(mockClient.models, 'generateContent').mockResolvedValue(mockContentResponse as any);++ const result = await createGoogleImage(mockClient, provider, {+ model: 'gemini-nano-banana-2.1:image',+ params: { prompt: 'A red apple' },+ });++ expect(result).toEqual({ imageUrl: 'data:image/png;base64,final-image' });+ });++ it('should fall back to a thought image when no final image is returned', async () => {+ const mockContentResponse = {+ candidates: [+ {+ content: {+ parts: [+ { inlineData: { data: 'draft-image', mimeType: 'image/png' }, thought: true },+ ],+ },+ },+ ],+ };+ vi.spyOn(mockClient.models, 'generateContent').mockResolvedValue(mockContentResponse as any);++ const result = await createGoogleImage(mockClient, provider, {+ model: 'gemini-nano-banana-2.1:image',+ params: { prompt: 'A red apple' },+ });++ expect(result).toEqual({ imageUrl: 'data:image/png;base64,draft-image' });+ });+it('should include text output tokens in successful image usage cost', async () => {// ArrangegetModelPricingMock.mockResolvedValueOnce({diff --git a/packages/model-runtime/src/providers/google/createImage.ts b/packages/model-runtime/src/providers/google/createImage.tsindex 67b535e7536..fe81610d135 100644--- a/packages/model-runtime/src/providers/google/createImage.ts+++ b/packages/model-runtime/src/providers/google/createImage.ts@@ -231,11 +231,13 @@ function extractImageFromResponse(response: GenerateContentResponse): CreateImagthrow createGoogleImageNoImageError('No image generated', response);}- for (const part of candidate.content.parts) {- if (part.inlineData?.data) {- const imageUrl = `data:${part.inlineData.mimeType || 'image/png'};base64,${part.inlineData.data}`;- return { imageUrl };- }+ // Thinking image models (e.g. Nano Banana 2.1 on Vertex AI) return interim draft images as+ // `thought` parts before the final image, so prefer the final one and fall back to a draft.+ const imageParts = candidate.content.parts.filter((part) => part.inlineData?.data);+ const imagePart = imageParts.find((part) => !part.thought) ?? imageParts.at(-1);+ if (imagePart?.inlineData) {+ const imageUrl = `data:${imagePart.inlineData.mimeType || 'image/png'};base64,${imagePart.inlineData.data}`;+ return { imageUrl };}const textFromParts = getTextFromParts(candidate.content.parts);diff --git a/packages/model-runtime/src/providers/google/index.test.ts b/packages/model-runtime/src/providers/google/index.test.tsindex 8f9f818aa4a..4e1818e3f92 100644--- a/packages/model-runtime/src/providers/google/index.test.ts+++ b/packages/model-runtime/src/providers/google/index.test.ts@@ -1451,6 +1451,48 @@ describe('buildGoogleToolsWithSearch', () => {expect(config.toolConfig).toBeUndefined();});+ it('should request image output and image search for Nano Banana 2.1', async () => {+ const mockStream = new ReadableStream({+ start(controller) {+ controller.enqueue({+ candidates: [+ {+ content: { parts: [{ text: 'test' }], role: 'model' },+ finishReason: 'STOP',+ index: 0,+ },+ ],+ usageMetadata: { promptTokenCount: 1, totalTokenCount: 2 },+ modelVersion: 'gemini-nano-banana-2.1',+ });+ controller.close();+ },+ });+ vi.spyOn(instance['client'].models, 'generateContentStream').mockResolvedValue(+ mockStream as any,+ );++ await instance.chat({+ enabledSearch: true,+ imageResolution: '2K',+ messages: [{ content: 'Draw an apple', role: 'user' }],+ model: 'gemini-nano-banana-2.1',+ temperature: 1,+ top_p: 0.9,+ });++ const config = (instance['client'].models.generateContentStream as any).mock.calls[0][0].config;+ // Without the Image modality, Vertex AI answers with IMAGE_RECITATION and no image.+ expect(config.responseModalities).toEqual(['Text', 'Image']);+ expect(config.imageConfig).toEqual({ imageSize: '2K' });+ expect(config.tools).toEqual([+ { googleSearch: { searchTypes: { imageSearch: {}, webSearch: {} } } },+ ]);+ // Nano Banana 2.1 rejects sampling params with an API error.+ expect(config).not.toHaveProperty('temperature');+ expect(config).not.toHaveProperty('topP');+ });+it('should keep image resolution in imageConfig when aspect ratio is auto', async () => {const mockStream = new ReadableStream({start(controller) {diff --git a/packages/model-runtime/src/providers/google/index.ts b/packages/model-runtime/src/providers/google/index.tsindex 081ff9e2421..f533291dc51 100644--- a/packages/model-runtime/src/providers/google/index.ts+++ b/packages/model-runtime/src/providers/google/index.ts@@ -60,6 +60,7 @@ import {shouldDisableGoogleSystemInstruction,shouldDisableGoogleThinkingConfig,shouldOmitDeprecatedGoogleGenerationParams,+ shouldOmitGoogleSamplingParams,shouldUseGoogleImageSearchTypes,supportsGoogleSearchOnImageResponseModel,} from './modelId';@@ -243,7 +244,7 @@ export class LobeGoogleAI implements LobeRuntimeAI {systemInstruction: shouldDisableGoogleSystemInstruction(model)? undefined: (payload.system as string),- ...(shouldOmitDeprecatedGenerationParams+ ...(shouldOmitDeprecatedGenerationParams || shouldOmitGoogleSamplingParams(requestModel)? {}: {temperature: isImageResponseModeldiff --git a/packages/model-runtime/src/providers/google/modelId.test.ts b/packages/model-runtime/src/providers/google/modelId.test.tsindex d19ea52bbb8..1e8a276e5b7 100644--- a/packages/model-runtime/src/providers/google/modelId.test.ts+++ b/packages/model-runtime/src/providers/google/modelId.test.ts@@ -11,6 +11,7 @@ import {shouldDisableGoogleSystemInstruction,shouldDisableGoogleThinkingConfig,shouldOmitDeprecatedGoogleGenerationParams,+ shouldOmitGoogleSamplingParams,shouldUseGoogleImageSearchTypes,supportsGoogleSearchOnImageResponseModel,} from './modelId';@@ -49,6 +50,24 @@ describe('modelId', () => {source: 'googlePrefixed',});});++ it('parses versioned gemini-nano-banana ids as the Nano Banana family', () => {+ expect(parseGoogleModelId('gemini-nano-banana-2.1')).toMatchObject({+ family: 'nanoBanana',+ majorVersion: 2,+ minorVersion: 1,+ modifiers: [],+ normalizedModelId: 'gemini-nano-banana-2.1',+ });+ expect(parseGoogleModelId('gemini-nano-banana-2.1:image')).toMatchObject({+ family: 'nanoBanana',+ majorVersion: 2,+ minorVersion: 1,+ modifiers: ['image'],+ });+ // The Nano Banana product version must not be read as a Gemini version.+ expect(isGemini3OrAbove('gemini-nano-banana-3')).toBe(false);+ });});describe('version helpers', () => {@@ -77,6 +96,16 @@ describe('modelId', () => {])('detects modern generation config requirements for %s', (model, expected) => {expect(shouldOmitDeprecatedGoogleGenerationParams(model)).toBe(expected);});+ it.each([+ ['gemini-nano-banana-2.1', true],+ ['google/gemini-nano-banana-2.1', true],+ ['nano-banana-pro-preview', false],+ ['gemini-2.5-flash-image', false],+ ['gemini-3.1-flash-image', false],+ ['gemini-3.5-flash', false],+ ])('omits unsupported sampling params for %s: %s', (model, expected) => {+ expect(shouldOmitGoogleSamplingParams(model)).toBe(expected);+ });});describe('image response helpers', () => {@@ -96,6 +125,9 @@ describe('modelId', () => {'nano-banana','nano-banana-lite','google/nano-banana-lite',+ // Nano Banana 2.1 uses a `gemini-nano-banana-*` id without the `-image` modifier.+ 'gemini-nano-banana-2.1',+ 'gemini-nano-banana-2.1:image',])('detects image-response model %s', (model) => {expect(isGoogleImageResponseModel(model)).toBe(true);});@@ -108,12 +140,15 @@ describe('modelId', () => {expect(supportsGoogleSearchOnImageResponseModel('gemini-3.5-pro-image-preview')).toBe(true);expect(supportsGoogleSearchOnImageResponseModel('gemini-2.5-flash-image')).toBe(false);expect(supportsGoogleSearchOnImageResponseModel('nano-banana-pro-preview')).toBe(false);+ expect(supportsGoogleSearchOnImageResponseModel('gemini-nano-banana-2.1')).toBe(true);});it('keeps the imageSearch payload exception narrow', () => {expect(shouldUseGoogleImageSearchTypes('gemini-3.1-flash-image')).toBe(true);expect(shouldUseGoogleImageSearchTypes('gemini-3.1-flash-image-preview')).toBe(true);expect(shouldUseGoogleImageSearchTypes('gemini-3.5-pro-image-preview')).toBe(false);+ expect(shouldUseGoogleImageSearchTypes('gemini-nano-banana-2.1')).toBe(true);+ expect(shouldUseGoogleImageSearchTypes('nano-banana-pro-preview')).toBe(false);});});@@ -127,6 +162,8 @@ describe('modelId', () => {'gemini-3.1-flash-image-preview:image','gemini-3.1-flash-lite-image','gemini-3.1-flash-lite-image:image',+ 'gemini-nano-banana-2.1',+ 'gemini-nano-banana-2.1:image',])('detects Nano Banana model %s', (model) => {expect(isGoogleNanoBananaModel(model)).toBe(true);});diff --git a/packages/model-runtime/src/providers/google/modelId.ts b/packages/model-runtime/src/providers/google/modelId.tsindex cb509a915dc..df37fcbb4cb 100644--- a/packages/model-runtime/src/providers/google/modelId.ts+++ b/packages/model-runtime/src/providers/google/modelId.ts@@ -21,6 +21,11 @@ const VERSIONED_GOOGLE_MODEL_PATTERN =const LEGACY_GEMINI_MODEL_PATTERN = /^gemini[-.:]([a-z][a-z0-9]*(?:[-.:][a-z0-9]+)*)/;const LEARNLM_MODEL_PATTERN = /^learnlm[-.:]?([a-z0-9]+(?:[-.:][a-z0-9]+)*)?/;const NANO_BANANA_MODEL_PATTERN = /^nano-banana[-.:]?([a-z0-9]+(?:[-.:][a-z0-9]+)*)?/;+// Nano Banana 2.1 dropped the `gemini-<version>-flash-image` shape for `gemini-nano-banana-2.1`.+// The version is the Nano Banana product version (2 = Gemini 3.1 Flash Image), not a Gemini version.+// https://ai.google.dev/gemini-api/docs/models/gemini-nano-banana-2.1+const GEMINI_NANO_BANANA_MODEL_PATTERN =+ /^gemini-nano-banana(?:[-.:](\d+)(?:\.(\d+))?)?(?:[-.:]([a-z][a-z0-9]*(?:[-.:][a-z0-9]+)*))?/;const SAFETY_OFF_MODELS = new Set(['gemini-2.0-flash-exp']);@@ -142,6 +147,20 @@ export const parseGoogleModelId = (model: string): ParsedGoogleModelId | undefin};}+ const geminiNanoBananaMatch = GEMINI_NANO_BANANA_MODEL_PATTERN.exec(extracted.normalizedModelId);+ if (geminiNanoBananaMatch) {+ const [, majorVersion, minorVersion, modifiers] = geminiNanoBananaMatch;++ return {+ family: 'nanoBanana',+ modifiers: parseModifiers(modifiers),+ normalizedModelId: extracted.normalizedModelId,+ source: extracted.source,+ ...(majorVersion ? { majorVersion: Number(majorVersion) } : {}),+ ...parseMinorVersion(minorVersion),+ };+ }+const legacyGeminiMatch = LEGACY_GEMINI_MODEL_PATTERN.exec(extracted.normalizedModelId);if (legacyGeminiMatch) {const [, modifiers] = legacyGeminiMatch;@@ -258,13 +277,37 @@ export const isGoogleNanoBananaModel = (model: string | undefined): boolean => {return parseGoogleModelId(model)?.family === 'nanoBanana';};+/**+ * Versioned Nano Banana ids (`gemini-nano-banana-2.1`) start at Nano Banana 2, which supports+ * Google Search grounding with both web and image search.+ */+const isVersionedNanoBananaModel = (parsed: ParsedGoogleModelId | undefined): boolean =>+ parsed?.family === 'nanoBanana' && hasVersionAtLeast(parsed, 2);++/**+ * Nano Banana 2.1+ rejects `temperature` / `topP` (and `topK`, `seed`, `logprobs`) with an API error.+ * Kept separate from {@link shouldOmitDeprecatedGoogleGenerationParams}, which also drops+ * `thinkingBudget` and assistant prefills for models that do not need it.+ * @see https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/gemini/nano-banana-2-1+ */+export const shouldOmitGoogleSamplingParams = (model: string): boolean => {+ const parsed = parseGoogleModelId(model);+ return parsed?.family === 'nanoBanana' && hasVersionAtLeast(parsed, 2, 1);+};+export const shouldUseGoogleImageSearchTypes = (model: string): boolean => {const normalizedModelId = normalizeGoogleModelId(model);- return !!normalizedModelId && IMAGE_SEARCH_TYPES_MODELS.has(normalizedModelId);+ if (!normalizedModelId) return false;++ return (+ IMAGE_SEARCH_TYPES_MODELS.has(normalizedModelId) ||+ isVersionedNanoBananaModel(parseGoogleModelId(model))+ );};export const supportsGoogleSearchOnImageResponseModel = (model: string): boolean => {const parsed = parseGoogleModelId(model);+ if (isVersionedNanoBananaModel(parsed)) return true;if (!parsed || parsed.family !== 'gemini') return false;return isGoogleImageResponseModel(model) && hasVersionAtLeast(parsed, 3);diff --git a/packages/model-runtime/src/providers/google/thinkingResolver.test.ts b/packages/model-runtime/src/providers/google/thinkingResolver.test.tsindex 3a712b15c73..761acfaed73 100644--- a/packages/model-runtime/src/providers/google/thinkingResolver.test.ts+++ b/packages/model-runtime/src/providers/google/thinkingResolver.test.ts@@ -107,6 +107,7 @@ describe('thinkingResolver', () => {'gemini-3-pro-image-preview','gemma-4-31b-it','gemma-4-26b-a4b-it',+ 'gemini-nano-banana-2.1',])('should return true for %s', (model) => {expect(isGemini3Model(model)).toBe(true);});@@ -263,6 +264,12 @@ describe('thinkingResolver', () => {});describe('resolveGoogleThinkingConfig', () => {+ it('passes the requested thinkingLevel through for Nano Banana 2.1', () => {+ expect(+ resolveGoogleThinkingConfig('gemini-nano-banana-2.1', { thinkingLevel: 'high' }),+ ).toMatchObject({ thinkingBudget: undefined, thinkingLevel: 'high' });+ });+describe('gemini-pro (legacy unversioned model)', () => {const model = 'gemini-pro';diff --git a/packages/model-runtime/src/providers/google/thinkingResolver.ts b/packages/model-runtime/src/providers/google/thinkingResolver.tsindex 015dd0c0212..f6850271660 100644--- a/packages/model-runtime/src/providers/google/thinkingResolver.ts+++ b/packages/model-runtime/src/providers/google/thinkingResolver.ts@@ -123,7 +123,12 @@ export const isGemini3Model = (model?: string): boolean => {return (isGemini3OrAbove(model) ||- (parsed?.family === 'gemma' && parsed.majorVersion !== undefined && parsed.majorVersion >= 4)+ (parsed?.family === 'gemma' && parsed.majorVersion !== undefined && parsed.majorVersion >= 4) ||+ // Versioned Nano Banana ids (`gemini-nano-banana-2.1`) are Gemini 3 image models that accept+ // `thinkingLevel`, like their `gemini-3.1-flash-image` predecessor.+ (parsed?.family === 'nanoBanana' &&+ parsed.majorVersion !== undefined &&+ parsed.majorVersion >= 2));};diff --git a/packages/model-runtime/src/utils/modelParse.test.ts b/packages/model-runtime/src/utils/modelParse.test.tsindex 14c83b76a52..616b037e0fa 100644--- a/packages/model-runtime/src/utils/modelParse.test.ts+++ b/packages/model-runtime/src/utils/modelParse.test.ts@@ -318,6 +318,24 @@ describe('modelParse', () => {expect(out[0].type).toBe('chat');});+ it('google: Nano Banana ids without "-image-" infer image output and thinking but no function calling', async () => {+ const out = await processModelList(+ [{ id: 'gemini-nano-banana-2.1' }, { id: 'nano-banana-pro-preview' }],+ MODEL_LIST_CONFIGS.google,+ 'google',+ );+ expect(out).toHaveLength(2);+ for (const model of out) {+ expect(model.type).toBe('chat');+ expect(model.imageOutput).toBe(true);+ expect(model.reasoning).toBe(true);+ expect(model.functionCall).toBe(false);+ }+ // Only versioned ids get Google Search at runtime (`supportsGoogleSearchOnImageResponseModel`)+ expect(out.find((m) => m.id === 'gemini-nano-banana-2.1')?.search).toBe(true);+ expect(out.find((m) => m.id === 'nano-banana-pro-preview')?.search).toBe(false);+ });+it('google: gemini-* without "-image-" should not infer imageOutput and get search=true via known google model', async () => {const out = await processModelList([{ id: 'gemini-2.5-pro' }],diff --git a/packages/model-runtime/src/utils/modelParse.ts b/packages/model-runtime/src/utils/modelParse.tsindex 36b1e913318..9cb5da07003 100644--- a/packages/model-runtime/src/utils/modelParse.ts+++ b/packages/model-runtime/src/utils/modelParse.ts@@ -47,10 +47,14 @@ export const MODEL_LIST_CONFIGS = {},google: {excludeKeywords: ['tts'],- functionCallKeywords: ['gemini', '!-image-', 'gemma-4'],- imageOutputKeywords: ['-image-'],- reasoningKeywords: ['thinking', '-2.5-', '!-image-', '-3-', 'gemma-4'],- searchKeywords: ['-search', '!-image-', 'gemma-4'],+ // Nano Banana ids (`gemini-nano-banana-2.1`, `nano-banana-pro-preview`) lack `-image-` but are+ // native image-output models with thinking and no function calling. Search is limited to the+ // versioned `gemini-nano-banana-*` ids, the only aliases the runtime sends Google Search for+ // (`supportsGoogleSearchOnImageResponseModel`).+ functionCallKeywords: ['gemini', '!-image-', '!nano-banana', 'gemma-4'],+ imageOutputKeywords: ['-image-', 'nano-banana'],+ reasoningKeywords: ['thinking', '-2.5-', '!-image-', '-3-', 'gemma-4', 'nano-banana'],+ searchKeywords: ['-search', '!-image-', 'gemma-4', 'gemini-nano-banana'],videoKeywords: ['-2.5-', '!-image-', '-3-'],visionKeywords: ['gemini', 'learnlm', 'gemma-4'],},diff --git a/src/features/Conversation/Messages/AssistantGroup/components/MessageContent.test.tsx b/src/features/Conversation/Messages/AssistantGroup/components/MessageContent.test.tsxindex 75fd4502a17..01a20e36da4 100644--- a/src/features/Conversation/Messages/AssistantGroup/components/MessageContent.test.tsx+++ b/src/features/Conversation/Messages/AssistantGroup/components/MessageContent.test.tsx@@ -9,7 +9,9 @@ import MessageContent from './MessageContent';let mockStoreContent = 'original full content';let mockStoreHasTools = true;-let mockStoreMessage: { createdAt?: number } | undefined = { createdAt: 1000 };+let mockStoreMessage:+ | { createdAt?: number; metadata?: { isMultimodal?: boolean; tempDisplayContent?: string } }+ | undefined = { createdAt: 1000 };vi.mock('@/features/Conversation/Markdown', () => ({default: ({ children, className }: { children?: ReactNode; className?: string }) => (@@ -23,10 +25,21 @@ vi.mock('@/features/Conversation/Messages/components/ContentLoading', () => ({default: ({ id }: { id: string }) => <div data-testid="loading">{id}</div>,}));+vi.mock('@/features/Conversation/Messages/components/RichContentRenderer', () => ({+ RichContentRenderer: ({ parts }: { parts: { image?: string; type: string }[] }) => (+ <div data-testid="rich-content">+ {parts.map((part) =>+ part.type === 'image' ? <img key={part.image} src={part.image} /> : null,+ )}+ </div>+ ),+}));+vi.mock('../../../store', () => ({dataSelectors: {getBlockContent: () => () => mockStoreContent,getBlockHasTools: () => () => mockStoreHasTools,+ getBlockMetadata: () => () => mockStoreMessage?.metadata,getDbMessageById: () => () => mockStoreMessage,},useConversationStore: (selector: (state: unknown) => unknown) => selector({}),@@ -90,4 +103,19 @@ describe('MessageContent', () => {expect(useMarkdownMock).toHaveBeenCalledWith('block-1', true);});++ it('renders multimodal image parts instead of the raw serialized JSON', () => {+ const imageUrl = 'https://example.com/apple.png';+ mockStoreContent = JSON.stringify([{ image: imageUrl, type: 'image' }]);+ mockStoreHasTools = false;+ mockStoreMessage = { createdAt: 1000, metadata: { isMultimodal: true } };++ render(<MessageContent id="block-1" />);++ expect(screen.getByTestId('rich-content').querySelector('img')).toHaveAttribute(+ 'src',+ imageUrl,+ );+ expect(screen.queryByTestId('markdown')).not.toBeInTheDocument();+ });});diff --git a/src/features/Conversation/Messages/AssistantGroup/components/MessageContent.tsx b/src/features/Conversation/Messages/AssistantGroup/components/MessageContent.tsxindex 8a3d75ee749..add535a716a 100644--- a/src/features/Conversation/Messages/AssistantGroup/components/MessageContent.tsx+++ b/src/features/Conversation/Messages/AssistantGroup/components/MessageContent.tsx@@ -1,9 +1,11 @@+import { deserializeParts } from '@lobechat/utils';import { createStaticStyles, cx } from 'antd-style';import { memo } from 'react';import { LOADING_FLAT } from '@/const/message';import MarkdownMessage from '@/features/Conversation/Markdown';import ContentLoading from '@/features/Conversation/Messages/components/ContentLoading';+import { RichContentRenderer } from '@/features/Conversation/Messages/components/RichContentRenderer';import { dataSelectors, useConversationStore } from '../../../store';import { normalizeThinkTags, processWithArtifact } from '../../../utils/markdown';@@ -41,6 +43,16 @@ const MessageContent = memo<MessageContentProps>(const ms = new Date(value).getTime();return Number.isFinite(ms) ? ms : undefined;});+ /**+ * Image-output models (e.g. Nano Banana) persist content as serialized parts.+ * A step block after a tool call still needs to render them as images, not raw JSON.+ */+ const isMultimodal = useConversationStore(+ (s) => !!dataSelectors.getBlockMetadata(id)(s)?.isMultimodal,+ );+ const tempDisplayContent = useConversationStore(+ (s) => dataSelectors.getBlockMetadata(id)(s)?.tempDisplayContent as string | undefined,+ );const message = normalizeThinkTags(processWithArtifact(content ?? ''));// Once a tool call exists below this block's text, the text is already@@ -55,6 +67,10 @@ const MessageContent = memo<MessageContentProps>(return <ContentLoading id={id} startTime={createdAt} />;}+ const contentParts =+ isMultimodal && content ? deserializeParts(tempDisplayContent || content) : null;+ if (contentParts) return <RichContentRenderer parts={contentParts} />;+const isSingleLine = (message || '').split('\n').length <= 2;const isToolSingleLine = hasTools && isSingleLine;diff --git a/src/features/Conversation/store/slices/data/selectors.test.ts b/src/features/Conversation/store/slices/data/selectors.test.tsindex b2ea77ce461..124847503f7 100644--- a/src/features/Conversation/store/slices/data/selectors.test.ts+++ b/src/features/Conversation/store/slices/data/selectors.test.ts@@ -101,3 +101,30 @@ describe('isRefreshingAt', () => {expect(dataSelectors.isRefreshingAt('g2')({} as State)).toBe(false);});});++describe('getBlockMetadata', () => {+ it('resolves metadata of a block nested inside a compressed group', () => {+ const state = stateWith([+ {+ compressedMessages: [+ {+ children: [+ { content: '', id: 'step-1', tools: [] },+ { content: '[]', id: 'step-2', metadata: { isMultimodal: true } },+ ],+ id: 'group-1',+ role: 'assistantGroup',+ },+ ],+ id: 'compressed-1',+ role: 'compressedGroup',+ },+ ]);++ expect(dataSelectors.getBlockMetadata('step-2')(state)).toEqual({ isMultimodal: true });+ });++ it('returns undefined for an unknown block', () => {+ expect(dataSelectors.getBlockMetadata('missing')(stateWith([]))).toBeUndefined();+ });+});diff --git a/src/features/Conversation/store/slices/data/selectors.ts b/src/features/Conversation/store/slices/data/selectors.tsindex e47e25daa9c..26652a1dca6 100644--- a/src/features/Conversation/store/slices/data/selectors.ts+++ b/src/features/Conversation/store/slices/data/selectors.ts@@ -282,6 +282,15 @@ const getBlockContent =(s: State): string | undefined =>findBlockById(blockId, s.displayMessages)?.content;+/**+ * Block metadata from the same recursive lookup as {@link getBlockContent}, so blocks nested in+ * compressed groups or council members resolve too (`getDbMessageById` only sees top-level rows).+ */+const getBlockMetadata =+ (blockId: string) =>+ (s: State): AssistantContentBlock['metadata'] =>+ findBlockById(blockId, s.displayMessages)?.metadata;+const getBlockHasTools =(blockId: string) =>(s: State): boolean => {@@ -328,6 +337,7 @@ export const dataSelectors = {getDbMessageById,getDbMessageByToolCallId,getBlockContent,+ getBlockMetadata,getBlockHasTools,getDisplayMessageById,getGroupLatestMessageWithoutTools,