@aigne/core 1.69.0 → 1.69.1-beta

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
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.69.1-beta](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.69.0...core-v1.69.1-beta) (2025-11-24)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **observability:** prevent OOM by optimizing trace data storage strategy ([#767](https://github.com/AIGNE-io/aigne-framework/issues/767)) ([acd6476](https://github.com/AIGNE-io/aigne-framework/commit/acd6476936423c2186cb633086177541b0c0b558))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @aigne/observability-api bumped to 0.11.10-beta
16
+
3
17
  ## [1.69.0](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.69.0-beta.2...core-v1.69.0) (2025-11-21)
4
18
 
5
19
 
@@ -199,6 +199,8 @@ class AIGNE {
199
199
  * {@includeCode ../../test/aigne/aigne.test.ts#example-shutdown}
200
200
  */
201
201
  async shutdown() {
202
+ // Close observer first to flush any pending traces
203
+ await this.observer?.close();
202
204
  for (const tool of this.skills) {
203
205
  await tool.shutdown();
204
206
  }
@@ -149,6 +149,7 @@ export interface Context<U extends UserContext = UserContext> extends TypedEvent
149
149
  * @hidden
150
150
  */
151
151
  export declare class AIGNEContext implements Context {
152
+ static exitCount: number;
152
153
  constructor(parent?: ConstructorParameters<typeof AIGNEContextShared>[0], { reset }?: {
153
154
  reset?: boolean;
154
155
  });
@@ -23,6 +23,7 @@ const usage_js_1 = require("./usage.js");
23
23
  * @hidden
24
24
  */
25
25
  class AIGNEContext {
26
+ static exitCount = 0;
26
27
  constructor(parent, { reset } = {}) {
27
28
  const tracer = parent?.observer?.tracer;
28
29
  if (parent instanceof AIGNEContext && !reset) {
@@ -205,19 +206,20 @@ class AIGNEContext {
205
206
  initProcessExitHandler() {
206
207
  if (this.parentId)
207
208
  return;
209
+ AIGNEContext.exitCount++;
208
210
  process.once("SIGINT", async () => {
209
211
  try {
210
212
  if (process.env.AIGNE_OBSERVABILITY_DISABLED)
211
213
  return;
212
- const span = this.span;
213
- if (!span)
214
- return;
215
- span.setStatus({ code: api_1.SpanStatusCode.ERROR, message: "SIGINT" });
216
- span.end();
217
- await this.observer?.flush(span);
214
+ await this.observer?.update(this.id, {
215
+ status: { code: api_1.SpanStatusCode.ERROR, message: "SIGINT" },
216
+ });
218
217
  }
219
218
  finally {
220
- process.exit(0);
219
+ AIGNEContext.exitCount--;
220
+ if (AIGNEContext.exitCount === 0) {
221
+ process.exit(0);
222
+ }
221
223
  }
222
224
  });
223
225
  }
@@ -239,37 +241,21 @@ class AIGNEContext {
239
241
  }
240
242
  span.setAttribute("metadata", JSON.stringify(this.internal.metadata ?? {}));
241
243
  span.setAttribute("custom.started_at", b.timestamp);
242
- span.setAttribute("input", JSON.stringify(input));
243
244
  span.setAttribute("agentTag", agent.tag ?? "UnknownAgent");
244
245
  if (taskTitle) {
245
246
  span.setAttribute("taskTitle", taskTitle);
246
247
  }
247
- try {
248
- span.setAttribute("userContext", JSON.stringify(this.userContext));
249
- }
250
- catch (_e) {
251
- logger_js_1.logger.error("parse userContext error", _e.message);
252
- span.setAttribute("userContext", JSON.stringify({}));
253
- }
254
- try {
255
- span.setAttribute("memories", JSON.stringify(this.memories));
256
- }
257
- catch (_e) {
258
- logger_js_1.logger.error("parse memories error", _e.message);
259
- span.setAttribute("memories", JSON.stringify([]));
260
- }
261
248
  await this.observer?.flush(span);
249
+ await this.observer?.update(this.id, {
250
+ input,
251
+ memories: this.memories,
252
+ userContext: this.userContext,
253
+ });
262
254
  break;
263
255
  }
264
256
  case "agentSucceed": {
265
257
  const { output } = args[0];
266
- try {
267
- span.setAttribute("output", JSON.stringify(output));
268
- }
269
- catch (_e) {
270
- logger_js_1.logger.error("parse output error", _e.message);
271
- span.setAttribute("output", JSON.stringify({}));
272
- }
258
+ await this.observer?.update(this.id, { output });
273
259
  span.setStatus({ code: api_1.SpanStatusCode.OK });
274
260
  span.end();
275
261
  break;
@@ -149,6 +149,7 @@ export interface Context<U extends UserContext = UserContext> extends TypedEvent
149
149
  * @hidden
150
150
  */
151
151
  export declare class AIGNEContext implements Context {
152
+ static exitCount: number;
152
153
  constructor(parent?: ConstructorParameters<typeof AIGNEContextShared>[0], { reset }?: {
153
154
  reset?: boolean;
154
155
  });
@@ -196,6 +196,8 @@ export class AIGNE {
196
196
  * {@includeCode ../../test/aigne/aigne.test.ts#example-shutdown}
197
197
  */
198
198
  async shutdown() {
199
+ // Close observer first to flush any pending traces
200
+ await this.observer?.close();
199
201
  for (const tool of this.skills) {
200
202
  await tool.shutdown();
201
203
  }
@@ -149,6 +149,7 @@ export interface Context<U extends UserContext = UserContext> extends TypedEvent
149
149
  * @hidden
150
150
  */
151
151
  export declare class AIGNEContext implements Context {
152
+ static exitCount: number;
152
153
  constructor(parent?: ConstructorParameters<typeof AIGNEContextShared>[0], { reset }?: {
153
154
  reset?: boolean;
154
155
  });
@@ -17,6 +17,7 @@ import { newEmptyContextUsage } from "./usage.js";
17
17
  * @hidden
18
18
  */
19
19
  export class AIGNEContext {
20
+ static exitCount = 0;
20
21
  constructor(parent, { reset } = {}) {
21
22
  const tracer = parent?.observer?.tracer;
22
23
  if (parent instanceof AIGNEContext && !reset) {
@@ -199,19 +200,20 @@ export class AIGNEContext {
199
200
  initProcessExitHandler() {
200
201
  if (this.parentId)
201
202
  return;
203
+ AIGNEContext.exitCount++;
202
204
  process.once("SIGINT", async () => {
203
205
  try {
204
206
  if (process.env.AIGNE_OBSERVABILITY_DISABLED)
205
207
  return;
206
- const span = this.span;
207
- if (!span)
208
- return;
209
- span.setStatus({ code: SpanStatusCode.ERROR, message: "SIGINT" });
210
- span.end();
211
- await this.observer?.flush(span);
208
+ await this.observer?.update(this.id, {
209
+ status: { code: SpanStatusCode.ERROR, message: "SIGINT" },
210
+ });
212
211
  }
213
212
  finally {
214
- process.exit(0);
213
+ AIGNEContext.exitCount--;
214
+ if (AIGNEContext.exitCount === 0) {
215
+ process.exit(0);
216
+ }
215
217
  }
216
218
  });
217
219
  }
@@ -233,37 +235,21 @@ export class AIGNEContext {
233
235
  }
234
236
  span.setAttribute("metadata", JSON.stringify(this.internal.metadata ?? {}));
235
237
  span.setAttribute("custom.started_at", b.timestamp);
236
- span.setAttribute("input", JSON.stringify(input));
237
238
  span.setAttribute("agentTag", agent.tag ?? "UnknownAgent");
238
239
  if (taskTitle) {
239
240
  span.setAttribute("taskTitle", taskTitle);
240
241
  }
241
- try {
242
- span.setAttribute("userContext", JSON.stringify(this.userContext));
243
- }
244
- catch (_e) {
245
- logger.error("parse userContext error", _e.message);
246
- span.setAttribute("userContext", JSON.stringify({}));
247
- }
248
- try {
249
- span.setAttribute("memories", JSON.stringify(this.memories));
250
- }
251
- catch (_e) {
252
- logger.error("parse memories error", _e.message);
253
- span.setAttribute("memories", JSON.stringify([]));
254
- }
255
242
  await this.observer?.flush(span);
243
+ await this.observer?.update(this.id, {
244
+ input,
245
+ memories: this.memories,
246
+ userContext: this.userContext,
247
+ });
256
248
  break;
257
249
  }
258
250
  case "agentSucceed": {
259
251
  const { output } = args[0];
260
- try {
261
- span.setAttribute("output", JSON.stringify(output));
262
- }
263
- catch (_e) {
264
- logger.error("parse output error", _e.message);
265
- span.setAttribute("output", JSON.stringify({}));
266
- }
252
+ await this.observer?.update(this.id, { output });
267
253
  span.setStatus({ code: SpanStatusCode.OK });
268
254
  span.end();
269
255
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/core",
3
- "version": "1.69.0",
3
+ "version": "1.69.1-beta",
4
4
  "description": "The functional core of agentic AI",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -93,9 +93,9 @@
93
93
  "zod-from-json-schema": "^0.0.5",
94
94
  "zod-to-json-schema": "^3.24.6",
95
95
  "@aigne/afs": "^1.2.1",
96
- "@aigne/afs-history": "^1.1.0",
97
96
  "@aigne/platform-helpers": "^0.6.4",
98
- "@aigne/observability-api": "^0.11.9"
97
+ "@aigne/afs-history": "^1.1.0",
98
+ "@aigne/observability-api": "^0.11.10-beta"
99
99
  },
100
100
  "devDependencies": {
101
101
  "@types/bun": "^1.2.22",