@aigne/core 1.24.1 → 1.26.0

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/CHANGELOG.md CHANGED
@@ -12,6 +12,39 @@
12
12
  * dependencies
13
13
  * @aigne/observability bumped to 0.1.0
14
14
 
15
+ ## [1.26.0](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.25.0...core-v1.26.0) (2025-06-30)
16
+
17
+
18
+ ### Features
19
+
20
+ * **ux:** polish tracing ux and update docs ([#193](https://github.com/AIGNE-io/aigne-framework/issues/193)) ([f80b63e](https://github.com/AIGNE-io/aigne-framework/commit/f80b63ecb1cfb00daa9b68330026da839d33f8a2))
21
+
22
+
23
+ ### Dependencies
24
+
25
+ * The following workspace dependencies were updated
26
+ * dependencies
27
+ * @aigne/observability bumped to 0.3.0
28
+
29
+ ## [1.25.0](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.24.1...core-v1.25.0) (2025-06-29)
30
+
31
+
32
+ ### Features
33
+
34
+ * **observability:** tune trace ux and supoort incremental exporting ([#184](https://github.com/AIGNE-io/aigne-framework/issues/184)) ([d174188](https://github.com/AIGNE-io/aigne-framework/commit/d174188459c77acb09b5ca040972f83abb067587))
35
+
36
+
37
+ ### Bug Fixes
38
+
39
+ * **core:** enable proper tracing for agent calls via message queue ([#191](https://github.com/AIGNE-io/aigne-framework/issues/191)) ([f8a4ce5](https://github.com/AIGNE-io/aigne-framework/commit/f8a4ce5fa54e0e01113b31fefcbd248b163980b2))
40
+
41
+
42
+ ### Dependencies
43
+
44
+ * The following workspace dependencies were updated
45
+ * dependencies
46
+ * @aigne/observability bumped to 0.2.0
47
+
15
48
  ## [1.24.1](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.24.0...core-v1.24.1) (2025-06-26)
16
49
 
17
50
 
@@ -272,7 +272,7 @@ class Agent {
272
272
  }
273
273
  async onMessage({ message, context }) {
274
274
  try {
275
- await context.invoke(this, message);
275
+ await context.invoke(this, message, { newContext: false });
276
276
  }
277
277
  catch (error) {
278
278
  context.emit("agentFailed", { agent: this, error });
@@ -524,11 +524,15 @@ class Agent {
524
524
  }
525
525
  async publishToTopics(output, options) {
526
526
  const publishTopics = typeof this.publishTopic === "function" ? await this.publishTopic(output) : this.publishTopic;
527
+ const role = this.constructor.name === "UserAgent" ? "user" : "agent";
527
528
  if (publishTopics?.length) {
528
- options.context.publish(publishTopics, {
529
- role: this.constructor.name === "UserAgent" ? "user" : "agent",
529
+ const ctx = role === "user" ? options.context.newContext({ reset: true }) : options.context;
530
+ ctx.publish(publishTopics, {
531
+ role,
530
532
  source: this.name,
531
533
  message: output,
534
+ }, {
535
+ newContext: role !== "user",
532
536
  });
533
537
  }
534
538
  }
@@ -49,7 +49,7 @@ class UserAgent extends agent_js_1.Agent {
49
49
  }
50
50
  const publicTopic = typeof this.publishTopic === "function" ? await this.publishTopic(input) : this.publishTopic;
51
51
  if (publicTopic?.length) {
52
- options.context.publish(publicTopic, input);
52
+ options.context.publish(publicTopic, input, { newContext: false });
53
53
  if (this.subscribeTopic) {
54
54
  return this.subscribe(this.subscribeTopic).then((res) => res.message);
55
55
  }
@@ -166,9 +166,10 @@ class AIGNEContext {
166
166
  this.memories.push(...options.memories);
167
167
  options.memories = undefined;
168
168
  }
169
+ const newContext = options?.newContext === false ? this : this.newContext();
169
170
  return this.internal.messageQueue.publish(topic, {
170
171
  ...(0, message_queue_js_1.toMessagePayload)(payload),
171
- context: this,
172
+ context: newContext,
172
173
  });
173
174
  });
174
175
  subscribe = ((...args) => {
@@ -205,6 +206,21 @@ class AIGNEContext {
205
206
  span.setAttribute("custom.started_at", b.timestamp);
206
207
  span.setAttribute("input", JSON.stringify(input));
207
208
  span.setAttribute("agentTag", agent.tag ?? "UnknownAgent");
209
+ try {
210
+ span.setAttribute("userContext", JSON.stringify(this.userContext));
211
+ }
212
+ catch (_e) {
213
+ logger_js_1.logger.error("parse userContext error", _e.message);
214
+ span.setAttribute("userContext", JSON.stringify({}));
215
+ }
216
+ try {
217
+ span.setAttribute("memories", JSON.stringify(this.memories));
218
+ }
219
+ catch (_e) {
220
+ logger_js_1.logger.error("parse memories error", _e.message);
221
+ span.setAttribute("memories", JSON.stringify([]));
222
+ }
223
+ await this.observer?.traceExporter?.insertInitialSpan?.(span);
208
224
  break;
209
225
  }
210
226
  case "agentSucceed": {
@@ -228,7 +228,7 @@ export class Agent {
228
228
  }
229
229
  async onMessage({ message, context }) {
230
230
  try {
231
- await context.invoke(this, message);
231
+ await context.invoke(this, message, { newContext: false });
232
232
  }
233
233
  catch (error) {
234
234
  context.emit("agentFailed", { agent: this, error });
@@ -480,11 +480,15 @@ export class Agent {
480
480
  }
481
481
  async publishToTopics(output, options) {
482
482
  const publishTopics = typeof this.publishTopic === "function" ? await this.publishTopic(output) : this.publishTopic;
483
+ const role = this.constructor.name === "UserAgent" ? "user" : "agent";
483
484
  if (publishTopics?.length) {
484
- options.context.publish(publishTopics, {
485
- role: this.constructor.name === "UserAgent" ? "user" : "agent",
485
+ const ctx = role === "user" ? options.context.newContext({ reset: true }) : options.context;
486
+ ctx.publish(publishTopics, {
487
+ role,
486
488
  source: this.name,
487
489
  message: output,
490
+ }, {
491
+ newContext: role !== "user",
488
492
  });
489
493
  }
490
494
  }
@@ -46,7 +46,7 @@ export class UserAgent extends Agent {
46
46
  }
47
47
  const publicTopic = typeof this.publishTopic === "function" ? await this.publishTopic(input) : this.publishTopic;
48
48
  if (publicTopic?.length) {
49
- options.context.publish(publicTopic, input);
49
+ options.context.publish(publicTopic, input, { newContext: false });
50
50
  if (this.subscribeTopic) {
51
51
  return this.subscribe(this.subscribeTopic).then((res) => res.message);
52
52
  }
@@ -160,9 +160,10 @@ export class AIGNEContext {
160
160
  this.memories.push(...options.memories);
161
161
  options.memories = undefined;
162
162
  }
163
+ const newContext = options?.newContext === false ? this : this.newContext();
163
164
  return this.internal.messageQueue.publish(topic, {
164
165
  ...toMessagePayload(payload),
165
- context: this,
166
+ context: newContext,
166
167
  });
167
168
  });
168
169
  subscribe = ((...args) => {
@@ -199,6 +200,21 @@ export class AIGNEContext {
199
200
  span.setAttribute("custom.started_at", b.timestamp);
200
201
  span.setAttribute("input", JSON.stringify(input));
201
202
  span.setAttribute("agentTag", agent.tag ?? "UnknownAgent");
203
+ try {
204
+ span.setAttribute("userContext", JSON.stringify(this.userContext));
205
+ }
206
+ catch (_e) {
207
+ logger.error("parse userContext error", _e.message);
208
+ span.setAttribute("userContext", JSON.stringify({}));
209
+ }
210
+ try {
211
+ span.setAttribute("memories", JSON.stringify(this.memories));
212
+ }
213
+ catch (_e) {
214
+ logger.error("parse memories error", _e.message);
215
+ span.setAttribute("memories", JSON.stringify([]));
216
+ }
217
+ await this.observer?.traceExporter?.insertInitialSpan?.(span);
202
218
  break;
203
219
  }
204
220
  case "agentSucceed": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/core",
3
- "version": "1.24.1",
3
+ "version": "1.26.0",
4
4
  "description": "AIGNE core library for building AI-powered applications",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -82,7 +82,7 @@
82
82
  "zod": "^3.24.4",
83
83
  "zod-to-json-schema": "^3.24.5",
84
84
  "@aigne/platform-helpers": "^0.1.2",
85
- "@aigne/observability": "^0.1.3"
85
+ "@aigne/observability": "^0.3.0"
86
86
  },
87
87
  "devDependencies": {
88
88
  "@types/bun": "^1.2.12",