Skip to content

🤯 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.

🐛 fix: flatten visual analysis tool schema (#14550)

YuTengjingcef69e9b7273
diff --git a/packages/builtin-tool-lobe-agent/src/manifest.test.ts b/packages/builtin-tool-lobe-agent/src/manifest.test.ts
index d3080933972..54cdce2c2ff 100644
--- a/packages/builtin-tool-lobe-agent/src/manifest.test.ts
+++ b/packages/builtin-tool-lobe-agent/src/manifest.test.ts
@@ -16,8 +16,18 @@ describe('LobeAgentManifest', () => {
expect(apiDescription).toContain('native multimodal capability');
expect(apiDescription).toContain('use this tool only as a fallback');
+ expect(apiDescription).toContain('Provide either refs or urls');
+ expect(apiDescription).toContain('Prefer refs when stable refs are available');
expect(apiDescription).toContain('msg_xxx.image_1');
- expect(apiDescription).toContain('Use only stable refs');
+ expect(apiDescription).toContain('use urls only for direct media URLs');
expect(apiDescription).toContain('answer the user directly with the result');
});
+
+ it('should keep visual analysis parameters compatible with strict tool schema validators', () => {
+ const parameters = LobeAgentManifest.api[0].parameters;
+
+ expect(parameters).not.toHaveProperty('oneOf');
+ expect(parameters).not.toHaveProperty('allOf');
+ expect(parameters).not.toHaveProperty('anyOf');
+ });
});
diff --git a/packages/builtin-tool-lobe-agent/src/manifest.ts b/packages/builtin-tool-lobe-agent/src/manifest.ts
index e8662a93f6e..95a13b24551 100644
--- a/packages/builtin-tool-lobe-agent/src/manifest.ts
+++ b/packages/builtin-tool-lobe-agent/src/manifest.ts
@@ -7,11 +7,10 @@ export const LobeAgentManifest: BuiltinToolManifest = {
api: [
{
description:
- "Analyze images or videos selected by visual file refs or direct media URLs and answer a visual question. Prefer the active model's native multimodal capability when it can inspect the visual media directly; use this tool only as a fallback when the active model cannot inspect the requested images or videos. Use only stable refs shown in <files_info>, such as msg_xxx.image_1 or msg_xxx.video_1. Pass refs for message attachments, or urls for direct media URLs that are not available as message refs. After this tool returns, answer the user directly with the result.",
+ "Analyze images or videos selected by visual file refs or direct media URLs and answer a visual question. Prefer the active model's native multimodal capability when it can inspect the visual media directly; use this tool only as a fallback when the active model cannot inspect the requested images or videos. Provide either refs or urls; at least one is required. Prefer refs when stable refs are available in <files_info>, such as msg_xxx.image_1 or msg_xxx.video_1, and use urls only for direct media URLs that are not available as message refs. After this tool returns, answer the user directly with the result.",
name: LobeAgentApiName.analyzeVisualMedia,
parameters: {
additionalProperties: false,
- anyOf: [{ required: ['refs'] }, { required: ['urls'] }],
properties: {
question: {
description: 'The visual question or task to answer.',
diff --git a/src/helpers/toolEngineering/index.test.ts b/src/helpers/toolEngineering/index.test.ts
index 4f41a39c320..2f47854d7c8 100644
--- a/src/helpers/toolEngineering/index.test.ts
+++ b/src/helpers/toolEngineering/index.test.ts
@@ -67,7 +67,6 @@ vi.mock('@/store/tool', () => ({
description: 'Analyze visual media',
name: 'analyzeVisualMedia',
parameters: {
- anyOf: [{ required: ['refs'] }, { required: ['urls'] }],
properties: {
question: { type: 'string' },
refs: {