@axiom-lattice/core 2.1.27 → 2.1.28

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.js CHANGED
@@ -2099,6 +2099,20 @@ ${serverKeys.map(
2099
2099
  return (0, import_langchain6.tool)(
2100
2100
  async (_input, _exeConfig) => {
2101
2101
  try {
2102
+ const runConfig = _exeConfig?.configurable?.runConfig || {};
2103
+ const metricsDataSource = runConfig.metricsDataSource;
2104
+ if (metricsDataSource) {
2105
+ const { serverKey, datasourceId } = metricsDataSource;
2106
+ return `\u2139\uFE0F **\u5F53\u524D\u5DF2\u9009\u4E2D\u6570\u636E\u6E90**
2107
+
2108
+ \u60A8\u5DF2\u901A\u8FC7\u754C\u9762\u9009\u4E2D\u4E86\u7279\u5B9A\u7684\u6570\u636E\u6E90\uFF0C\u6240\u6709 metrics \u67E5\u8BE2\u5C06\u4E13\u6CE8\u4E8E\uFF1A
2109
+ - **\u670D\u52A1\u5668**: ${serverKey}
2110
+ - **\u6570\u636E\u6E90ID**: ${datasourceId}
2111
+
2112
+ \u60A8\u53EF\u4EE5\u76F4\u63A5\u4F7F\u7528\u5176\u4ED6 metrics \u5DE5\u5177\uFF08\u5982 query_metrics_list\u3001query_semantic_metric_data \u7B49\uFF09\uFF0C\u65E0\u9700\u518D\u6307\u5B9A serverKey \u548C datasourceId \u53C2\u6570\u3002
2113
+
2114
+ \u5982\u9700\u67E5\u770B\u6240\u6709\u53EF\u7528\u7684\u6570\u636E\u6E90\uFF0C\u8BF7\u6E05\u9664\u5F53\u524D\u9009\u62E9\u6216\u91CD\u65B0\u6253\u5F00\u6570\u636E\u6E90\u9009\u62E9\u5668\u3002`;
2115
+ }
2102
2116
  if (serverKeys.length === 0) {
2103
2117
  return "No metrics servers configured.";
2104
2118
  }
@@ -2194,10 +2208,13 @@ ${serverKeys.map(
2194
2208
  ).join("\n")}` : "";
2195
2209
  return (0, import_langchain7.tool)(
2196
2210
  async ({
2197
- serverKey,
2211
+ serverKey: inputServerKey,
2198
2212
  datasourceIds
2199
2213
  }, _exeConfig) => {
2200
2214
  try {
2215
+ const runConfig = _exeConfig?.configurable?.runConfig || {};
2216
+ const metricsDataSource = runConfig.metricsDataSource;
2217
+ const serverKey = metricsDataSource?.serverKey || inputServerKey;
2201
2218
  if (!serverKey) {
2202
2219
  return "Error: serverKey parameter is required. Available servers: " + serverKeys.join(", ");
2203
2220
  }
@@ -2209,7 +2226,7 @@ ${serverKeys.map(
2209
2226
  return `Error: Server "${serverKey}" is not a semantic metrics server. This tool only works with semantic servers.`;
2210
2227
  }
2211
2228
  const client = metricsServerManager.getClient(serverKey);
2212
- const targetDatasourceIds = datasourceIds && datasourceIds.length > 0 ? datasourceIds : client.getSelectedDataSources();
2229
+ const targetDatasourceIds = datasourceIds && datasourceIds.length > 0 ? datasourceIds : metricsDataSource?.datasourceId ? [metricsDataSource.datasourceId] : client.getSelectedDataSources();
2213
2230
  if (targetDatasourceIds.length === 0) {
2214
2231
  return `Error: No data sources specified and no default data sources configured for server "${serverKey}".`;
2215
2232
  }
@@ -2257,7 +2274,7 @@ ${serverKeys.map(
2257
2274
  for (const dsId of sortedDatasourceIds) {
2258
2275
  const metrics = metricsByDatasource.get(dsId);
2259
2276
  const sortedMetrics = metrics.sort((a, b) => {
2260
- if (a.domain !== b.domain) {
2277
+ if (a.domain && a.domain !== b.domain) {
2261
2278
  return a.domain.localeCompare(b.domain);
2262
2279
  }
2263
2280
  return a.metricName.localeCompare(b.metricName);
@@ -2284,8 +2301,8 @@ ${serverKeys.map(
2284
2301
  name: "query_metrics_list",
2285
2302
  description: `${QUERY_METRICS_LIST_DESCRIPTION}${availableServersText}`,
2286
2303
  schema: import_zod9.default.object({
2287
- serverKey: import_zod9.default.string().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}`),
2288
- datasourceIds: import_zod9.default.array(import_zod9.default.string()).optional().describe("Optional array of datasource IDs to query. If not provided, uses all selected datasources.")
2304
+ serverKey: import_zod9.default.string().optional().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}. Optional if configured in runConfig.metricsDataSource`),
2305
+ datasourceIds: import_zod9.default.array(import_zod9.default.string()).optional().describe("Optional array of datasource IDs to query. If not provided, uses all selected datasources or the one configured in runConfig.metricsDataSource.")
2289
2306
  })
2290
2307
  }
2291
2308
  );
@@ -2342,11 +2359,15 @@ ${serverKeys.map(
2342
2359
  ).join("\n")}` : "";
2343
2360
  return (0, import_langchain8.tool)(
2344
2361
  async ({
2345
- serverKey,
2362
+ serverKey: inputServerKey,
2346
2363
  metricName,
2347
- datasourceId
2364
+ datasourceId: inputDatasourceId
2348
2365
  }, _exeConfig) => {
2349
2366
  try {
2367
+ const runConfig = _exeConfig?.configurable?.runConfig || {};
2368
+ const metricsDataSource = runConfig.metricsDataSource;
2369
+ const serverKey = metricsDataSource?.serverKey || inputServerKey;
2370
+ const datasourceId = inputDatasourceId || metricsDataSource?.datasourceId;
2350
2371
  if (!serverKey) {
2351
2372
  return "Error: serverKey parameter is required. Available servers: " + serverKeys.join(", ");
2352
2373
  }
@@ -2405,12 +2426,20 @@ ${serverKeys.map(
2405
2426
  lines.push(foundDetail.description);
2406
2427
  lines.push("");
2407
2428
  if (foundDetail.defaultTimeContext) {
2429
+ const dtc = foundDetail.defaultTimeContext;
2408
2430
  lines.push(`## \u65F6\u95F4\u4E0A\u4E0B\u6587`);
2409
2431
  lines.push("");
2410
- lines.push(`- **\u65F6\u95F4\u7EF4\u5EA6**: ${foundDetail.defaultTimeContext.timeDimension} (${foundDetail.defaultTimeContext.label})`);
2411
- lines.push(`- **\u9ED8\u8BA4\u7C92\u5EA6**: ${foundDetail.defaultTimeContext.granularity}`);
2412
- lines.push(`- **\u9ED8\u8BA4\u7A97\u53E3**: ${foundDetail.defaultTimeContext.window}`);
2413
- lines.push(`- **\u652F\u6301\u7684\u7C92\u5EA6**: ${foundDetail.defaultTimeContext.supportedGrains.join("\u3001")}`);
2432
+ if (dtc.timeDimension) {
2433
+ lines.push(`- **\u65F6\u95F4\u7EF4\u5EA6**: ${dtc.timeDimension}${dtc.label ? ` (${dtc.label})` : ""}`);
2434
+ }
2435
+ if (dtc.granularity) {
2436
+ lines.push(`- **\u9ED8\u8BA4\u7C92\u5EA6**: ${dtc.granularity}`);
2437
+ }
2438
+ if (dtc.window) {
2439
+ lines.push(`- **\u9ED8\u8BA4\u7A97\u53E3**: ${dtc.window}`);
2440
+ }
2441
+ const grains = dtc.supportedGrains;
2442
+ lines.push(`- **\u652F\u6301\u7684\u7C92\u5EA6**: ${Array.isArray(grains) && grains.length > 0 ? grains.join("\u3001") : "\u672A\u914D\u7F6E"}`);
2414
2443
  lines.push("");
2415
2444
  }
2416
2445
  if (foundDetail.supportedDimensions && foundDetail.supportedDimensions.length > 0) {
@@ -2474,10 +2503,12 @@ ${serverKeys.map(
2474
2503
  const aiContext = foundDetail.aiAgentContext;
2475
2504
  lines.push(`## AI \u5206\u6790\u4E0A\u4E0B\u6587`);
2476
2505
  lines.push("");
2477
- lines.push(`### \u6307\u6807\u6781\u6027`);
2478
- lines.push("");
2479
- lines.push(aiContext.polarity === "positive" ? "\u6B63\u5411\u6307\u6807\uFF08\u8D8A\u9AD8\u8D8A\u597D\uFF09" : "\u8D1F\u5411\u6307\u6807\uFF08\u8D8A\u4F4E\u8D8A\u597D\uFF09");
2480
- lines.push("");
2506
+ if (aiContext.polarity) {
2507
+ lines.push(`### \u6307\u6807\u6781\u6027`);
2508
+ lines.push("");
2509
+ lines.push(aiContext.polarity === "positive" ? "\u6B63\u5411\u6307\u6807\uFF08\u8D8A\u9AD8\u8D8A\u597D\uFF09" : "\u8D1F\u5411\u6307\u6807\uFF08\u8D8A\u4F4E\u8D8A\u597D\uFF09");
2510
+ lines.push("");
2511
+ }
2481
2512
  if (aiContext.synonyms && aiContext.synonyms.length > 0) {
2482
2513
  lines.push(`### \u540C\u4E49\u8BCD/\u522B\u540D`);
2483
2514
  lines.push("");
@@ -2500,7 +2531,9 @@ ${serverKeys.map(
2500
2531
  if (aiContext.diagnosticWorkflow.trigger && aiContext.diagnosticWorkflow.trigger.any_of) {
2501
2532
  lines.push(`**\u89E6\u53D1\u6761\u4EF6** (\u6EE1\u8DB3\u4EFB\u4E00):`);
2502
2533
  for (const trigger of aiContext.diagnosticWorkflow.trigger.any_of) {
2503
- lines.push(`- ${trigger.metric} ${trigger.operator} ${trigger.value}`);
2534
+ if (trigger.metric && trigger.operator) {
2535
+ lines.push(`- ${trigger.metric} ${trigger.operator} ${trigger.value ?? "N/A"}`);
2536
+ }
2504
2537
  }
2505
2538
  lines.push("");
2506
2539
  }
@@ -2508,14 +2541,17 @@ ${serverKeys.map(
2508
2541
  lines.push(`**\u5206\u6790\u52A8\u4F5C**:`);
2509
2542
  for (let i = 0; i < aiContext.diagnosticWorkflow.actions.length; i++) {
2510
2543
  const action = aiContext.diagnosticWorkflow.actions[i];
2511
- lines.push(`${i + 1}. **${action.type}**`);
2544
+ if (!action) continue;
2545
+ lines.push(`${i + 1}. **${action.type ?? "\u672A\u547D\u540D\u52A8\u4F5C"}**`);
2512
2546
  if (action.metric) {
2513
2547
  lines.push(` - \u5BF9\u6BD4\u6307\u6807: ${action.metric}`);
2514
2548
  }
2515
2549
  if (action.dimensions && action.dimensions.length > 0) {
2516
2550
  lines.push(` - \u4E0B\u94BB\u7EF4\u5EA6: ${action.dimensions.join("\u3001")}`);
2517
2551
  }
2518
- lines.push(` - \u76EE\u7684: ${action.intent}`);
2552
+ if (action.intent) {
2553
+ lines.push(` - \u76EE\u7684: ${action.intent}`);
2554
+ }
2519
2555
  }
2520
2556
  lines.push("");
2521
2557
  }
@@ -2549,9 +2585,9 @@ ${serverKeys.map(
2549
2585
  name: "query_metric_definition",
2550
2586
  description: `${QUERY_METRIC_DEFINITION_DESCRIPTION}${availableServersText}`,
2551
2587
  schema: import_zod10.default.object({
2552
- serverKey: import_zod10.default.string().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}`),
2588
+ serverKey: import_zod10.default.string().optional().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}. Optional if configured in runConfig.metricsDataSource`),
2553
2589
  metricName: import_zod10.default.string().describe("The name of the metric to get definition for."),
2554
- datasourceId: import_zod10.default.string().optional().describe("Optional specific datasource ID to search in. If not provided, searches all selected datasources.")
2590
+ datasourceId: import_zod10.default.string().optional().describe("Optional specific datasource ID to search in. If not provided, uses the one configured in runConfig.metricsDataSource or searches all selected datasources.")
2555
2591
  })
2556
2592
  }
2557
2593
  );
@@ -2743,14 +2779,18 @@ ${serverKeys.map(
2743
2779
  ).join("\n")}` : "";
2744
2780
  return (0, import_langchain9.tool)(
2745
2781
  async ({
2746
- serverKey,
2747
- datasourceId,
2782
+ serverKey: inputServerKey,
2783
+ datasourceId: inputDatasourceId,
2748
2784
  metrics,
2749
2785
  groupBy,
2750
2786
  filters,
2751
2787
  limit
2752
2788
  }, _exeConfig) => {
2753
2789
  try {
2790
+ const runConfig = _exeConfig?.configurable?.runConfig || {};
2791
+ const metricsDataSource = runConfig.metricsDataSource;
2792
+ const serverKey = metricsDataSource?.serverKey || inputServerKey;
2793
+ const datasourceId = metricsDataSource?.datasourceId || inputDatasourceId;
2754
2794
  if (!serverKey) {
2755
2795
  return "Error: serverKey parameter is required. Available servers: " + serverKeys.join(", ");
2756
2796
  }
@@ -2773,6 +2813,7 @@ ${serverKeys.map(
2773
2813
  operator: f.operator,
2774
2814
  values: f.values
2775
2815
  }));
2816
+ console.log(`[query_semantic_metric_data] Querying: server=${serverKey}, datasource=${datasourceId}, metrics=[${metrics.join(", ")}], groupBy=[${groupBy?.join(", ") || ""}], filters=${JSON.stringify(filters)}, limit=${limit || 1e3}`);
2776
2817
  const result = await client.semanticQuery({
2777
2818
  datasourceId,
2778
2819
  metrics,
@@ -2793,8 +2834,8 @@ ${serverKeys.map(
2793
2834
  name: "query_semantic_metric_data",
2794
2835
  description: `${QUERY_SEMANTIC_METRIC_DATA_DESCRIPTION}${availableServersText}`,
2795
2836
  schema: import_zod11.default.object({
2796
- serverKey: import_zod11.default.string().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}`),
2797
- datasourceId: import_zod11.default.string().describe("The data source ID to query metrics from."),
2837
+ serverKey: import_zod11.default.string().optional().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}. Optional if configured in runConfig.metricsDataSource`),
2838
+ datasourceId: import_zod11.default.string().optional().describe("The data source ID to query metrics from. Optional if configured in runConfig.metricsDataSource"),
2798
2839
  metrics: import_zod11.default.array(import_zod11.default.string()).describe("Array of metric names to query (e.g., ['net_sales_amt', 'gross_profit'])."),
2799
2840
  groupBy: import_zod11.default.array(import_zod11.default.string()).optional().describe("Optional array of dimensions to group by (e.g., ['DocDate__month', 'CustomerCode'])."),
2800
2841
  filters: import_zod11.default.array(import_zod11.default.object({
@@ -2821,10 +2862,13 @@ ${serverKeys.map(
2821
2862
  ).join("\n")}` : "";
2822
2863
  return (0, import_langchain10.tool)(
2823
2864
  async ({
2824
- serverKey,
2865
+ serverKey: inputServerKey,
2825
2866
  datasourceIds
2826
2867
  }, _exeConfig) => {
2827
2868
  try {
2869
+ const runConfig = _exeConfig?.configurable?.runConfig || {};
2870
+ const metricsDataSource = runConfig.metricsDataSource;
2871
+ const serverKey = metricsDataSource?.serverKey || inputServerKey;
2828
2872
  if (!serverKey) {
2829
2873
  return "Error: serverKey parameter is required. Available servers: " + serverKeys.join(", ");
2830
2874
  }
@@ -2836,7 +2880,7 @@ ${serverKeys.map(
2836
2880
  return `Error: Server "${serverKey}" is not a semantic metrics server. This tool only works with semantic servers.`;
2837
2881
  }
2838
2882
  const client = metricsServerManager.getClient(serverKey);
2839
- const targetDatasourceIds = datasourceIds && datasourceIds.length > 0 ? datasourceIds : client.getSelectedDataSources();
2883
+ const targetDatasourceIds = datasourceIds && datasourceIds.length > 0 ? datasourceIds : metricsDataSource?.datasourceId ? [metricsDataSource.datasourceId] : client.getSelectedDataSources();
2840
2884
  if (targetDatasourceIds.length === 0) {
2841
2885
  return `Error: No data sources specified and no default data sources configured for server "${serverKey}".`;
2842
2886
  }
@@ -2896,8 +2940,8 @@ ${serverKeys.map(
2896
2940
  name: "query_tables_list",
2897
2941
  description: `${QUERY_TABLES_LIST_DESCRIPTION}${availableServersText}`,
2898
2942
  schema: import_zod12.default.object({
2899
- serverKey: import_zod12.default.string().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}`),
2900
- datasourceIds: import_zod12.default.array(import_zod12.default.string()).optional().describe("Optional array of datasource IDs to query. If not provided, uses all selected datasources.")
2943
+ serverKey: import_zod12.default.string().optional().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}. Optional if configured in runConfig.metricsDataSource`),
2944
+ datasourceIds: import_zod12.default.array(import_zod12.default.string()).optional().describe("Optional array of datasource IDs to query. If not provided, uses the one configured in runConfig.metricsDataSource or all selected datasources.")
2901
2945
  })
2902
2946
  }
2903
2947
  );
@@ -2916,11 +2960,15 @@ ${serverKeys.map(
2916
2960
  ).join("\n")}` : "";
2917
2961
  return (0, import_langchain11.tool)(
2918
2962
  async ({
2919
- serverKey,
2963
+ serverKey: inputServerKey,
2920
2964
  tableName,
2921
- datasourceId
2965
+ datasourceId: inputDatasourceId
2922
2966
  }, _exeConfig) => {
2923
2967
  try {
2968
+ const runConfig = _exeConfig?.configurable?.runConfig || {};
2969
+ const metricsDataSource = runConfig.metricsDataSource;
2970
+ const serverKey = metricsDataSource?.serverKey || inputServerKey;
2971
+ const datasourceId = inputDatasourceId || metricsDataSource?.datasourceId;
2924
2972
  if (!serverKey) {
2925
2973
  return "Error: serverKey parameter is required. Available servers: " + serverKeys.join(", ");
2926
2974
  }
@@ -3008,9 +3056,9 @@ ${serverKeys.map(
3008
3056
  name: "query_table_definition",
3009
3057
  description: `${QUERY_TABLE_DEFINITION_DESCRIPTION}${availableServersText}`,
3010
3058
  schema: import_zod13.default.object({
3011
- serverKey: import_zod13.default.string().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}`),
3059
+ serverKey: import_zod13.default.string().optional().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}. Optional if configured in runConfig.metricsDataSource`),
3012
3060
  tableName: import_zod13.default.string().describe("The name of the table to get definition for."),
3013
- datasourceId: import_zod13.default.string().optional().describe("Optional specific datasource ID to search in. If not provided, searches all selected datasources.")
3061
+ datasourceId: import_zod13.default.string().optional().describe("Optional specific datasource ID to search in. If not provided, uses the one configured in runConfig.metricsDataSource or searches all selected datasources.")
3014
3062
  })
3015
3063
  }
3016
3064
  );
@@ -3064,13 +3112,17 @@ ${serverKeys.map(
3064
3112
  ).join("\n")}` : "";
3065
3113
  return (0, import_langchain12.tool)(
3066
3114
  async ({
3067
- serverKey,
3068
- datasourceId,
3115
+ serverKey: inputServerKey,
3116
+ datasourceId: inputDatasourceId,
3069
3117
  customSql,
3070
3118
  params,
3071
3119
  limit
3072
3120
  }, _exeConfig) => {
3073
3121
  try {
3122
+ const runConfig = _exeConfig?.configurable?.runConfig || {};
3123
+ const metricsDataSource = runConfig.metricsDataSource;
3124
+ const serverKey = metricsDataSource?.serverKey || inputServerKey;
3125
+ const datasourceId = metricsDataSource?.datasourceId || inputDatasourceId;
3074
3126
  if (!serverKey) {
3075
3127
  return "Error: serverKey parameter is required. Available servers: " + serverKeys.join(", ");
3076
3128
  }
@@ -3103,8 +3155,8 @@ ${serverKeys.map(
3103
3155
  name: "execute_sql_query",
3104
3156
  description: `${EXECUTE_SQL_QUERY_DESCRIPTION}${availableServersText}`,
3105
3157
  schema: import_zod14.default.object({
3106
- serverKey: import_zod14.default.string().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}`),
3107
- datasourceId: import_zod14.default.string().describe("The data source ID to execute SQL against."),
3158
+ serverKey: import_zod14.default.string().optional().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}. Optional if configured in runConfig.metricsDataSource`),
3159
+ datasourceId: import_zod14.default.string().optional().describe("The data source ID to execute SQL against. Optional if configured in runConfig.metricsDataSource"),
3108
3160
  customSql: import_zod14.default.string().describe("Custom SQL query string with named parameters (e.g., :year, :category). Use double quotes for identifiers."),
3109
3161
  params: import_zod14.default.record(import_zod14.default.union([import_zod14.default.string(), import_zod14.default.number(), import_zod14.default.boolean()])).optional().describe("Optional parameters for the SQL query. Keys should match the :paramName placeholders in customSql."),
3110
3162
  limit: import_zod14.default.number().optional().describe("Maximum number of results to return (default: 1000).")
@@ -7705,6 +7757,11 @@ var AgentWorkerState = import_langgraph5.Annotation.Root({
7705
7757
  reducer: (x, y) => y ?? x,
7706
7758
  default: () => void 0
7707
7759
  }),
7760
+ // RunConfig for passing configuration through the graph
7761
+ runConfig: (0, import_langgraph5.Annotation)({
7762
+ reducer: (x, y) => y ?? x,
7763
+ default: () => void 0
7764
+ }),
7708
7765
  // Execution result
7709
7766
  result: (0, import_langgraph5.Annotation)({
7710
7767
  reducer: (x, y) => y ?? x,
@@ -7722,12 +7779,13 @@ var AgentWorkerState = import_langgraph5.Annotation.Root({
7722
7779
  })
7723
7780
  });
7724
7781
  async function executeNode(state) {
7725
- const { assistant_id, thread_id, input, command2 } = state;
7782
+ const { assistant_id, thread_id, input, command2, runConfig } = state;
7726
7783
  const callParams = {
7727
7784
  assistant_id,
7728
7785
  thread_id,
7729
7786
  input,
7730
- command: command2
7787
+ command: command2,
7788
+ runConfig
7731
7789
  };
7732
7790
  const result = await AgentManager.getInstance().callAgentInQueue(
7733
7791
  callParams,
@@ -7792,7 +7850,7 @@ var DEFAULT_SUBAGENT_PROMPT = "In order to complete the objective that the user
7792
7850
  var EXCLUDED_STATE_KEYS = ["messages", "todos", "jumpTo"];
7793
7851
  var DEFAULT_GENERAL_PURPOSE_DESCRIPTION = "General-purpose agent for researching complex questions, searching for files and content, and executing multi-step tasks. When you are searching for a keyword or file and are not confident that you will find the right match in the first few tries use this agent to perform the search for you. This agent has access to all tools as the main agent.";
7794
7852
  function getTaskToolDescription(subagentDescriptions) {
7795
- return `
7853
+ return subagentDescriptions.length > 0 ? `
7796
7854
  Launch an ephemeral subagent to handle complex, multi-step independent tasks with isolated context windows.
7797
7855
 
7798
7856
  Available agent types and the tools they have access to:
@@ -7902,7 +7960,7 @@ Since the user is greeting, use the greeting-responder agent to respond with a f
7902
7960
  </commentary>
7903
7961
  assistant: "I'm going to use the Task tool to launch with the greeting-responder agent"
7904
7962
  </example>
7905
- `.trim();
7963
+ `.trim() : "No subagents available, you DON'T NEED TO USE THE TASK TOOL, just use the tools directly.";
7906
7964
  }
7907
7965
  var TASK_SYSTEM_PROMPT = `## \`task\` (subagent spawner)
7908
7966
 
@@ -7989,16 +8047,16 @@ function getSubagents(options) {
7989
8047
  }
7990
8048
  for (const agentParams of subagents) {
7991
8049
  subagentDescriptions.push(
7992
- `- ${agentParams.name}: ${agentParams.description}`
8050
+ `- ${agentParams.key}: ${agentParams.name} - ${agentParams.description}`
7993
8051
  );
7994
8052
  if ("runnable" in agentParams) {
7995
- agents[agentParams.name] = agentParams.runnable;
8053
+ agents[agentParams.key] = agentParams.runnable;
7996
8054
  } else {
7997
8055
  const middleware = agentParams.middleware ? [...defaultSubagentMiddleware, ...agentParams.middleware] : [...defaultSubagentMiddleware];
7998
8056
  const interruptOn = agentParams.interruptOn || defaultInterruptOn;
7999
8057
  if (interruptOn)
8000
8058
  middleware.push((0, import_langchain47.humanInTheLoopMiddleware)({ interruptOn }));
8001
- agents[agentParams.name] = (0, import_langchain47.createAgent)({
8059
+ agents[agentParams.key] = (0, import_langchain47.createAgent)({
8002
8060
  model: agentParams.model ?? defaultModel,
8003
8061
  systemPrompt: agentParams.systemPrompt,
8004
8062
  tools: agentParams.tools ?? defaultTools,
@@ -8046,7 +8104,12 @@ function createTaskTool(options) {
8046
8104
  const workerResult = await agentWorkerGraph.invoke({
8047
8105
  assistant_id: subagent_type,
8048
8106
  thread_id: subagent_thread_id,
8049
- input: { ...subagentState, message: description }
8107
+ input: { ...subagentState, message: description },
8108
+ runConfig: {
8109
+ ...config.configurable?.runConfig,
8110
+ assistant_id: subagent_type,
8111
+ thread_id: subagent_thread_id
8112
+ }
8050
8113
  });
8051
8114
  const result = workerResult.finalState?.values;
8052
8115
  if (!config.toolCall?.id) {
@@ -9661,6 +9724,7 @@ var DeepAgentGraphBuilder = class {
9661
9724
  const subagents = params.subAgents.map((sa) => {
9662
9725
  if (sa.client) {
9663
9726
  return {
9727
+ key: sa.config.key,
9664
9728
  name: sa.config.name,
9665
9729
  description: sa.config.description,
9666
9730
  runnable: sa.client
@@ -9670,6 +9734,7 @@ var DeepAgentGraphBuilder = class {
9670
9734
  config: sa.config
9671
9735
  });
9672
9736
  return {
9737
+ key: sa.config.key,
9673
9738
  name: sa.config.name,
9674
9739
  description: sa.config.description,
9675
9740
  runnable: subagentClient