Skip to content

Commit 8247670

Browse files
committed
patch
1 parent df76070 commit 8247670

5 files changed

Lines changed: 67 additions & 12 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "agent-swarm-kit",
3-
"version": "1.1.144",
3+
"version": "1.1.145",
44
"description": "A TypeScript library for building orchestrated framework-agnostic multi-agent AI systems",
55
"author": {
66
"name": "Petr Tripolsky",

src/functions/target/executeForce.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { randomString } from "functools-kit";
22
import swarm, { ExecutionContextService } from "../../lib";
33
import { GLOBAL_CONFIG } from "../../config/params";
44
import beginContext from "../../utils/beginContext";
5+
import { errorSubject } from "../../config/emitters";
56

67
const METHOD_NAME = "function.target.executeForce";
78

@@ -32,24 +33,42 @@ const executeForceInternal = beginContext(
3233
swarm.perfService.startExecution(executionId, clientId, content.length);
3334
try {
3435
swarm.busService.commitExecutionBegin(clientId, { swarmName });
35-
const result = await swarm.sessionPublicService.execute(
36+
37+
let result = "";
38+
let errorValue = null;
39+
40+
const unError = errorSubject.once(([errorClientId, error]) => {
41+
if (clientId === errorClientId) {
42+
errorValue = error;
43+
}
44+
});
45+
46+
result = await swarm.sessionPublicService.execute(
3647
content,
3748
"tool",
3849
METHOD_NAME,
3950
clientId,
4051
swarmName
4152
);
53+
54+
unError();
55+
56+
if (errorValue) {
57+
throw errorValue;
58+
}
59+
4260
isFinished = swarm.perfService.endExecution(
4361
executionId,
4462
clientId,
4563
result.length
4664
);
47-
swarm.busService.commitExecutionEnd(clientId, { swarmName });
65+
4866
return result;
4967
} finally {
5068
if (!isFinished) {
5169
swarm.perfService.endExecution(executionId, clientId, 0);
5270
}
71+
swarm.busService.commitExecutionEnd(clientId, { swarmName });
5372
swarm.executionValidationService.decrementCount(executionId, clientId, swarmName);
5473
}
5574
},

src/functions/target/runStateless.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { AgentName } from "../../interfaces/Agent.interface";
33
import { GLOBAL_CONFIG } from "../../config/params";
44
import swarm, { ExecutionContextService } from "../../lib";
55
import beginContext from "../../utils/beginContext";
6+
import { errorSubject } from "../../config/emitters";
67

78
const METHOD_NAME = "function.target.runStateless";
89

@@ -57,26 +58,43 @@ const runStatelessInternal = beginContext(
5758
agentName,
5859
swarmName,
5960
});
60-
const result = await swarm.sessionPublicService.run(
61+
62+
let result = "";
63+
let errorValue = null;
64+
65+
const unError = errorSubject.once(([errorClientId, error]) => {
66+
if (clientId === errorClientId) {
67+
errorValue = error;
68+
}
69+
});
70+
71+
result = await swarm.sessionPublicService.run(
6172
content,
6273
METHOD_NAME,
6374
clientId,
6475
swarmName
6576
);
77+
78+
unError();
79+
80+
if (errorValue) {
81+
throw errorValue;
82+
}
83+
6684
isFinished = swarm.perfService.endExecution(
6785
executionId,
6886
clientId,
6987
result.length
7088
);
71-
swarm.busService.commitExecutionEnd(clientId, {
72-
agentName,
73-
swarmName,
74-
});
7589
return result;
7690
} finally {
7791
if (!isFinished) {
7892
swarm.perfService.endExecution(executionId, clientId, 0);
7993
}
94+
swarm.busService.commitExecutionEnd(clientId, {
95+
agentName,
96+
swarmName,
97+
});
8098
swarm.executionValidationService.decrementCount(executionId, clientId, swarmName);
8199
}
82100
},

src/functions/target/runStatelessForce.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { randomString } from "functools-kit";
22
import swarm, { ExecutionContextService } from "../../lib";
33
import { GLOBAL_CONFIG } from "../../config/params";
44
import beginContext from "../../utils/beginContext";
5+
import { errorSubject } from "../../config/emitters";
56

67
const METHOD_NAME = "function.target.runStatelessForce";
78

@@ -32,23 +33,40 @@ const runStatelessForceInternal = beginContext(
3233
swarm.perfService.startExecution(executionId, clientId, content.length);
3334
try {
3435
swarm.busService.commitExecutionBegin(clientId, { swarmName });
35-
const result = await swarm.sessionPublicService.run(
36+
37+
let result = "";
38+
let errorValue = null;
39+
40+
const unError = errorSubject.once(([errorClientId, error]) => {
41+
if (clientId === errorClientId) {
42+
errorValue = error;
43+
}
44+
});
45+
46+
result = await swarm.sessionPublicService.run(
3647
content,
3748
METHOD_NAME,
3849
clientId,
3950
swarmName
4051
);
52+
53+
unError();
54+
55+
if (errorValue) {
56+
throw errorValue;
57+
}
58+
4159
isFinished = swarm.perfService.endExecution(
4260
executionId,
4361
clientId,
4462
result.length
4563
);
46-
swarm.busService.commitExecutionEnd(clientId, { swarmName });
4764
return result;
4865
} finally {
4966
if (!isFinished) {
5067
swarm.perfService.endExecution(executionId, clientId, 0);
5168
}
69+
swarm.busService.commitExecutionEnd(clientId, { swarmName });
5270
swarm.executionValidationService.decrementCount(executionId, clientId, swarmName);
5371
}
5472
},

0 commit comments

Comments
 (0)