MCPcopy Index your code
hub / github.com/simstudioai/sim / executeDeepResearchRequest

Function executeDeepResearchRequest

apps/sim/providers/gemini/core.ts:657–888  ·  view source on GitHub ↗
(
  config: GeminiExecutionConfig
)

Source from the content-addressed store, hash-verified

655 * or structured output (response_format). These are gracefully ignored.
656 */
657export async function executeDeepResearchRequest(
658 config: GeminiExecutionConfig
659): Promise<ProviderResponse | StreamingExecution> {
660 const { ai, model, request, providerType } = config
661 const logger = createLogger(providerType === 'google' ? 'GoogleProvider' : 'VertexProvider')
662
663 logger.info('Preparing deep research request', {
664 model,
665 hasSystemPrompt: !!request.systemPrompt,
666 hasMessages: !!request.messages?.length,
667 streaming: !!request.stream,
668 hasPreviousInteractionId: !!request.previousInteractionId,
669 })
670
671 if (request.tools?.length) {
672 logger.warn('Deep research does not support custom tools — ignoring tools parameter')
673 }
674 if (request.responseFormat) {
675 logger.warn(
676 'Deep research does not support structured output — ignoring responseFormat parameter'
677 )
678 }
679
680 const providerStartTime = Date.now()
681 const providerStartTimeISO = new Date(providerStartTime).toISOString()
682
683 try {
684 const { input, systemInstruction } = collapseMessagesToInput(request)
685
686 // Deep research requires background=true and store=true (store defaults to true,
687 // but we set it explicitly per API requirements)
688 const baseParams = {
689 agent: model as Interactions.CreateAgentInteractionParamsNonStreaming['agent'],
690 input,
691 background: true,
692 store: true,
693 ...(systemInstruction && { system_instruction: systemInstruction }),
694 ...(request.previousInteractionId && {
695 previous_interaction_id: request.previousInteractionId,
696 }),
697 agent_config: {
698 type: 'deep-research' as const,
699 thinking_summaries: 'auto' as const,
700 },
701 }
702
703 logger.info('Creating deep research interaction', {
704 inputLength: input.length,
705 hasSystemInstruction: !!systemInstruction,
706 streaming: !!request.stream,
707 })
708
709 // Streaming mode: create a streaming interaction and return a StreamingExecution
710 if (request.stream) {
711 const streamParams: Interactions.CreateAgentInteractionParamsStreaming = {
712 ...baseParams,
713 stream: true,
714 }

Callers 1

executeGeminiRequestFunction · 0.85

Calls 13

createLoggerFunction · 0.90
calculateCostFunction · 0.90
toErrorFunction · 0.90
collapseMessagesToInputFunction · 0.85
createDeepResearchStreamFunction · 0.85
extractInteractionUsageFunction · 0.85
infoMethod · 0.80
errorMethod · 0.80
sleepFunction · 0.70
warnMethod · 0.65

Tested by

no test coverage detected