@inkeep/agents-run-api 0.0.0-dev-20251222083114 → 0.0.0-dev-20251222193816

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -4910,6 +4910,58 @@ function getCompressionConfigForModel(modelSettings) {
4910
4910
  }
4911
4911
  }
4912
4912
 
4913
+ //#endregion
4914
+ //#region src/utils/token-estimator.ts
4915
+ /**
4916
+ * Token estimation utility for context tracking.
4917
+ *
4918
+ * Uses character-based approximation (~4 characters per token) which:
4919
+ * - Works universally for all models (OpenAI, Anthropic, Gemini, custom)
4920
+ * - Requires no external dependencies
4921
+ * - Is fast (simple string length calculation)
4922
+ * - Is accurate enough for relative comparisons between context components
4923
+ */
4924
+ const CHARS_PER_TOKEN = 4;
4925
+ /**
4926
+ * Creates an empty context breakdown with all values set to 0.
4927
+ */
4928
+ function createEmptyBreakdown() {
4929
+ return {
4930
+ systemPromptTemplate: 0,
4931
+ coreInstructions: 0,
4932
+ agentPrompt: 0,
4933
+ toolsSection: 0,
4934
+ artifactsSection: 0,
4935
+ dataComponents: 0,
4936
+ artifactComponents: 0,
4937
+ transferInstructions: 0,
4938
+ delegationInstructions: 0,
4939
+ thinkingPreparation: 0,
4940
+ conversationHistory: 0,
4941
+ total: 0
4942
+ };
4943
+ }
4944
+ /**
4945
+ * Estimates the number of tokens in a text string using character-based approximation.
4946
+ *
4947
+ * @param text - The text to estimate tokens for
4948
+ * @returns Estimated token count (approximately text.length / 4)
4949
+ */
4950
+ function estimateTokens(text) {
4951
+ if (!text) return 0;
4952
+ return Math.ceil(text.length / CHARS_PER_TOKEN);
4953
+ }
4954
+ /**
4955
+ * Calculates the total from all breakdown components and updates the total field.
4956
+ *
4957
+ * @param breakdown - The context breakdown to calculate total for
4958
+ * @returns The breakdown with updated total
4959
+ */
4960
+ function calculateBreakdownTotal(breakdown) {
4961
+ breakdown.total = breakdown.systemPromptTemplate + breakdown.coreInstructions + breakdown.agentPrompt + breakdown.toolsSection + breakdown.artifactsSection + breakdown.dataComponents + breakdown.artifactComponents + breakdown.transferInstructions + breakdown.delegationInstructions + breakdown.thinkingPreparation + breakdown.conversationHistory;
4962
+ return breakdown;
4963
+ }
4964
+
4913
4965
  //#endregion
4914
4966
  //#region src/a2a/client.ts
4915
4967
  const logger$12 = (0, __inkeep_agents_core.getLogger)("a2aClient");
@@ -5691,6 +5743,9 @@ var SystemPromptBuilder = class {
5691
5743
  throw new Error(`Template loading failed: ${error}`);
5692
5744
  }
5693
5745
  }
