( config: GeminiExecutionConfig )
| 655 | * or structured output (response_format). These are gracefully ignored. |
| 656 | */ |
| 657 | export 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 | } |
no test coverage detected