diff --git a/packages/agent-core/src/mastra/system-prompt.ts b/packages/agent-core/src/mastra/system-prompt.ts index a4ca627d..d7d19a32 100644 --- a/packages/agent-core/src/mastra/system-prompt.ts +++ b/packages/agent-core/src/mastra/system-prompt.ts @@ -233,7 +233,7 @@ Load the generate-media skill before creating or editing an image or generating const RESEARCH_MODULE = `## Research -Gather sources with search_web / search_web_advanced / search_company / search_web_content, then use search_scrape or search_extract for source retrieval. For an explicit deep-research request, cited report, market analysis, due diligence, or comprehensive investigation of one topic, use research_deep with 3 queries for a concise/narrow report, 4 by default, and 5-6 only when the user explicitly asks for deeper coverage. Use research_fanout when the request compares many entities or independent angles. Call the selected research workflow once per user request; if it fails, explain the failure instead of immediately rerunning it. Those workflows produce the complete cited PDF deliverable automatically, so do not regenerate it with a document tool. After a research workflow succeeds, present its returned report Markdown as the response body without summarizing, restructuring, or appending hidden claim-map data; the PDF is rendered from that same Markdown. Treat search snippets as leads, not sources — open the real pages and cross-check. Cite as you go: attribute each claim to its source inline with the page title and its URL, and make sure every citation resolves. End a research answer with a short Sources list of the URLs you actually used.`; +Gather sources with search_web / search_web_advanced / search_company / search_web_content, then use search_scrape or search_extract for source retrieval. For an explicit deep-research request, cited report, market analysis, due diligence, or comprehensive investigation of one topic, use research_deep with 3 queries for a concise/narrow report, 4 by default, and 5-6 only when the user explicitly asks for deeper coverage. A comparison of a few sources, standards, or recommendations within one topic still uses research_deep. Reserve research_fanout for four or more independent entities or genuinely separate angles, and pass entities as an array of separate short names. Call the selected research workflow once per user request; if it fails, explain the failure instead of immediately rerunning it. Those workflows produce the complete cited PDF deliverable automatically, so do not regenerate it with a document tool. After a research workflow succeeds, present its returned report Markdown as the response body without summarizing, restructuring, or appending hidden claim-map data; the PDF is rendered from that same Markdown. Treat search snippets as leads, not sources — open the real pages and cross-check. Cite as you go: attribute each claim to its source inline with the page title and its URL, and make sure every citation resolves. End a research answer with a short Sources list of the URLs you actually used.`; /** Compact all-domains pointer for an ambiguous general request — keeps the model aware without the full modules. */ const GENERALIST_MODULE = `## Choosing your approach diff --git a/packages/agent-core/src/mastra/tool-defs/research-tools.ts b/packages/agent-core/src/mastra/tool-defs/research-tools.ts index 4fbbe188..74e7f7ab 100644 --- a/packages/agent-core/src/mastra/tool-defs/research-tools.ts +++ b/packages/agent-core/src/mastra/tool-defs/research-tools.ts @@ -279,7 +279,7 @@ export const mastraDeepResearch = createTool({ export const mastraResearchFanout = createTool({ id: "research_fanout", description: - "Run the Deep Research fan-out workflow across multiple entities or angles. It returns a cited comparison report and saves the complete report as a PDF deliverable in the project.", + "Run Deep Research across four or more independent entities or genuinely separate angles. Pass entities as an array of separate short names. For comparisons of a few sources or standards within one topic, use research_deep. The workflow returns a cited comparison report and saves the complete report as a PDF deliverable in the project.", inputSchema: DeepResearchFanoutInputSchema, outputSchema: ResearchReportArtifactSchema, execute: async (input, context) => { diff --git a/packages/agent-core/src/mastra/workflows/research-schemas.ts b/packages/agent-core/src/mastra/workflows/research-schemas.ts index c1d7573a..16fb46c2 100644 --- a/packages/agent-core/src/mastra/workflows/research-schemas.ts +++ b/packages/agent-core/src/mastra/workflows/research-schemas.ts @@ -41,7 +41,7 @@ export const ResearchReportSchema = z.strictObject({ }); export const ResearchQuerySchema = z.strictObject({ - query: z.string().trim().min(1).max(2_000), + query: z.string().trim().min(1).max(1_000), }); export const DeepResearchInputSchema = z.strictObject({ @@ -65,7 +65,14 @@ export const DeepResearchInputSchema = z.strictObject({ }); export const DeepResearchFanoutInputSchema = z.strictObject({ - entities: z.array(z.string().trim().min(1).max(200)).min(1).max(12).optional(), + entities: z + .array(z.string().trim().min(1).max(200)) + .min(1) + .max(12) + .optional() + .describe( + "Optional array of separate short entity names; never combine entities into one string.", + ), goal: z.string().trim().min(1).max(2_000), maxQueries: z.number().int().min(1).max(12).default(10), }); diff --git a/packages/agent-core/src/mastra/workflows/research-support.ts b/packages/agent-core/src/mastra/workflows/research-support.ts index a4de2e95..f0769cf4 100644 --- a/packages/agent-core/src/mastra/workflows/research-support.ts +++ b/packages/agent-core/src/mastra/workflows/research-support.ts @@ -1,4 +1,4 @@ -const MAX_RESEARCH_QUERY_CHARACTERS = 2_000; +const MAX_RESEARCH_QUERY_CHARACTERS = 1_000; export function buildDeepResearchQueries( topic: string,