5746
+ /**
5747
+ * Build the system prompt and return both the prompt string and token breakdown
5748
+ */
5694
5749
  buildSystemPrompt(config) {
5695
5750
  this.loadTemplates();
5696
5751
  this.validateTemplateVariables(config);
@@ -5767,12 +5822,17 @@ var Phase1Config = class Phase1Config {
5767
5822
  return inputSchema;
5768
5823
  }
5769
5824
  assemble(templates, config) {
5770
- const systemPromptTemplate = templates.get("system-prompt");
5771
- if (!systemPromptTemplate) throw new Error("System prompt template not loaded");
5772
- let systemPrompt = systemPromptTemplate;
5773
- if (config.corePrompt && config.corePrompt.trim()) systemPrompt = systemPrompt.replace("{{CORE_INSTRUCTIONS}}", config.corePrompt);
5774
- else systemPrompt = systemPrompt.replace(/<core_instructions>\s*\{\{CORE_INSTRUCTIONS\}\}\s*<\/core_instructions>/g, "");
5825
+ const breakdown = createEmptyBreakdown();
5826
+ const systemPromptTemplateContent = templates.get("system-prompt");
5827
+ if (!systemPromptTemplateContent) throw new Error("System prompt template not loaded");
5828
+ breakdown.systemPromptTemplate = estimateTokens(systemPromptTemplateContent.replace("{{CORE_INSTRUCTIONS}}", "").replace("{{AGENT_CONTEXT_SECTION}}", "").replace("{{ARTIFACTS_SECTION}}", "").replace("{{TOOLS_SECTION}}", "").replace("{{THINKING_PREPARATION_INSTRUCTIONS}}", "").replace("{{TRANSFER_INSTRUCTIONS}}", "").replace("{{DELEGATION_INSTRUCTIONS}}", ""));
5829
+ let systemPrompt = systemPromptTemplateContent;
5830
+ if (config.corePrompt && config.corePrompt.trim()) {
5831
+ breakdown.coreInstructions = estimateTokens(config.corePrompt);
5832
+ systemPrompt = systemPrompt.replace("{{CORE_INSTRUCTIONS}}", config.corePrompt);
5833
+ } else systemPrompt = systemPrompt.replace(/<core_instructions>\s*\{\{CORE_INSTRUCTIONS\}\}\s*<\/core_instructions>/g, "");
5775
5834
  const agentContextSection = this.generateAgentContextSection(config.prompt);
5835
+ breakdown.agentPrompt = estimateTokens(agentContextSection);
5776
5836
  systemPrompt = systemPrompt.replace("{{AGENT_CONTEXT_SECTION}}", agentContextSection);
5777
5837
  const toolData = (this.isToolDataArray(config.tools) ? config.tools : Phase1Config.convertMcpToolsToToolData(config.tools)).map((tool$2) => ({
5778
5838
  ...tool$2,
@@ -5780,16 +5840,26 @@ var Phase1Config = class Phase1Config {
5780
5840
  }));
5781
5841
  const hasArtifactComponents = config.artifactComponents && config.artifactComponents.length > 0;
5782
5842
  const artifactsSection = this.generateArtifactsSection(templates, config.artifacts, hasArtifactComponents, config.artifactComponents, config.hasAgentArtifactComponents);
5843
+ breakdown.artifactsSection = estimateTokens(artifactsSection);
5844
+ if (hasArtifactComponents) breakdown.artifactComponents = estimateTokens(this.getArtifactCreationInstructions(hasArtifactComponents, config.artifactComponents));
5783
5845
  systemPrompt = systemPrompt.replace("{{ARTIFACTS_SECTION}}", artifactsSection);
5784
5846
  const toolsSection = this.generateToolsSection(templates, toolData);
5847
+ breakdown.toolsSection = estimateTokens(toolsSection);
5785
5848
  systemPrompt = systemPrompt.replace("{{TOOLS_SECTION}}", toolsSection);
5786
5849
  const thinkingPreparationSection = this.generateThinkingPreparationSection(templates, config.isThinkingPreparation);
5850
+ breakdown.thinkingPreparation = estimateTokens(thinkingPreparationSection);
5787
5851
  systemPrompt = systemPrompt.replace("{{THINKING_PREPARATION_INSTRUCTIONS}}", thinkingPreparationSection);
5788
5852
  const transferSection = this.generateTransferInstructions(config.hasTransferRelations);
5853
+ breakdown.transferInstructions = estimateTokens(transferSection);
5789
5854
  systemPrompt = systemPrompt.replace("{{TRANSFER_INSTRUCTIONS}}", transferSection);
5790
5855
  const delegationSection = this.generateDelegationInstructions(config.hasDelegateRelations);
5856
+ breakdown.delegationInstructions = estimateTokens(delegationSection);
5791
5857
  systemPrompt = systemPrompt.replace("{{DELEGATION_INSTRUCTIONS}}", delegationSection);
5792
- return systemPrompt;
5858
+ calculateBreakdownTotal(breakdown);
5859
+ return {
5860
+ prompt: systemPrompt,
5861
+ breakdown
5862
+ };
5793
5863
  }
5794
5864
  generateAgentContextSection(prompt) {
5795
5865
  if (!prompt || prompt.trim() === "") return "";
@@ -6612,16 +6682,16 @@ var Agent = class {
6612
6682
  */
6613
6683
  simpleCompression(messages, targetTokens) {
6614
6684
  if (messages.length === 0) return messages;
6615
- const estimateTokens = (msg) => {
6685
+ const estimateTokens$1 = (msg) => {
6616
6686
  const content = typeof msg.content === "string" ? msg.content : JSON.stringify(msg.content);
6617
6687
  return Math.ceil(content.length / 4);
6618
6688
  };
6619
- let totalTokens = messages.reduce((sum, msg) => sum + estimateTokens(msg), 0);
6689
+ let totalTokens = messages.reduce((sum, msg) => sum + estimateTokens$1(msg), 0);
6620
6690
  if (totalTokens <= targetTokens) return messages;
6621
6691
  const result = [...messages];
6622
6692
  while (totalTokens > targetTokens && result.length > 1) {
6623
6693
  const dropped = result.shift();
6624
- if (dropped) totalTokens -= estimateTokens(dropped);
6694
+ if (dropped) totalTokens -= estimateTokens$1(dropped);
6625
6695
  }
6626
6696
  return result;
6627
6697
  }
@@ -7753,7 +7823,7 @@ ${typeof cleanResult === "string" ? cleanResult : JSON.stringify(cleanResult, nu
7753
7823
  if (streamRequestId && this.artifactComponents.length > 0) agentSessionManager.updateArtifactComponents(streamRequestId, this.artifactComponents);
7754
7824
  const conversationId = runtimeContext?.metadata?.conversationId;
7755
7825
  if (conversationId) this.setConversationId(conversationId);
7756
- const [mcpTools, systemPrompt, thinkingSystemPrompt, functionTools, relationTools, defaultTools] = await tracer.startActiveSpan("agent.load_tools", { attributes: {
7826
+ const [mcpTools, systemPromptResult, thinkingSystemPromptResult, functionTools, relationTools, defaultTools] = await tracer.startActiveSpan("agent.load_tools", { attributes: {
7757
7827
  "subAgent.name": this.config.name,
7758
7828
  "session.id": sessionId || "none"
7759
7829
  } }, async (childSpan) => {
@@ -7775,6 +7845,9 @@ ${typeof cleanResult === "string" ? cleanResult : JSON.stringify(cleanResult, nu
7775
7845
  childSpan.end();
7776
7846
  }
7777
7847
  });
7848
+ const systemPrompt = systemPromptResult.prompt;
7849
+ const thinkingSystemPrompt = thinkingSystemPromptResult.prompt;
7850
+ const contextBreakdown = systemPromptResult.breakdown;
7778
7851
  const allTools = {
7779
7852
  ...mcpTools,
7780
7853
  ...functionTools,
@@ -7812,6 +7885,22 @@ ${typeof cleanResult === "string" ? cleanResult : JSON.stringify(cleanResult, nu
7812
7885
  }
7813
7886
  });
7814
7887
  }
7888
+ contextBreakdown.conversationHistory = estimateTokens(conversationHistory);
7889
+ calculateBreakdownTotal(contextBreakdown);
7890
+ span.setAttributes({
7891
+ "context.breakdown.system_template_tokens": contextBreakdown.systemPromptTemplate,
7892
+ "context.breakdown.core_instructions_tokens": contextBreakdown.coreInstructions,
7893
+ "context.breakdown.agent_prompt_tokens": contextBreakdown.agentPrompt,
7894
+ "context.breakdown.tools_tokens": contextBreakdown.toolsSection,
7895
+ "context.breakdown.artifacts_tokens": contextBreakdown.artifactsSection,
7896
+ "context.breakdown.data_components_tokens": contextBreakdown.dataComponents,
7897
+ "context.breakdown.artifact_components_tokens": contextBreakdown.artifactComponents,
7898
+ "context.breakdown.transfer_instructions_tokens": contextBreakdown.transferInstructions,
7899
+ "context.breakdown.delegation_instructions_tokens": contextBreakdown.delegationInstructions,
7900
+ "context.breakdown.thinking_preparation_tokens": contextBreakdown.thinkingPreparation,
7901
+ "context.breakdown.conversation_history_tokens": contextBreakdown.conversationHistory,
7902
+ "context.breakdown.total_tokens": contextBreakdown.total
7903
+ });
7815
7904
  const primaryModelSettings = this.getPrimaryModel();
7816
7905
  const modelSettings = __inkeep_agents_core.ModelFactory.prepareGenerationConfig(primaryModelSettings);
7817
7906
  let response;
package/dist/index.js CHANGED
@@ -4906,6 +4906,58 @@ function getCompressionConfigForModel(modelSettings) {
4906
4906
  }
4907
4907
  }
4908
4908
 
4909
+ //#endregion
4910
+ //#region src/utils/token-estimator.ts
4911
+ /**
4912
+ * Token estimation utility for context tracking.
4913
+ *
4914
+ * Uses character-based approximation (~4 characters per token) which:
4915
+ * - Works universally for all models (OpenAI, Anthropic, Gemini, custom)
4916
+ * - Requires no external dependencies
4917
+ * - Is fast (simple string length calculation)
4918
+ * - Is accurate enough for relative comparisons between context components
4919
+ */
4920
+ const CHARS_PER_TOKEN = 4;
4921
+ /**
4922
+ * Creates an empty context breakdown with all values set to 0.
4923
+ */
4924
+ function createEmptyBreakdown() {
4925
+ return {
4926
+ systemPromptTemplate: 0,
4927
+ coreInstructions: 0,
4928
+ agentPrompt: 0,
4929
+ toolsSection: 0,
4930
+ artifactsSection: 0,
4931
+ dataComponents: 0,
4932
+ artifactComponents: 0,
4933
+ transferInstructions: 0,
4934
+ delegationInstructions: 0,
4935
+ thinkingPreparation: 0,
4936
+ conversationHistory: 0,
4937
+ total: 0
4938
+ };
4939
+ }
4940
+ /**
4941
+ * Estimates the number of tokens in a text string using character-based approximation.
4942
+ *
4943
+ * @param text - The text to estimate tokens for
4944
+ * @returns Estimated token count (approximately text.length / 4)
4945
+ */
4946
+ function estimateTokens(text) {
4947
+ if (!text) return 0;
4948
+ return Math.ceil(text.length / CHARS_PER_TOKEN);
4949
+ }
4950
+ /**
4951
+ * Calculates the total from all breakdown components and updates the total field.
4952
+ *
4953
+ * @param breakdown - The context breakdown to calculate total for
4954
+ * @returns The breakdown with updated total
4955
+ */
4956
+ function calculateBreakdownTotal(breakdown) {
4957
+ breakdown.total = breakdown.systemPromptTemplate + breakdown.coreInstructions + breakdown.agentPrompt + breakdown.toolsSection + breakdown.artifactsSection + breakdown.dataComponents + breakdown.artifactComponents + breakdown.transferInstructions + breakdown.delegationInstructions + breakdown.thinkingPreparation + breakdown.conversationHistory;
4958
+ return breakdown;
4959
+ }
4960
+
4909
4961
  //#endregion
4910
4962
  //#region src/a2a/client.ts
4911
4963
  const logger$12 = getLogger("a2aClient");
@@ -5687,6 +5739,9 @@ var SystemPromptBuilder = class {
5687
5739
  throw new Error(`Template loading failed: ${error}`);
5688
5740
  }
5689
5741
  }
5742
+ /**
5743
+ * Build the system prompt and return both the prompt string and token breakdown
5744
+ */
5690
5745
  buildSystemPrompt(config) {
5691
5746
  this.loadTemplates();
5692
5747
  this.validateTemplateVariables(config);
@@ -5763,12 +5818,17 @@ var Phase1Config = class Phase1Config {
5763
5818
  return inputSchema;
5764
5819
  }
5765
5820
  assemble(templates, config) {
5766
- const systemPromptTemplate = templates.get("system-prompt");
5767
- if (!systemPromptTemplate) throw new Error("System prompt template not loaded");
5768
- let systemPrompt = systemPromptTemplate;
5769
- if (config.corePrompt && config.corePrompt.trim()) systemPrompt = systemPrompt.replace("{{CORE_INSTRUCTIONS}}", config.corePrompt);
5770
- else systemPrompt = systemPrompt.replace(/<core_instructions>\s*\{\{CORE_INSTRUCTIONS\}\}\s*<\/core_instructions>/g, "");
5821
+ const breakdown = createEmptyBreakdown();
5822
+ const systemPromptTemplateContent = templates.get("system-prompt");
5823
+ if (!systemPromptTemplateContent) throw new Error("System prompt template not loaded");
5824
+ breakdown.systemPromptTemplate = estimateTokens(systemPromptTemplateContent.replace("{{CORE_INSTRUCTIONS}}", "").replace("{{AGENT_CONTEXT_SECTION}}", "").replace("{{ARTIFACTS_SECTION}}", "").replace("{{TOOLS_SECTION}}", "").replace("{{THINKING_PREPARATION_INSTRUCTIONS}}", "").replace("{{TRANSFER_INSTRUCTIONS}}", "").replace("{{DELEGATION_INSTRUCTIONS}}", ""));
5825
+ let systemPrompt = systemPromptTemplateContent;
5826
+ if (config.corePrompt && config.corePrompt.trim()) {
5827
+ breakdown.coreInstructions = estimateTokens(config.corePrompt);
5828
+ systemPrompt = systemPrompt.replace("{{CORE_INSTRUCTIONS}}", config.corePrompt);
5829
+ } else systemPrompt = systemPrompt.replace(/<core_instructions>\s*\{\{CORE_INSTRUCTIONS\}\}\s*<\/core_instructions>/g, "");
5771
5830
  const agentContextSection = this.generateAgentContextSection(config.prompt);
5831
+ breakdown.agentPrompt = estimateTokens(agentContextSection);
5772
5832
  systemPrompt = systemPrompt.replace("{{AGENT_CONTEXT_SECTION}}", agentContextSection);
5773
5833
  const toolData = (this.isToolDataArray(config.tools) ? config.tools : Phase1Config.convertMcpToolsToToolData(config.tools)).map((tool$1) => ({
5774
5834
  ...tool$1,
@@ -5776,16 +5836,26 @@ var Phase1Config = class Phase1Config {
5776
5836
  }));
5777
5837
  const hasArtifactComponents = config.artifactComponents && config.artifactComponents.length > 0;
5778
5838
  const artifactsSection = this.generateArtifactsSection(templates, config.artifacts, hasArtifactComponents, config.artifactComponents, config.hasAgentArtifactComponents);
5839
+ breakdown.artifactsSection = estimateTokens(artifactsSection);
5840
+ if (hasArtifactComponents) breakdown.artifactComponents = estimateTokens(this.getArtifactCreationInstructions(hasArtifactComponents, config.artifactComponents));
5779
5841
  systemPrompt = systemPrompt.replace("{{ARTIFACTS_SECTION}}", artifactsSection);
5780
5842
  const toolsSection = this.generateToolsSection(templates, toolData);
5843
+ breakdown.toolsSection = estimateTokens(toolsSection);
5781
5844
  systemPrompt = systemPrompt.replace("{{TOOLS_SECTION}}", toolsSection);
5782
5845
  const thinkingPreparationSection = this.generateThinkingPreparationSection(templates, config.isThinkingPreparation);
5846
+ breakdown.thinkingPreparation = estimateTokens(thinkingPreparationSection);
5783
5847
  systemPrompt = systemPrompt.replace("{{THINKING_PREPARATION_INSTRUCTIONS}}", thinkingPreparationSection);
5784
5848
  const transferSection = this.generateTransferInstructions(config.hasTransferRelations);
5849
+ breakdown.transferInstructions = estimateTokens(transferSection);
5785
5850
  systemPrompt = systemPrompt.replace("{{TRANSFER_INSTRUCTIONS}}", transferSection);
5786
5851
  const delegationSection = this.generateDelegationInstructions(config.hasDelegateRelations);
5852
+ breakdown.delegationInstructions = estimateTokens(delegationSection);
5787
5853
  systemPrompt = systemPrompt.replace("{{DELEGATION_INSTRUCTIONS}}", delegationSection);
5788
- return systemPrompt;
5854
+ calculateBreakdownTotal(breakdown);
5855
+ return {
5856
+ prompt: systemPrompt,
5857
+ breakdown
5858
+ };
5789
5859
  }
5790
5860
  generateAgentContextSection(prompt) {
5791
5861
  if (!prompt || prompt.trim() === "") return "";
@@ -6608,16 +6678,16 @@ var Agent = class {
6608
6678
  */
6609
6679
  simpleCompression(messages, targetTokens) {
6610
6680
  if (messages.length === 0) return messages;
6611
- const estimateTokens = (msg) => {
6681
+ const estimateTokens$1 = (msg) => {
6612
6682
  const content = typeof msg.content === "string" ? msg.content : JSON.stringify(msg.content);
6613
6683
  return Math.ceil(content.length / 4);
6614
6684
  };
6615
- let totalTokens = messages.reduce((sum, msg) => sum + estimateTokens(msg), 0);
6685
+ let totalTokens = messages.reduce((sum, msg) => sum + estimateTokens$1(msg), 0);
6616
6686
  if (totalTokens <= targetTokens) return messages;
6617
6687
  const result = [...messages];
6618
6688
  while (totalTokens > targetTokens && result.length > 1) {
6619
6689
  const dropped = result.shift();
6620
- if (dropped) totalTokens -= estimateTokens(dropped);
6690
+ if (dropped) totalTokens -= estimateTokens$1(dropped);
6621
6691
  }
6622
6692
  return result;
6623
6693
  }
@@ -7749,7 +7819,7 @@ ${typeof cleanResult === "string" ? cleanResult : JSON.stringify(cleanResult, nu
7749
7819
  if (streamRequestId && this.artifactComponents.length > 0) agentSessionManager.updateArtifactComponents(streamRequestId, this.artifactComponents);
7750
7820
  const conversationId = runtimeContext?.metadata?.conversationId;
7751
7821
  if (conversationId) this.setConversationId(conversationId);
7752
- const [mcpTools, systemPrompt, thinkingSystemPrompt, functionTools, relationTools, defaultTools] = await tracer.startActiveSpan("agent.load_tools", { attributes: {
7822
+ const [mcpTools, systemPromptResult, thinkingSystemPromptResult, functionTools, relationTools, defaultTools] = await tracer.startActiveSpan("agent.load_tools", { attributes: {
7753
7823
  "subAgent.name": this.config.name,
7754
7824
  "session.id": sessionId || "none"
7755
7825
  } }, async (childSpan) => {
@@ -7771,6 +7841,9 @@ ${typeof cleanResult === "string" ? cleanResult : JSON.stringify(cleanResult, nu
7771
7841
  childSpan.end();
7772
7842
  }
7773
7843
  });
7844
+ const systemPrompt = systemPromptResult.prompt;
7845
+ const thinkingSystemPrompt = thinkingSystemPromptResult.prompt;
7846
+ const contextBreakdown = systemPromptResult.breakdown;
7774
7847
  const allTools = {
7775
7848
  ...mcpTools,
7776
7849
  ...functionTools,
@@ -7808,6 +7881,22 @@ ${typeof cleanResult === "string" ? cleanResult : JSON.stringify(cleanResult, nu
7808
7881
  }
7809
7882
  });
7810
7883
  }
7884
+ contextBreakdown.conversationHistory = estimateTokens(conversationHistory);
7885
+ calculateBreakdownTotal(contextBreakdown);
7886
+ span.setAttributes({
7887
+ "context.breakdown.system_template_tokens": contextBreakdown.systemPromptTemplate,
7888
+ "context.breakdown.core_instructions_tokens": contextBreakdown.coreInstructions,
7889
+ "context.breakdown.agent_prompt_tokens": contextBreakdown.agentPrompt,
7890
+ "context.breakdown.tools_tokens": contextBreakdown.toolsSection,
7891
+ "context.breakdown.artifacts_tokens": contextBreakdown.artifactsSection,
7892
+ "context.breakdown.data_components_tokens": contextBreakdown.dataComponents,
7893
+ "context.breakdown.artifact_components_tokens": contextBreakdown.artifactComponents,
7894
+ "context.breakdown.transfer_instructions_tokens": contextBreakdown.transferInstructions,
7895
+ "context.breakdown.delegation_instructions_tokens": contextBreakdown.delegationInstructions,
7896
+ "context.breakdown.thinking_preparation_tokens": contextBreakdown.thinkingPreparation,
7897
+ "context.breakdown.conversation_history_tokens": contextBreakdown.conversationHistory,
7898
+ "context.breakdown.total_tokens": contextBreakdown.total
7899
+ });
7811
7900
  const primaryModelSettings = this.getPrimaryModel();
7812
7901
  const modelSettings = ModelFactory.prepareGenerationConfig(primaryModelSettings);
7813
7902
  let response;