agent-swarm-kit 1.0.37 → 1.0.38

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/build/index.cjs CHANGED
@@ -669,18 +669,19 @@ var ClientAgent = /** @class */ (function () {
669
669
  * @param {string} content - The tool output content.
670
670
  * @returns {Promise<void>}
671
671
  */
672
- this.commitToolOutput = function (content) { return __awaiter(_this, void 0, void 0, function () {
672
+ this.commitToolOutput = function (toolId, content) { return __awaiter(_this, void 0, void 0, function () {
673
673
  return __generator(this, function (_a) {
674
674
  switch (_a.label) {
675
675
  case 0:
676
- this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " commitToolOutput"), { content: content });
676
+ this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " commitToolOutput"), { content: content, toolId: toolId });
677
677
  this.params.onToolOutput &&
678
- this.params.onToolOutput(this.params.clientId, this.params.agentName, content);
678
+ this.params.onToolOutput(toolId, this.params.clientId, this.params.agentName, content);
679
679
  return [4 /*yield*/, this.params.history.push({
680
680
  role: "tool",
681
681
  agentName: this.params.agentName,
682
682
  mode: "tool",
683
683
  content: content,
684
+ tool_call_id: toolId,
684
685
  })];
685
686
  case 1:
686
687
  _a.sent();
@@ -699,9 +700,9 @@ var ClientAgent = /** @class */ (function () {
699
700
  this.execute = functoolsKit.queued(function (incoming, mode) { return __awaiter(_this, void 0, void 0, function () {
700
701
  var message, _loop_1, this_1, _a, _b, tool, state_1, e_1_1, result, validation, result1;
701
702
  var e_1, _c;
702
- var _d, _e, _f, _g, _h;
703
- return __generator(this, function (_j) {
704
- switch (_j.label) {
703
+ var _d, _e, _f, _g, _h, _j;
704
+ return __generator(this, function (_k) {
705
+ switch (_k.label) {
705
706
  case 0:
706
707
  this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute begin"), { incoming: incoming, mode: mode });
707
708
  this.params.onExecute &&
@@ -713,45 +714,45 @@ var ClientAgent = /** @class */ (function () {
713
714
  content: incoming.trim(),
714
715
  })];
715
716
  case 1:
716
- _j.sent();
717
+ _k.sent();
717
718
  return [4 /*yield*/, this.getCompletion(mode)];
718
719
  case 2:
719
- message = _j.sent();
720
+ message = _k.sent();
720
721
  if (!message.tool_calls) return [3 /*break*/, 11];
721
722
  this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " tool call begin"));
722
723
  _loop_1 = function (tool) {
723
724
  var targetFn, result_2, result_3;
724
- return __generator(this, function (_k) {
725
- switch (_k.label) {
725
+ return __generator(this, function (_l) {
726
+ switch (_l.label) {
726
727
  case 0:
727
728
  targetFn = (_d = this_1.params.tools) === null || _d === void 0 ? void 0 : _d.find(function (t) { return t.function.name === tool.function.name; });
728
729
  return [4 /*yield*/, this_1.params.history.push(__assign(__assign({}, message), { agentName: this_1.params.agentName }))];
729
730
  case 1:
730
- _k.sent();
731
+ _l.sent();
731
732
  if (!!targetFn) return [3 /*break*/, 4];
732
733
  this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " functionName=").concat(tool.function.name, " tool function not found"), this_1.params.tools);
733
734
  return [4 /*yield*/, this_1._resurrectModel(mode, "No target function for ".concat(tool.function.name))];
734
735
  case 2:
735
- result_2 = _k.sent();
736
+ result_2 = _l.sent();
736
737
  this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " execute end result=").concat(result_2));
737
738
  return [4 /*yield*/, this_1._emitOuput(mode, result_2)];
738
739
  case 3:
739
- _k.sent();
740
+ _l.sent();
740
741
  return [2 /*return*/, { value: void 0 }];
741
742
  case 4:
742
743
  ((_e = targetFn.callbacks) === null || _e === void 0 ? void 0 : _e.onValidate) &&
743
744
  ((_f = targetFn.callbacks) === null || _f === void 0 ? void 0 : _f.onValidate(this_1.params.clientId, this_1.params.agentName, tool.function.arguments));
744
745
  return [4 /*yield*/, functoolsKit.not(targetFn.validate(this_1.params.clientId, this_1.params.agentName, tool.function.arguments))];
745
746
  case 5:
746
- if (!_k.sent()) return [3 /*break*/, 8];
747
+ if (!_l.sent()) return [3 /*break*/, 8];
747
748
  this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " functionName=").concat(tool.function.name, " tool validation not passed"));
748
749
  return [4 /*yield*/, this_1._resurrectModel(mode, "Function validation failed: name=".concat(tool.function.name, " arguments=").concat(JSON.stringify(tool.function.arguments)))];
749
750
  case 6:
750
- result_3 = _k.sent();
751
+ result_3 = _l.sent();
751
752
  this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " execute end result=").concat(result_3));
752
753
  return [4 /*yield*/, this_1._emitOuput(mode, result_3)];
753
754
  case 7:
754
- _k.sent();
755
+ _l.sent();
755
756
  return [2 /*return*/, { value: void 0 }];
756
757
  case 8:
757
758
  ((_g = targetFn.callbacks) === null || _g === void 0 ? void 0 : _g.onCall) &&
@@ -759,40 +760,40 @@ var ClientAgent = /** @class */ (function () {
759
760
  /**
760
761
  * @description Do not await to avoid deadlock! The tool can send the message to other agents by emulating user messages
761
762
  */
762
- targetFn.call(this_1.params.clientId, this_1.params.agentName, tool.function.arguments);
763
+ targetFn.call((_j = tool.id) !== null && _j !== void 0 ? _j : functoolsKit.randomString(), this_1.params.clientId, this_1.params.agentName, tool.function.arguments);
763
764
  this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " functionName=").concat(tool.function.name, " tool call executing"));
764
765
  return [4 /*yield*/, Promise.race([
765
766
  this_1._toolCommitSubject.toPromise(),
766
767
  this_1._outputSubject.toPromise(),
767
768
  ])];
768
769
  case 9:
769
- _k.sent();
770
+ _l.sent();
770
771
  this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " functionName=").concat(tool.function.name, " tool call end"));
771
772
  return [2 /*return*/];
772
773
  }
773
774
  });
774
775
  };
775
776
  this_1 = this;
776
- _j.label = 3;
777
+ _k.label = 3;
777
778
  case 3:
778
- _j.trys.push([3, 8, 9, 10]);
779
+ _k.trys.push([3, 8, 9, 10]);
779
780
  _a = __values(message.tool_calls), _b = _a.next();
780
- _j.label = 4;
781
+ _k.label = 4;
781
782
  case 4:
782
783
  if (!!_b.done) return [3 /*break*/, 7];
783
784
  tool = _b.value;
784
785
  return [5 /*yield**/, _loop_1(tool)];
785
786
  case 5:
786
- state_1 = _j.sent();
787
+ state_1 = _k.sent();
787
788
  if (typeof state_1 === "object")
788
789
  return [2 /*return*/, state_1.value];
789
- _j.label = 6;
790
+ _k.label = 6;
790
791
  case 6:
791
792
  _b = _a.next();
792
793
  return [3 /*break*/, 4];
793
794
  case 7: return [3 /*break*/, 10];
794
795
  case 8:
795
- e_1_1 = _j.sent();
796
+ e_1_1 = _k.sent();
796
797
  e_1 = { error: e_1_1 };
797
798
  return [3 /*break*/, 10];
798
799
  case 9:
@@ -809,24 +810,24 @@ var ClientAgent = /** @class */ (function () {
809
810
  result = message.content;
810
811
  return [4 /*yield*/, this.params.history.push(__assign(__assign({}, message), { agentName: this.params.agentName }))];
811
812
  case 12:
812
- _j.sent();
813
+ _k.sent();
813
814
  validation = null;
814
815
  return [4 /*yield*/, this.params.validate(result)];
815
816
  case 13:
816
- if (!(validation = _j.sent())) return [3 /*break*/, 16];
817
+ if (!(validation = _k.sent())) return [3 /*break*/, 16];
817
818
  this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute invalid tool call detected: ").concat(validation), { result: result });
818
819
  return [4 /*yield*/, this._resurrectModel(mode, "Invalid model output: ".concat(result))];
819
820
  case 14:
820
- result1 = _j.sent();
821
+ result1 = _k.sent();
821
822
  return [4 /*yield*/, this._emitOuput(mode, result1)];
822
823
  case 15:
823
- _j.sent();
824
+ _k.sent();
824
825
  return [2 /*return*/];
825
826
  case 16:
826
827
  this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute end result=").concat(result));
827
828
  return [4 /*yield*/, this._emitOuput(mode, result)];
828
829
  case 17:
829
- _j.sent();
830
+ _k.sent();
830
831
  return [2 /*return*/];
831
832
  }
832
833
  });
@@ -918,17 +919,19 @@ var AgentConnectionService = /** @class */ (function () {
918
919
  /**
919
920
  * Commits tool output.
920
921
  * @param {string} content - The tool output content.
922
+ * @param {string} toolId - The `tool_call_id` for openai history
921
923
  * @returns {Promise<any>} The commit result.
922
924
  */
923
- this.commitToolOutput = function (content) { return __awaiter(_this, void 0, void 0, function () {
925
+ this.commitToolOutput = function (toolId, content) { return __awaiter(_this, void 0, void 0, function () {
924
926
  return __generator(this, function (_a) {
925
927
  switch (_a.label) {
926
928
  case 0:
927
929
  this.loggerService.log("agentConnectionService commitToolOutput", {
928
930
  content: content,
931
+ toolId: toolId,
929
932
  context: this.contextService.context,
930
933
  });
931
- return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).commitToolOutput(content)];
934
+ return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).commitToolOutput(toolId, content)];
932
935
  case 1: return [2 /*return*/, _a.sent()];
933
936
  }
934
937
  });
@@ -1784,21 +1787,23 @@ var ClientSession = /** @class */ (function () {
1784
1787
  }); };
1785
1788
  /**
1786
1789
  * Commits tool output.
1790
+ * @param {string} toolId - The `tool_call_id` for openai history
1787
1791
  * @param {string} content - The content to commit.
1788
1792
  * @returns {Promise<void>}
1789
1793
  */
1790
- this.commitToolOutput = function (content) { return __awaiter(_this, void 0, void 0, function () {
1794
+ this.commitToolOutput = function (toolId, content) { return __awaiter(_this, void 0, void 0, function () {
1791
1795
  var agent;
1792
1796
  return __generator(this, function (_a) {
1793
1797
  switch (_a.label) {
1794
1798
  case 0:
1795
1799
  this.params.logger.debug("ClientSession clientId=".concat(this.params.clientId, " commitToolOutput"), {
1796
1800
  content: content,
1801
+ toolId: toolId,
1797
1802
  });
1798
1803
  return [4 /*yield*/, this.params.swarm.getAgent()];
1799
1804
  case 1:
1800
1805
  agent = _a.sent();
1801
- return [4 /*yield*/, agent.commitToolOutput(content)];
1806
+ return [4 /*yield*/, agent.commitToolOutput(toolId, content)];
1802
1807
  case 2: return [2 /*return*/, _a.sent()];
1803
1808
  }
1804
1809
  });
@@ -2006,18 +2011,20 @@ var SessionConnectionService = /** @class */ (function () {
2006
2011
  };
2007
2012
  /**
2008
2013
  * Commits tool output to the session.
2014
+ * @param {string} toolId - The `tool_call_id` for openai history
2009
2015
  * @param {string} content - The content to commit.
2010
2016
  * @returns {Promise<void>} A promise that resolves when the content is committed.
2011
2017
  */
2012
- this.commitToolOutput = function (content) { return __awaiter(_this, void 0, void 0, function () {
2018
+ this.commitToolOutput = function (toolId, content) { return __awaiter(_this, void 0, void 0, function () {
2013
2019
  return __generator(this, function (_a) {
2014
2020
  switch (_a.label) {
2015
2021
  case 0:
2016
2022
  this.loggerService.log("sessionConnectionService commitToolOutput", {
2017
2023
  context: this.contextService.context,
2018
2024
  content: content,
2025
+ toolId: toolId,
2019
2026
  });
2020
- return [4 /*yield*/, this.getSession(this.contextService.context.clientId, this.contextService.context.swarmName).commitToolOutput(content)];
2027
+ return [4 /*yield*/, this.getSession(this.contextService.context.clientId, this.contextService.context.swarmName).commitToolOutput(toolId, content)];
2021
2028
  case 1: return [2 /*return*/, _a.sent()];
2022
2029
  }
2023
2030
  });
@@ -2204,12 +2211,13 @@ var AgentPublicService = /** @class */ (function () {
2204
2211
  }); };
2205
2212
  /**
2206
2213
  * Commits tool output to the agent.
2214
+ * @param {string} toolId - The `tool_call_id` for openai history
2207
2215
  * @param {string} content - The content to commit.
2208
2216
  * @param {string} clientId - The client ID.
2209
2217
  * @param {AgentName} agentName - The name of the agent.
2210
2218
  * @returns {Promise<unknown>} The commit result.
2211
2219
  */
2212
- this.commitToolOutput = function (content, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
2220
+ this.commitToolOutput = function (toolId, content, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
2213
2221
  var _this = this;
2214
2222
  return __generator(this, function (_a) {
2215
2223
  switch (_a.label) {
@@ -2217,12 +2225,13 @@ var AgentPublicService = /** @class */ (function () {
2217
2225
  this.loggerService.log("agentPublicService commitToolOutput", {
2218
2226
  content: content,
2219
2227
  clientId: clientId,
2228
+ toolId: toolId,
2220
2229
  agentName: agentName,
2221
2230
  });
2222
2231
  return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
2223
2232
  return __generator(this, function (_a) {
2224
2233
  switch (_a.label) {
2225
- case 0: return [4 /*yield*/, this.agentConnectionService.commitToolOutput(content)];
2234
+ case 0: return [4 /*yield*/, this.agentConnectionService.commitToolOutput(toolId, content)];
2226
2235
  case 1: return [2 /*return*/, _a.sent()];
2227
2236
  }
2228
2237
  });
@@ -2632,17 +2641,19 @@ var SessionPublicService = /** @class */ (function () {
2632
2641
  };
2633
2642
  /**
2634
2643
  * Commits tool output to the session.
2644
+ * @param {string} toolId - The `tool_call_id` for openai history
2635
2645
  * @param {string} content - The content to commit.
2636
2646
  * @param {string} clientId - The client ID.
2637
2647
  * @param {SwarmName} swarmName - The swarm name.
2638
2648
  * @returns {Promise<void>}
2639
2649
  */
2640
- this.commitToolOutput = function (content, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
2650
+ this.commitToolOutput = function (toolId, content, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
2641
2651
  var _this = this;
2642
2652
  return __generator(this, function (_a) {
2643
2653
  switch (_a.label) {
2644
2654
  case 0:
2645
2655
  this.loggerService.log("sessionPublicService commitToolOutput", {
2656
+ toolId: toolId,
2646
2657
  content: content,
2647
2658
  clientId: clientId,
2648
2659
  swarmName: swarmName,
@@ -2650,7 +2661,7 @@ var SessionPublicService = /** @class */ (function () {
2650
2661
  return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
2651
2662
  return __generator(this, function (_a) {
2652
2663
  switch (_a.label) {
2653
- case 0: return [4 /*yield*/, this.sessionConnectionService.commitToolOutput(content)];
2664
+ case 0: return [4 /*yield*/, this.sessionConnectionService.commitToolOutput(toolId, content)];
2654
2665
  case 1: return [2 /*return*/, _a.sent()];
2655
2666
  }
2656
2667
  });
@@ -4151,12 +4162,13 @@ var getAgentHistory = function (clientId, agentName) { return __awaiter(void 0,
4151
4162
  * @param {AgentName} agentName - The name of the agent committing the output.
4152
4163
  * @returns {Promise<void>} - A promise that resolves when the operation is complete.
4153
4164
  */
4154
- var commitToolOutput = function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
4165
+ var commitToolOutput = function (toolId, content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
4155
4166
  var swarmName, currentAgentName;
4156
4167
  return __generator(this, function (_a) {
4157
4168
  switch (_a.label) {
4158
4169
  case 0:
4159
4170
  swarm.loggerService.log('function commitToolOutput', {
4171
+ toolId: toolId,
4160
4172
  content: content,
4161
4173
  clientId: clientId,
4162
4174
  agentName: agentName,
@@ -4170,13 +4182,14 @@ var commitToolOutput = function (content, clientId, agentName) { return __awaite
4170
4182
  currentAgentName = _a.sent();
4171
4183
  if (currentAgentName !== agentName) {
4172
4184
  swarm.loggerService.log('function "commitToolOutput" skipped due to the agent change', {
4185
+ toolId: toolId,
4173
4186
  currentAgentName: currentAgentName,
4174
4187
  agentName: agentName,
4175
4188
  clientId: clientId,
4176
4189
  });
4177
4190
  return [2 /*return*/];
4178
4191
  }
4179
- return [4 /*yield*/, swarm.sessionPublicService.commitToolOutput(content, clientId, swarmName)];
4192
+ return [4 /*yield*/, swarm.sessionPublicService.commitToolOutput(toolId, content, clientId, swarmName)];
4180
4193
  case 2:
4181
4194
  _a.sent();
4182
4195
  return [2 /*return*/];
package/build/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { scoped } from 'di-scoped';
2
- import { ToolRegistry, trycatch, sleep, PubsubArrayAdapter, Subject, queued, not, memoize, createAwaiter, cancelable, CANCELED_PROMISE_SYMBOL, schedule, ttl, singleshot, Source } from 'functools-kit';
2
+ import { ToolRegistry, trycatch, sleep, PubsubArrayAdapter, Subject, queued, randomString, not, memoize, createAwaiter, cancelable, CANCELED_PROMISE_SYMBOL, schedule, ttl, singleshot, Source } from 'functools-kit';
3
3
  import { createActivator } from 'di-kit';
4
4
  import { omit } from 'lodash-es';
5
5
  import xml2js from 'xml2js';
@@ -667,18 +667,19 @@ var ClientAgent = /** @class */ (function () {
667
667
  * @param {string} content - The tool output content.
668
668
  * @returns {Promise<void>}
669
669
  */
670
- this.commitToolOutput = function (content) { return __awaiter(_this, void 0, void 0, function () {
670
+ this.commitToolOutput = function (toolId, content) { return __awaiter(_this, void 0, void 0, function () {
671
671
  return __generator(this, function (_a) {
672
672
  switch (_a.label) {
673
673
  case 0:
674
- this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " commitToolOutput"), { content: content });
674
+ this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " commitToolOutput"), { content: content, toolId: toolId });
675
675
  this.params.onToolOutput &&
676
- this.params.onToolOutput(this.params.clientId, this.params.agentName, content);
676
+ this.params.onToolOutput(toolId, this.params.clientId, this.params.agentName, content);
677
677
  return [4 /*yield*/, this.params.history.push({
678
678
  role: "tool",
679
679
  agentName: this.params.agentName,
680
680
  mode: "tool",
681
681
  content: content,
682
+ tool_call_id: toolId,
682
683
  })];
683
684
  case 1:
684
685
  _a.sent();
@@ -697,9 +698,9 @@ var ClientAgent = /** @class */ (function () {
697
698
  this.execute = queued(function (incoming, mode) { return __awaiter(_this, void 0, void 0, function () {
698
699
  var message, _loop_1, this_1, _a, _b, tool, state_1, e_1_1, result, validation, result1;
699
700
  var e_1, _c;
700
- var _d, _e, _f, _g, _h;
701
- return __generator(this, function (_j) {
702
- switch (_j.label) {
701
+ var _d, _e, _f, _g, _h, _j;
702
+ return __generator(this, function (_k) {
703
+ switch (_k.label) {
703
704
  case 0:
704
705
  this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute begin"), { incoming: incoming, mode: mode });
705
706
  this.params.onExecute &&
@@ -711,45 +712,45 @@ var ClientAgent = /** @class */ (function () {
711
712
  content: incoming.trim(),
712
713
  })];
713
714
  case 1:
714
- _j.sent();
715
+ _k.sent();
715
716
  return [4 /*yield*/, this.getCompletion(mode)];
716
717
  case 2:
717
- message = _j.sent();
718
+ message = _k.sent();
718
719
  if (!message.tool_calls) return [3 /*break*/, 11];
719
720
  this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " tool call begin"));
720
721
  _loop_1 = function (tool) {
721
722
  var targetFn, result_2, result_3;
722
- return __generator(this, function (_k) {
723
- switch (_k.label) {
723
+ return __generator(this, function (_l) {
724
+ switch (_l.label) {
724
725
  case 0:
725
726
  targetFn = (_d = this_1.params.tools) === null || _d === void 0 ? void 0 : _d.find(function (t) { return t.function.name === tool.function.name; });
726
727
  return [4 /*yield*/, this_1.params.history.push(__assign(__assign({}, message), { agentName: this_1.params.agentName }))];
727
728
  case 1:
728
- _k.sent();
729
+ _l.sent();
729
730
  if (!!targetFn) return [3 /*break*/, 4];
730
731
  this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " functionName=").concat(tool.function.name, " tool function not found"), this_1.params.tools);
731
732
  return [4 /*yield*/, this_1._resurrectModel(mode, "No target function for ".concat(tool.function.name))];
732
733
  case 2:
733
- result_2 = _k.sent();
734
+ result_2 = _l.sent();
734
735
  this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " execute end result=").concat(result_2));
735
736
  return [4 /*yield*/, this_1._emitOuput(mode, result_2)];
736
737
  case 3:
737
- _k.sent();
738
+ _l.sent();
738
739
  return [2 /*return*/, { value: void 0 }];
739
740
  case 4:
740
741
  ((_e = targetFn.callbacks) === null || _e === void 0 ? void 0 : _e.onValidate) &&
741
742
  ((_f = targetFn.callbacks) === null || _f === void 0 ? void 0 : _f.onValidate(this_1.params.clientId, this_1.params.agentName, tool.function.arguments));
742
743
  return [4 /*yield*/, not(targetFn.validate(this_1.params.clientId, this_1.params.agentName, tool.function.arguments))];
743
744
  case 5:
744
- if (!_k.sent()) return [3 /*break*/, 8];
745
+ if (!_l.sent()) return [3 /*break*/, 8];
745
746
  this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " functionName=").concat(tool.function.name, " tool validation not passed"));
746
747
  return [4 /*yield*/, this_1._resurrectModel(mode, "Function validation failed: name=".concat(tool.function.name, " arguments=").concat(JSON.stringify(tool.function.arguments)))];
747
748
  case 6:
748
- result_3 = _k.sent();
749
+ result_3 = _l.sent();
749
750
  this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " execute end result=").concat(result_3));
750
751
  return [4 /*yield*/, this_1._emitOuput(mode, result_3)];
751
752
  case 7:
752
- _k.sent();
753
+ _l.sent();
753
754
  return [2 /*return*/, { value: void 0 }];
754
755
  case 8:
755
756
  ((_g = targetFn.callbacks) === null || _g === void 0 ? void 0 : _g.onCall) &&
@@ -757,40 +758,40 @@ var ClientAgent = /** @class */ (function () {
757
758
  /**
758
759
  * @description Do not await to avoid deadlock! The tool can send the message to other agents by emulating user messages
759
760
  */
760
- targetFn.call(this_1.params.clientId, this_1.params.agentName, tool.function.arguments);
761
+ targetFn.call((_j = tool.id) !== null && _j !== void 0 ? _j : randomString(), this_1.params.clientId, this_1.params.agentName, tool.function.arguments);
761
762
  this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " functionName=").concat(tool.function.name, " tool call executing"));
762
763
  return [4 /*yield*/, Promise.race([
763
764
  this_1._toolCommitSubject.toPromise(),
764
765
  this_1._outputSubject.toPromise(),
765
766
  ])];
766
767
  case 9:
767
- _k.sent();
768
+ _l.sent();
768
769
  this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " functionName=").concat(tool.function.name, " tool call end"));
769
770
  return [2 /*return*/];
770
771
  }
771
772
  });
772
773
  };
773
774
  this_1 = this;
774
- _j.label = 3;
775
+ _k.label = 3;
775
776
  case 3:
776
- _j.trys.push([3, 8, 9, 10]);
777
+ _k.trys.push([3, 8, 9, 10]);
777
778
  _a = __values(message.tool_calls), _b = _a.next();
778
- _j.label = 4;
779
+ _k.label = 4;
779
780
  case 4:
780
781
  if (!!_b.done) return [3 /*break*/, 7];
781
782
  tool = _b.value;
782
783
  return [5 /*yield**/, _loop_1(tool)];
783
784
  case 5:
784
- state_1 = _j.sent();
785
+ state_1 = _k.sent();
785
786
  if (typeof state_1 === "object")
786
787
  return [2 /*return*/, state_1.value];
787
- _j.label = 6;
788
+ _k.label = 6;
788
789
  case 6:
789
790
  _b = _a.next();
790
791
  return [3 /*break*/, 4];
791
792
  case 7: return [3 /*break*/, 10];
792
793
  case 8:
793
- e_1_1 = _j.sent();
794
+ e_1_1 = _k.sent();
794
795
  e_1 = { error: e_1_1 };
795
796
  return [3 /*break*/, 10];
796
797
  case 9:
@@ -807,24 +808,24 @@ var ClientAgent = /** @class */ (function () {
807
808
  result = message.content;
808
809
  return [4 /*yield*/, this.params.history.push(__assign(__assign({}, message), { agentName: this.params.agentName }))];
809
810
  case 12:
810
- _j.sent();
811
+ _k.sent();
811
812
  validation = null;
812
813
  return [4 /*yield*/, this.params.validate(result)];
813
814
  case 13:
814
- if (!(validation = _j.sent())) return [3 /*break*/, 16];
815
+ if (!(validation = _k.sent())) return [3 /*break*/, 16];
815
816
  this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute invalid tool call detected: ").concat(validation), { result: result });
816
817
  return [4 /*yield*/, this._resurrectModel(mode, "Invalid model output: ".concat(result))];
817
818
  case 14:
818
- result1 = _j.sent();
819
+ result1 = _k.sent();
819
820
  return [4 /*yield*/, this._emitOuput(mode, result1)];
820
821
  case 15:
821
- _j.sent();
822
+ _k.sent();
822
823
  return [2 /*return*/];
823
824
  case 16:
824
825
  this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute end result=").concat(result));
825
826
  return [4 /*yield*/, this._emitOuput(mode, result)];
826
827
  case 17:
827
- _j.sent();
828
+ _k.sent();
828
829
  return [2 /*return*/];
829
830
  }
830
831
  });
@@ -916,17 +917,19 @@ var AgentConnectionService = /** @class */ (function () {
916
917
  /**
917
918
  * Commits tool output.
918
919
  * @param {string} content - The tool output content.
920
+ * @param {string} toolId - The `tool_call_id` for openai history
919
921
  * @returns {Promise<any>} The commit result.
920
922
  */
921
- this.commitToolOutput = function (content) { return __awaiter(_this, void 0, void 0, function () {
923
+ this.commitToolOutput = function (toolId, content) { return __awaiter(_this, void 0, void 0, function () {
922
924
  return __generator(this, function (_a) {
923
925
  switch (_a.label) {
924
926
  case 0:
925
927
  this.loggerService.log("agentConnectionService commitToolOutput", {
926
928
  content: content,
929
+ toolId: toolId,
927
930
  context: this.contextService.context,
928
931
  });
929
- return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).commitToolOutput(content)];
932
+ return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).commitToolOutput(toolId, content)];
930
933
  case 1: return [2 /*return*/, _a.sent()];
931
934
  }
932
935
  });
@@ -1782,21 +1785,23 @@ var ClientSession = /** @class */ (function () {
1782
1785
  }); };
1783
1786
  /**
1784
1787
  * Commits tool output.
1788
+ * @param {string} toolId - The `tool_call_id` for openai history
1785
1789
  * @param {string} content - The content to commit.
1786
1790
  * @returns {Promise<void>}
1787
1791
  */
1788
- this.commitToolOutput = function (content) { return __awaiter(_this, void 0, void 0, function () {
1792
+ this.commitToolOutput = function (toolId, content) { return __awaiter(_this, void 0, void 0, function () {
1789
1793
  var agent;
1790
1794
  return __generator(this, function (_a) {
1791
1795
  switch (_a.label) {
1792
1796
  case 0:
1793
1797
  this.params.logger.debug("ClientSession clientId=".concat(this.params.clientId, " commitToolOutput"), {
1794
1798
  content: content,
1799
+ toolId: toolId,
1795
1800
  });
1796
1801
  return [4 /*yield*/, this.params.swarm.getAgent()];
1797
1802
  case 1:
1798
1803
  agent = _a.sent();
1799
- return [4 /*yield*/, agent.commitToolOutput(content)];
1804
+ return [4 /*yield*/, agent.commitToolOutput(toolId, content)];
1800
1805
  case 2: return [2 /*return*/, _a.sent()];
1801
1806
  }
1802
1807
  });
@@ -2004,18 +2009,20 @@ var SessionConnectionService = /** @class */ (function () {
2004
2009
  };
2005
2010
  /**
2006
2011
  * Commits tool output to the session.
2012
+ * @param {string} toolId - The `tool_call_id` for openai history
2007
2013
  * @param {string} content - The content to commit.
2008
2014
  * @returns {Promise<void>} A promise that resolves when the content is committed.
2009
2015
  */
2010
- this.commitToolOutput = function (content) { return __awaiter(_this, void 0, void 0, function () {
2016
+ this.commitToolOutput = function (toolId, content) { return __awaiter(_this, void 0, void 0, function () {
2011
2017
  return __generator(this, function (_a) {
2012
2018
  switch (_a.label) {
2013
2019
  case 0:
2014
2020
  this.loggerService.log("sessionConnectionService commitToolOutput", {
2015
2021
  context: this.contextService.context,
2016
2022
  content: content,
2023
+ toolId: toolId,
2017
2024
  });
2018
- return [4 /*yield*/, this.getSession(this.contextService.context.clientId, this.contextService.context.swarmName).commitToolOutput(content)];
2025
+ return [4 /*yield*/, this.getSession(this.contextService.context.clientId, this.contextService.context.swarmName).commitToolOutput(toolId, content)];
2019
2026
  case 1: return [2 /*return*/, _a.sent()];
2020
2027
  }
2021
2028
  });
@@ -2202,12 +2209,13 @@ var AgentPublicService = /** @class */ (function () {
2202
2209
  }); };
2203
2210
  /**
2204
2211
  * Commits tool output to the agent.
2212
+ * @param {string} toolId - The `tool_call_id` for openai history
2205
2213
  * @param {string} content - The content to commit.
2206
2214
  * @param {string} clientId - The client ID.
2207
2215
  * @param {AgentName} agentName - The name of the agent.
2208
2216
  * @returns {Promise<unknown>} The commit result.
2209
2217
  */
2210
- this.commitToolOutput = function (content, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
2218
+ this.commitToolOutput = function (toolId, content, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
2211
2219
  var _this = this;
2212
2220
  return __generator(this, function (_a) {
2213
2221
  switch (_a.label) {
@@ -2215,12 +2223,13 @@ var AgentPublicService = /** @class */ (function () {
2215
2223
  this.loggerService.log("agentPublicService commitToolOutput", {
2216
2224
  content: content,
2217
2225
  clientId: clientId,
2226
+ toolId: toolId,
2218
2227
  agentName: agentName,
2219
2228
  });
2220
2229
  return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
2221
2230
  return __generator(this, function (_a) {
2222
2231
  switch (_a.label) {
2223
- case 0: return [4 /*yield*/, this.agentConnectionService.commitToolOutput(content)];
2232
+ case 0: return [4 /*yield*/, this.agentConnectionService.commitToolOutput(toolId, content)];
2224
2233
  case 1: return [2 /*return*/, _a.sent()];
2225
2234
  }
2226
2235
  });
@@ -2630,17 +2639,19 @@ var SessionPublicService = /** @class */ (function () {
2630
2639
  };
2631
2640
  /**
2632
2641
  * Commits tool output to the session.
2642
+ * @param {string} toolId - The `tool_call_id` for openai history
2633
2643
  * @param {string} content - The content to commit.
2634
2644
  * @param {string} clientId - The client ID.
2635
2645
  * @param {SwarmName} swarmName - The swarm name.
2636
2646
  * @returns {Promise<void>}
2637
2647
  */
2638
- this.commitToolOutput = function (content, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
2648
+ this.commitToolOutput = function (toolId, content, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
2639
2649
  var _this = this;
2640
2650
  return __generator(this, function (_a) {
2641
2651
  switch (_a.label) {
2642
2652
  case 0:
2643
2653
  this.loggerService.log("sessionPublicService commitToolOutput", {
2654
+ toolId: toolId,
2644
2655
  content: content,
2645
2656
  clientId: clientId,
2646
2657
  swarmName: swarmName,
@@ -2648,7 +2659,7 @@ var SessionPublicService = /** @class */ (function () {
2648
2659
  return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
2649
2660
  return __generator(this, function (_a) {
2650
2661
  switch (_a.label) {
2651
- case 0: return [4 /*yield*/, this.sessionConnectionService.commitToolOutput(content)];
2662
+ case 0: return [4 /*yield*/, this.sessionConnectionService.commitToolOutput(toolId, content)];
2652
2663
  case 1: return [2 /*return*/, _a.sent()];
2653
2664
  }
2654
2665
  });
@@ -4149,12 +4160,13 @@ var getAgentHistory = function (clientId, agentName) { return __awaiter(void 0,
4149
4160
  * @param {AgentName} agentName - The name of the agent committing the output.
4150
4161
  * @returns {Promise<void>} - A promise that resolves when the operation is complete.
4151
4162
  */
4152
- var commitToolOutput = function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
4163
+ var commitToolOutput = function (toolId, content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
4153
4164
  var swarmName, currentAgentName;
4154
4165
  return __generator(this, function (_a) {
4155
4166
  switch (_a.label) {
4156
4167
  case 0:
4157
4168
  swarm.loggerService.log('function commitToolOutput', {
4169
+ toolId: toolId,
4158
4170
  content: content,
4159
4171
  clientId: clientId,
4160
4172
  agentName: agentName,
@@ -4168,13 +4180,14 @@ var commitToolOutput = function (content, clientId, agentName) { return __awaite
4168
4180
  currentAgentName = _a.sent();
4169
4181
  if (currentAgentName !== agentName) {
4170
4182
  swarm.loggerService.log('function "commitToolOutput" skipped due to the agent change', {
4183
+ toolId: toolId,
4171
4184
  currentAgentName: currentAgentName,
4172
4185
  agentName: agentName,
4173
4186
  clientId: clientId,
4174
4187
  });
4175
4188
  return [2 /*return*/];
4176
4189
  }
4177
- return [4 /*yield*/, swarm.sessionPublicService.commitToolOutput(content, clientId, swarmName)];
4190
+ return [4 /*yield*/, swarm.sessionPublicService.commitToolOutput(toolId, content, clientId, swarmName)];
4178
4191
  case 2:
4179
4192
  _a.sent();
4180
4193
  return [2 /*return*/];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-swarm-kit",
3
- "version": "1.0.37",
3
+ "version": "1.0.38",
4
4
  "description": "A TypeScript library for building orchestrated framework-agnostic multi-agent AI systems",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",
package/types.d.ts CHANGED
@@ -218,10 +218,11 @@ interface ISession {
218
218
  connect(connector: SendMessageFn$1): ReceiveMessageFn;
219
219
  /**
220
220
  * Commit tool output.
221
+ * @param {string} toolId - The `tool_call_id` for openai history
221
222
  * @param {string} content - The content to commit.
222
223
  * @returns {Promise<void>}
223
224
  */
224
- commitToolOutput(content: string): Promise<void>;
225
+ commitToolOutput(toolId: string, content: string): Promise<void>;
225
226
  /**
226
227
  * Commit user message without answer
227
228
  * @param {string} message - The message to commit.
@@ -257,6 +258,86 @@ type SessionMode = "session" | "makeConnection" | "complete";
257
258
  */
258
259
  type ExecutionMode = "tool" | "user";
259
260
 
261
+ /**
262
+ * Represents a tool call with a function name and arguments.
263
+ */
264
+ interface IToolCall {
265
+ /**
266
+ * The ID of the tool call.
267
+ */
268
+ id: string;
269
+ /**
270
+ * The type of the tool. Currently, only `function` is supported.
271
+ */
272
+ type: 'function';
273
+ /**
274
+ * The function that the model called.
275
+ */
276
+ function: {
277
+ /**
278
+ * The name of the function to be called.
279
+ */
280
+ name: string;
281
+ /**
282
+ * The arguments to be passed to the function.
283
+ */
284
+ arguments: {
285
+ [key: string]: any;
286
+ };
287
+ };
288
+ }
289
+ /**
290
+ * Represents a tool with a type and function details.
291
+ */
292
+ interface ITool {
293
+ /**
294
+ * The type of the tool.
295
+ */
296
+ type: string;
297
+ function: {
298
+ /**
299
+ * The name of the function.
300
+ */
301
+ name: string;
302
+ /**
303
+ * The description of the function.
304
+ */
305
+ description: string;
306
+ /**
307
+ * The parameters required by the function.
308
+ */
309
+ parameters: {
310
+ /**
311
+ * The type of the parameters.
312
+ */
313
+ type: string;
314
+ /**
315
+ * The list of required parameters.
316
+ */
317
+ required: string[];
318
+ /**
319
+ * The properties of the parameters.
320
+ */
321
+ properties: {
322
+ [key: string]: {
323
+ /**
324
+ * The type of the property.
325
+ */
326
+ type: string;
327
+ /**
328
+ * The description of the property.
329
+ */
330
+ description: string;
331
+ /**
332
+ * The possible values for the property.
333
+ */
334
+ enum?: string[];
335
+ };
336
+ };
337
+ };
338
+ };
339
+ }
340
+
260
341
  /**
261
342
  * Interface representing a model message.
262
343
  */
@@ -285,14 +366,11 @@ interface IModelMessage {
285
366
  * Optional tool calls associated with the message.
286
367
  * @type {Array<{ function: { name: string; arguments: { [key: string]: any; }; }; }>}
287
368
  */
288
- tool_calls?: {
289
- function: {
290
- name: string;
291
- arguments: {
292
- [key: string]: any;
293
- };
294
- };
295
- }[];
369
+ tool_calls?: IToolCall[];
370
+ /**
371
+ * Tool call that this message is responding to.
372
+ */
373
+ tool_call_id?: string;
296
374
  }
297
375
 
298
376
  /**
@@ -348,75 +426,6 @@ interface IHistorySchema {
348
426
  items: IPubsubArray<IModelMessage>;
349
427
  }
350
428
 
351
- /**
352
- * Represents a tool call with a function name and arguments.
353
- */
354
- interface IToolCall {
355
- function: {
356
- /**
357
- * The name of the function to be called.
358
- */
359
- name: string;
360
- /**
361
- * The arguments to be passed to the function.
362
- */
363
- arguments: {
364
- [key: string]: any;
365
- };
366
- };
367
- }
368
- /**
369
- * Represents a tool with a type and function details.
370
- */
371
- interface ITool {
372
- /**
373
- * The type of the tool.
374
- */
375
- type: string;
376
- function: {
377
- /**
378
- * The name of the function.
379
- */
380
- name: string;
381
- /**
382
- * The description of the function.
383
- */
384
- description: string;
385
- /**
386
- * The parameters required by the function.
387
- */
388
- parameters: {
389
- /**
390
- * The type of the parameters.
391
- */
392
- type: string;
393
- /**
394
- * The list of required parameters.
395
- */
396
- required: string[];
397
- /**
398
- * The properties of the parameters.
399
- */
400
- properties: {
401
- [key: string]: {
402
- /**
403
- * The type of the property.
404
- */
405
- type: string;
406
- /**
407
- * The description of the property.
408
- */
409
- description: string;
410
- /**
411
- * The possible values for the property.
412
- */
413
- enum?: string[];
414
- };
415
- };
416
- };
417
- };
418
- }
419
-
420
429
  /**
421
430
  * Interface representing a completion.
422
431
  */
@@ -518,7 +527,7 @@ interface IAgentTool<T = Record<string, unknown>> extends ITool {
518
527
  * @param params - The parameters for the tool.
519
528
  * @returns A promise that resolves when the tool call is complete.
520
529
  */
521
- call(clientId: string, agentName: AgentName, params: T): Promise<void>;
530
+ call(toolId: string, clientId: string, agentName: AgentName, params: T): Promise<void>;
522
531
  /**
523
532
  * Validates the parameters for the tool.
524
533
  * @param clientId - The ID of the client.
@@ -569,11 +578,12 @@ interface IAgentSchemaCallbacks {
569
578
  onExecute?: (clientId: string, agentName: AgentName, input: string, mode: ExecutionMode) => void;
570
579
  /**
571
580
  * Callback triggered when there is tool output.
581
+ * @param toolId - The `tool_call_id` for openai history
572
582
  * @param clientId - The ID of the client.
573
583
  * @param agentName - The name of the agent.
574
584
  * @param content - The content of the tool output.
575
585
  */
576
- onToolOutput?: (clientId: string, agentName: AgentName, content: string) => void;
586
+ onToolOutput?: (toolId: string, clientId: string, agentName: AgentName, content: string) => void;
577
587
  /**
578
588
  * Callback triggered when there is a system message.
579
589
  * @param clientId - The ID of the client.
@@ -665,10 +675,11 @@ interface IAgent {
665
675
  waitForOutput: () => Promise<string>;
666
676
  /**
667
677
  * Commits the tool output.
678
+ * @param {string} toolId - The `tool_call_id` for openai history
668
679
  * @param content - The content of the tool output.
669
680
  * @returns A promise that resolves when the tool output is committed.
670
681
  */
671
- commitToolOutput(content: string): Promise<void>;
682
+ commitToolOutput(toolId: string, content: string): Promise<void>;
672
683
  /**
673
684
  * Commits a system message.
674
685
  * @param message - The system message to commit.
@@ -793,7 +804,7 @@ declare class ClientAgent implements IAgent {
793
804
  * @param {string} content - The tool output content.
794
805
  * @returns {Promise<void>}
795
806
  */
796
- commitToolOutput: (content: string) => Promise<void>;
807
+ commitToolOutput: (toolId: string, content: string) => Promise<void>;
797
808
  /**
798
809
  * Executes the incoming message and processes tool calls if any.
799
810
  * @param {string} incoming - The incoming message content.
@@ -840,9 +851,10 @@ declare class AgentConnectionService implements IAgent {
840
851
  /**
841
852
  * Commits tool output.
842
853
  * @param {string} content - The tool output content.
854
+ * @param {string} toolId - The `tool_call_id` for openai history
843
855
  * @returns {Promise<any>} The commit result.
844
856
  */
845
- commitToolOutput: (content: string) => Promise<void>;
857
+ commitToolOutput: (toolId: string, content: string) => Promise<void>;
846
858
  /**
847
859
  * Commits a system message.
848
860
  * @param {string} message - The system message.
@@ -1148,10 +1160,11 @@ declare class ClientSession implements ISession {
1148
1160
  execute: (message: string, mode: ExecutionMode) => Promise<string>;
1149
1161
  /**
1150
1162
  * Commits tool output.
1163
+ * @param {string} toolId - The `tool_call_id` for openai history
1151
1164
  * @param {string} content - The content to commit.
1152
1165
  * @returns {Promise<void>}
1153
1166
  */
1154
- commitToolOutput: (content: string) => Promise<void>;
1167
+ commitToolOutput: (toolId: string, content: string) => Promise<void>;
1155
1168
  /**
1156
1169
  * Commits user message without answer.
1157
1170
  * @param {string} message - The message to commit.
@@ -1218,10 +1231,11 @@ declare class SessionConnectionService implements ISession {
1218
1231
  connect: (connector: SendMessageFn$1) => ReceiveMessageFn;
1219
1232
  /**
1220
1233
  * Commits tool output to the session.
1234
+ * @param {string} toolId - The `tool_call_id` for openai history
1221
1235
  * @param {string} content - The content to commit.
1222
1236
  * @returns {Promise<void>} A promise that resolves when the content is committed.
1223
1237
  */
1224
- commitToolOutput: (content: string) => Promise<void>;
1238
+ commitToolOutput: (toolId: string, content: string) => Promise<void>;
1225
1239
  /**
1226
1240
  * Commits a system message to the session.
1227
1241
  * @param {string} message - The message to commit.
@@ -1285,12 +1299,13 @@ declare class AgentPublicService implements TAgentConnectionService {
1285
1299
  waitForOutput: (clientId: string, agentName: AgentName) => Promise<string>;
1286
1300
  /**
1287
1301
  * Commits tool output to the agent.
1302
+ * @param {string} toolId - The `tool_call_id` for openai history
1288
1303
  * @param {string} content - The content to commit.
1289
1304
  * @param {string} clientId - The client ID.
1290
1305
  * @param {AgentName} agentName - The name of the agent.
1291
1306
  * @returns {Promise<unknown>} The commit result.
1292
1307
  */
1293
- commitToolOutput: (content: string, clientId: string, agentName: AgentName) => Promise<void>;
1308
+ commitToolOutput: (toolId: string, content: string, clientId: string, agentName: AgentName) => Promise<void>;
1294
1309
  /**
1295
1310
  * Commits a system message to the agent.
1296
1311
  * @param {string} message - The message to commit.
@@ -1410,12 +1425,13 @@ declare class SessionPublicService implements TSessionConnectionService {
1410
1425
  connect: (connector: SendMessageFn$1, clientId: string, swarmName: SwarmName) => ReceiveMessageFn;
1411
1426
  /**
1412
1427
  * Commits tool output to the session.
1428
+ * @param {string} toolId - The `tool_call_id` for openai history
1413
1429
  * @param {string} content - The content to commit.
1414
1430
  * @param {string} clientId - The client ID.
1415
1431
  * @param {SwarmName} swarmName - The swarm name.
1416
1432
  * @returns {Promise<void>}
1417
1433
  */
1418
- commitToolOutput: (content: string, clientId: string, swarmName: SwarmName) => Promise<void>;
1434
+ commitToolOutput: (toolId: string, content: string, clientId: string, swarmName: SwarmName) => Promise<void>;
1419
1435
  /**
1420
1436
  * Commits a system message to the session.
1421
1437
  * @param {string} message - The message to commit.
@@ -1907,7 +1923,7 @@ declare const getAgentHistory: (clientId: string, agentName: AgentName) => Promi
1907
1923
  * @param {AgentName} agentName - The name of the agent committing the output.
1908
1924
  * @returns {Promise<void>} - A promise that resolves when the operation is complete.
1909
1925
  */
1910
- declare const commitToolOutput: (content: string, clientId: string, agentName: AgentName) => Promise<void>;
1926
+ declare const commitToolOutput: (toolId: string, content: string, clientId: string, agentName: AgentName) => Promise<void>;
1911
1927
 
1912
1928
  /**
1913
1929
  * Commits a system message to the active agent in as swarm.