@slopus/happy-agent-base 0.0.8 → 0.0.10

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/README.md CHANGED
@@ -60,14 +60,14 @@ validation, rendering, and automatic result commit in one outer transaction. It
60
60
 
61
61
  Modules may provide an ordered array of `[key, migration]` tuples. Agent base tracks each
62
62
  successful key and runs every missing migration transactionally before any `beforeStart` hook; a
63
- failure aborts system startup. Every module migration and hook scope carries a schema-aware common
64
- Drizzle facade: a root database outside a transaction and its active transaction facade inside
65
- one. Driver-only root members such as `$client` and `batch` are deliberately not part of that
66
- surface. Modules may implement `beforeStart(ctx, agents, database)` and
67
- `afterStart(ctx, agents, database)` hooks.
63
+ failure aborts system startup. Every module migration and hook context carries the common Drizzle
64
+ facade in `ctx.db`: a root database outside a transaction and its active transaction facade inside
65
+ one. A migration also receives that facade explicitly to retain its exact engine-specific type.
66
+ Driver-only root members such as `$client` and `batch` are deliberately not part of that surface.
67
+ Modules may implement `beforeStart(ctx, agents)` and `afterStart(ctx, agents)` hooks.
68
68
  Every `beforeStart` settles successfully before active agents are restored; every `afterStart`
69
- runs after those agents are restored and started. Both receive the system's `AgentSystemRef` and
70
- root database.
69
+ runs after those agents are restored and started. Both receive the system's `AgentSystemRef`; their
70
+ context carries the root database.
71
71
  All hooks may return synchronously or with a promise, including `onEvent`; the runtime awaits each
72
72
  answer and contains failures from observing hooks.
73
73
 
@@ -97,6 +97,17 @@ the default parent, while creation options may override the parent or explicitly
97
97
  tool's call-bound KV, it supplies retry-stable operation identities without heap state or provider
98
98
  call IDs.
99
99
 
100
+ Agent hooks also receive `agentHistoryKV(ctx)`, exposed to modules as `scope.historyKV`. It is
101
+ durable across turns and restarts but belongs only to the current conversation history: successful
102
+ compaction and incompatible model resets clear it atomically with the replaced history and expire
103
+ retained old handles. Lifecycle action hooks may return `{ type: "inject", message }` to queue a
104
+ system notice. Notices are durable and append only after pending tool results and compaction have
105
+ settled, immediately before the inference that should see them.
106
+ Compaction exposes `beforeCompaction`, transactional `historyErasedTransact`, and
107
+ `afterCompaction` hooks. The middle hook runs after the old records and history KV are cleared but
108
+ before replacement history is appended, so its writes and the replacement commit or roll back
109
+ together.
110
+
100
111
  This package contains no ready-made product modules. Reusable tools, hooks, permissions,
101
112
  workspaces, search, workflows, and other capabilities belong in
102
113
  [`@slopus/happy-agent-features`](../happy-agent-features). Provider protocols and vendor
@@ -1 +1 @@
1
- {"version":3,"file":"Agent.d.ts","sourceRoot":"","sources":["../sources/Agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAwB,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACxF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAGlD,OAAO,EAEH,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACxB,MAAM,gBAAgB,CAAC;AAcxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAuB,MAAM,oBAAoB,CAAC;AAC7E,OAAO,KAAK,EAAE,WAAW,EAAoB,MAAM,kBAAkB,CAAC;AAGtE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;GAGG;AACH,MAAM,WAAW,YAAY,CACzB,IAAI,SAAS,YAAY,GAAG,YAAY,EACxC,QAAQ,SAAS,aAAa,GAAG,aAAa,CAChD,SAAQ,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACrC,sFAAsF;IACtF,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,WAAW,CAAC,IAAI,EAAE,QAAQ,CAA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,CAEjC;IAED,+EAA+E;IACzE,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAE1E;IAED,gFAAgF;IAC1E,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAExE;IAED,6EAA6E;IACvE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3B;IAED;;;OAGG;IACG,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAEnC;CACJ"}
package/dist/Agent.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { agentConfig } from "./AgentConfig.js";
2
2
  import { AgentBase, } from "./AgentBase.js";
3
- import { agentDatabase, agentEffort, agentKV, agentModel, agentPermissionMode, agentProvider, agentRunKV, agentServiceTier, withAgentKV, withAgentRunKV, } from "./AgentContexts.js";
3
+ import { agentDatabase, agentEffort, agentHistoryKV, agentKV, agentModel, agentPermissionMode, agentProvider, agentRunKV, agentServiceTier, withAgentKV, withAgentHistoryKV, withAgentRunKV, } from "./AgentContexts.js";
4
4
  /**
5
5
  * A thin wrapper around `AgentBase` that assembles its behavior from modules. Each module
6
6
  * implements any subset of the agent hooks on its own; the agent merges them into the singular
@@ -234,6 +234,9 @@ function mergeModules(modules, options, sharedKV) {
234
234
  return tools;
235
235
  },
236
236
  }),
237
+ ...spread("beforeCompaction", fanOut((module) => module.beforeCompaction)),
238
+ ...spread("historyErasedTransact", chain((module) => module.historyErasedTransact)),
239
+ ...spread("afterCompaction", fanOut((module) => module.afterCompaction)),
237
240
  ...spread("beforeToolCallTransact", chain((module) => module.beforeToolCallTransact)),
238
241
  ...(withBeforeToolCall.length === 0
239
242
  ? {}
@@ -329,34 +332,40 @@ function mergeModules(modules, options, sharedKV) {
329
332
  };
330
333
  }
331
334
  /**
332
- * The context a module's hooks run on: the agent's context with both key-value stores narrowed
335
+ * The context a module's hooks run on: the agent's context with its key-value stores narrowed
333
336
  * to the module's own name, so modules never see each other's persisted entries — and neither
334
337
  * does a tool one of them runs.
335
338
  */
336
339
  function moduleCtx(ctx, module) {
337
340
  const kv = agentKV(ctx);
341
+ const historyKV = agentHistoryKV(ctx);
338
342
  const runKV = agentRunKV(ctx);
339
343
  const scoped = kv === undefined ? ctx : withAgentKV(ctx, kv.scoped("module", module.name));
340
- return runKV === undefined
344
+ const withHistory = historyKV === undefined
341
345
  ? scoped
342
- : withAgentRunKV(scoped, runKV.scoped("module", module.name));
346
+ : withAgentHistoryKV(scoped, historyKV.scoped("module", module.name));
347
+ return runKV === undefined
348
+ ? withHistory
349
+ : withAgentRunKV(withHistory, runKV.scoped("module", module.name));
343
350
  }
344
351
  /**
345
352
  * What a module's hook is handed alongside the context: the agent it is serving, and its own
346
- * scope of each of the three stores. The selection comes from the context the agent derived for
353
+ * scope of each store. The selection comes from the context the agent derived for
347
354
  * this call, so a hook always sees the model, effort, and tier the work is actually running on
348
355
  * rather than the ones the agent was built with.
349
356
  */
350
357
  function moduleScope(ctx, module, options, sharedKV) {
351
358
  const kv = agentKV(ctx);
359
+ const historyKV = agentHistoryKV(ctx);
352
360
  const runKV = agentRunKV(ctx);
353
- const database = agentDatabase(ctx);
354
- if (kv === undefined || runKV === undefined || database === undefined) {
361
+ if (kv === undefined ||
362
+ historyKV === undefined ||
363
+ runKV === undefined ||
364
+ agentDatabase(ctx) === undefined) {
355
365
  throw new Error(`The module "${module.name}" was called without its agent storage context.`);
356
366
  }
357
367
  const provider = agentProvider(ctx) ?? options.provider;
358
368
  return {
359
- database: database,
360
369
  agent: {
361
370
  id: options.id,
362
371
  metadata: agentConfig(ctx)?.metadata,
@@ -370,6 +379,7 @@ function moduleScope(ctx, module, options, sharedKV) {
370
379
  kv: kv.scoped("module", module.name),
371
380
  sharedKV: sharedKV.scoped(module.name),
372
381
  runKV: runKV.scoped("module", module.name),
382
+ historyKV: historyKV.scoped("module", module.name),
373
383
  };
374
384
  }
375
385
  /**
package/dist/Agent.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Agent.js","sourceRoot":"","sources":["../sources/Agent.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EACH,SAAS,GAIZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACH,aAAa,EACb,WAAW,EACX,OAAO,EACP,UAAU,EACV,mBAAmB,EACnB,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,cAAc,GACjB,MAAM,oBAAoB,CAAC;AA6B5B;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,KAAK;IAId,yFAAyF;IAChF,KAAK,CAAY;IAC1B,4FAA4F;IACnF,QAAQ,CAAyC;IAE1D;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,MAAM,CAGjB,GAAY,EAAE,OAAqC;QACjD,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;QACzC,OAAO,IAAI,KAAK,CAAC,MAAM,SAAS,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;IACjE,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,IAAI,CAGf,GAAY,EAAE,OAAqC;QACjD,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;QACzC,OAAO,IAAI,KAAK,CAAC,MAAM,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;IAC/D,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,UAAU,CAInB,GAAY,EACZ,OAAqC;QAErC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;QACzC,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,U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AAE,OAAO,EACZ,OAAO,EAAE,kBAAkB,EAC3B,OAAO,CAAC,EAAE,uBAAuB,GAAG,qBAAqB,GAC1D,OAAO,CAAC,sBAAsB,CAAC,CAEjC;IAED;;;OAGG;IACG,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAkDvE;IAuND;;;;OAIG;IACH,KAAK,IAAI,IAAI,CAGZ;IAED;;;;;OAKG;IACG,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAKjC;IAED;;;;;;;;;OASG;IACG,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAuB1E;IAmGD;;;;;;;;;;;OAWG;IACG,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBxE;IAgBD;;;;;;;;;;;;;;;;OAgBG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAuD3B;IAED;;;;OAIG;IACG,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAInC;CAgkEJ"}
package/dist/AgentBase.js CHANGED
@@ -4,7 +4,7 @@ import { AsyncLocalStorage } from "node:async_hooks";
4
4
  import { Type } from "@sinclair/typebox";
5
5
  import { Value } from "@sinclair/typebox/value";
6
6
  import { afterCommit, asyncLock, createContextNamespace, deterministicStringify, withLifetime, } from "@steve.kite/stdlib";
7
- import { agentDatabase, agentKV, agentStorageTransaction, withAgentContext, withAgentDatabase, withAgentKV, withAgentPermissionMode, withAgentRunKV, withoutAgentStorageTransaction, } from "./AgentContexts.js";
7
+ import { agentDatabase, agentKV, agentStorageTransaction, withAgentContext, withAgentDatabase, withAgentHistoryKV, withAgentKV, withAgentPermissionMode, withAgentRunKV, withoutAgentStorageTransaction, } from "./AgentContexts.js";
8
8
  import { agentConfig, ownAgentConfig, withAgentConfig } from "./AgentConfig.js";
9
9
  import { taskContextBeforeToolCall, withAgentTaskContext } from "./AgentTaskContext.js";
10
10
  import { AgentKV } from "./AgentKV.js";
@@ -259,6 +259,10 @@ export class AgentBase {
259
259
  #persistenceLock;
260
260
  /** The session-scoped key-value store carried on every context the agent derives. */
261
261
  #kv;
262
+ /** Durable state tied to the current history and invalidated when that history is replaced. */
263
+ #historyKV;
264
+ /** Ends handles from the previous history epoch after its replacement commits. */
265
+ #historyKVLifetime = new AbortController();
262
266
  /**
263
267
  * The store belonging to the run rather than to the conversation, erased in the transaction
264
268
  * that settles the agent. What a run concludes about itself is worth nothing to the next one,
@@ -280,6 +284,10 @@ export class AgentBase {
280
284
  #steering = [];
281
285
  /** The durable send queue, in the order its keys sort. */
282
286
  #sends = [];
287
+ /** Hook notices waiting to join history after tool settlement and compaction. */
288
+ #injections = [];
289
+ /** A consumed notice that still needs one provider response. */
290
+ #noticeAwaitingResponse = false;
283
291
  /** A dispatched tool batch whose results have not all landed yet, and so has to be resumed. */
284
292
  #pendingTools = [];
285
293
  /**
@@ -469,6 +477,7 @@ export class AgentBase {
469
477
  this.#serviceTier = options.serviceTier;
470
478
  this.#permissionMode = options.permissionMode ?? DEFAULT_AGENT_PERMISSION_MODE;
471
479
  this.#kv = new AgentKV(this.#persistence, `kv.${options.id}.`);
480
+ this.#historyKV = this.#newHistoryKV();
472
481
  this.#runKV = this.#kv.scoped("run");
473
482
  // Everything the agent does — hooks and tool executions included — runs on a context
474
483
  // carrying its provider and the currently effective model, effort, and service tier.
@@ -488,7 +497,18 @@ export class AgentBase {
488
497
  #hookContext(ctx) {
489
498
  const selected = withAgentContext(ctx, this.#selection());
490
499
  const database = agentDatabase(ctx) ?? this.#persistence.database;
491
- return withAgentRunKV(withAgentKV(withAgentDatabase(selected, database), this.#kv), this.#runKV);
500
+ return withAgentRunKV(withAgentHistoryKV(withAgentKV(withAgentDatabase(selected, database), this.#kv), this.#historyKV), this.#runKV);
501
+ }
502
+ /** Create the handle for one history epoch under the stable history storage prefix. */
503
+ #newHistoryKV() {
504
+ return this.#kv.scoped("history").until(this.#historyKVLifetime.signal);
505
+ }
506
+ /** Expire every retained old handle and install a fresh handle for replacement history. */
507
+ #rotateHistoryKV() {
508
+ this.#historyKVLifetime.abort();
509
+ this.#historyKVLifetime = new AbortController();
510
+ this.#historyKV = this.#newHistoryKV();
511
+ this.#ctx = this.#deriveCtx();
492
512
  }
493
513
  /** Load a directly owned configuration written by `updateMetadata`, when one exists. */
494
514
  async #loadConfig(ctx) {
@@ -831,6 +851,30 @@ export class AgentBase {
831
851
  this.#admitted.delete(admitted);
832
852
  }
833
853
  }
854
+ /** Durably queue hook notices until history reaches a safe append boundary. */
855
+ async #enqueueInjections(ctx, batch) {
856
+ if (batch.length === 0)
857
+ return;
858
+ if (this.#closed)
859
+ throw new Error("The agent has been closed.");
860
+ await this.#runInPersistenceLock(ctx, async (lockCtx) => {
861
+ const accepted = [];
862
+ await this.#recordTransaction(lockCtx, async (txCtx) => {
863
+ for (const message of batch) {
864
+ const key = await this.#queueKey(txCtx, "inject.");
865
+ await this.#persistence.writeValue(txCtx, key, message);
866
+ accepted.push({ key, message });
867
+ }
868
+ if (accepted.length > 0)
869
+ await this.#recordPending(txCtx, "inference");
870
+ });
871
+ this.#injections.push(...accepted);
872
+ if (accepted.length > 0) {
873
+ this.#turnRequested = true;
874
+ this.#startRun();
875
+ }
876
+ });
877
+ }
834
878
  /**
835
879
  * Start the loop without a new message: load the durable state and, if a turn was cut off —
836
880
  * queued messages, a dispatched tool batch without results, or an unanswered user or tool
@@ -1019,7 +1063,9 @@ export class AgentBase {
1019
1063
  const run = this.#runPromise;
1020
1064
  if (run === undefined)
1021
1065
  return undefined;
1022
- this.#turnRequested = false;
1066
+ // An abort drops ordinary requested continuation, but a notice already appended to
1067
+ // history remains owed one provider request and must reopen under a fresh abort scope.
1068
+ this.#turnRequested = this.#hasNoticeWorkToFinish();
1023
1069
  this.#abortController?.abort();
1024
1070
  return run;
1025
1071
  }
@@ -1219,8 +1265,9 @@ export class AgentBase {
1219
1265
  throw error;
1220
1266
  }
1221
1267
  await this.#applyActions(this.#hooks.afterTurn, abort.signal, turn);
1222
- if (!this.#turnRequested || this.#closed)
1268
+ if (!this.#turnRequested || (this.#closed && !this.#hasNoticeWorkToFinish())) {
1223
1269
  break;
1270
+ }
1224
1271
  // Each turn cancels on its own scope. Reopening it here rather than at the top
1225
1272
  // keeps the run's first turn under the scope its opening hook already ran in.
1226
1273
  abort = this.#openAbortScope();
@@ -1229,7 +1276,7 @@ export class AgentBase {
1229
1276
  ? undefined
1230
1277
  : (hookCtx) => this.#hooks.afterAgentLoopTransact?.(hookCtx, loop));
1231
1278
  await this.#applyActions(this.#hooks.afterAgentLoop, abort.signal, loop);
1232
- } while (this.#turnRequested && !this.#closed);
1279
+ } while (this.#turnRequested && (!this.#closed || this.#hasNoticeWorkToFinish()));
1233
1280
  // Nothing is asked for any more, so the outstanding work is erased. That erasure is what
1234
1281
  // makes the agent idle, and it commits together with whatever the settling hooks write,
1235
1282
  // so no owner can ever see the agent finished without their conclusions or their
@@ -1342,7 +1389,7 @@ export class AgentBase {
1342
1389
  const lifetime = new AbortController();
1343
1390
  try {
1344
1391
  const liveCtx = withLifetime(txCtx, lifetime.signal);
1345
- const hookCtx = withAgentKV(liveCtx, this.#kv);
1392
+ const hookCtx = withAgentHistoryKV(withAgentKV(liveCtx, this.#kv), this.#historyKV);
1346
1393
  return await work(withAgentRunKV(hookCtx, this.#runKV));
1347
1394
  }
1348
1395
  finally {
@@ -1371,9 +1418,9 @@ export class AgentBase {
1371
1418
  await this.#carryOutActions(actions);
1372
1419
  }
1373
1420
  /**
1374
- * Ask a lifecycle hook what to do next and carry its actions out: queue steering or sent
1375
- * messages through the ordinary durable path, or trigger a compaction. Every returned
1376
- * action is applied before the loop continues, so they all take effect at the same point.
1421
+ * Ask a lifecycle hook what to do next and carry its actions out: queue steering, sent
1422
+ * messages, or system notices through their durable paths, or trigger compaction. Every
1423
+ * returned action is applied before the loop continues.
1377
1424
  * Neither a throwing hook nor a failing action ever fails the run. Unlike `#applyActions`
1378
1425
  * this belongs to no turn's scope, so nothing can cancel the answer out from under it.
1379
1426
  */
@@ -1390,16 +1437,18 @@ export class AgentBase {
1390
1437
  await this.#carryOutActions(actions);
1391
1438
  }
1392
1439
  /**
1393
- * Carry out what a hook asked for. The messages came from one decision, so they are accepted
1394
- * as one batch: a caller arriving while they are being written lands after all of them
1395
- * rather than between two halves of the same thought.
1440
+ * Carry out what a hook asked for. User messages keep their ordinary queues; system notices
1441
+ * enter a separate durable queue consumed only at a safe history boundary.
1396
1442
  */
1397
1443
  async #carryOutActions(actions) {
1398
1444
  const batch = [];
1445
+ const injections = [];
1399
1446
  const flush = async () => {
1400
1447
  const pending = batch.splice(0, batch.length);
1448
+ const pendingInjections = injections.splice(0, injections.length);
1401
1449
  try {
1402
1450
  await this.#enqueue(this.#ctx, pending);
1451
+ await this.#enqueueInjections(this.#ctx, pendingInjections);
1403
1452
  }
1404
1453
  catch {
1405
1454
  // A hook-driven action must not fail the run.
@@ -1411,6 +1460,10 @@ export class AgentBase {
1411
1460
  this.#ensureCompaction().catch(() => undefined);
1412
1461
  continue;
1413
1462
  }
1463
+ if (action.type === "inject") {
1464
+ injections.push(structuredClone(action.message));
1465
+ continue;
1466
+ }
1414
1467
  const id = action.id ?? createId();
1415
1468
  if (!Value.Check(cuid2Schema, id))
1416
1469
  continue;
@@ -1462,6 +1515,7 @@ export class AgentBase {
1462
1515
  return;
1463
1516
  }
1464
1517
  }
1518
+ let needsInference = resumed.length > 0;
1465
1519
  // A requested compaction runs before this turn's first inference, so the model
1466
1520
  // always receives a settled conversation — never one still owing tool results.
1467
1521
  await this.#runCompaction(abort.signal);
@@ -1469,7 +1523,6 @@ export class AgentBase {
1469
1523
  // end the context, or — checked once, against the freshly loaded durable state —
1470
1524
  // when a cut-off run left its trailing user or tool message unanswered. Afterwards
1471
1525
  // a trailing user message can be legitimate: a response may have zero blocks.
1472
- let needsInference = resumed.length > 0;
1473
1526
  if (!this.#recoveryChecked) {
1474
1527
  this.#recoveryChecked = true;
1475
1528
  if (await this.#resumesInterruptedRun())
@@ -1490,7 +1543,11 @@ export class AgentBase {
1490
1543
  // the last response already reported its own terminal event, and a second one
1491
1544
  // would contradict it for the same response.
1492
1545
  if (abort.signal.aborted) {
1493
- const hasPendingWork = needsInference || this.#steering.length > 0 || this.#sends.length > 0;
1546
+ const hasPendingWork = needsInference ||
1547
+ this.#steering.length > 0 ||
1548
+ this.#sends.length > 0 ||
1549
+ this.#injections.length > 0 ||
1550
+ this.#noticeAwaitingResponse;
1494
1551
  if (hasPendingWork)
1495
1552
  await this.#emit({ type: "done", state: "cancelled" });
1496
1553
  break;
@@ -1499,8 +1556,11 @@ export class AgentBase {
1499
1556
  if (!injected && !needsInference) {
1500
1557
  injected = await this.#consumeQueue(this.#sends, this.#sendMode, "send");
1501
1558
  }
1559
+ // Notices follow queue consumption so a model-switching message can replace
1560
+ // history first. Tool settlement and compaction already finished above.
1561
+ await this.#consumeInjections();
1502
1562
  // Nothing to answer — a start() on an idle history, or the queues ran dry.
1503
- if (!injected && !needsInference)
1563
+ if (!this.#noticeAwaitingResponse && !injected && !needsInference)
1504
1564
  break;
1505
1565
  const instructions = await this.#instructions();
1506
1566
  const tools = await this.#tools();
@@ -1534,6 +1594,17 @@ export class AgentBase {
1534
1594
  ...(this.#serviceTier === undefined ? {} : { serviceTier: this.#serviceTier }),
1535
1595
  });
1536
1596
  const { content, state, errorMessage, tokens } = await this.#collect(stream, abortPromise);
1597
+ // A cancellation or a stream ending without a done event did not answer an
1598
+ // appended notice. Keep that obligation and reopen it under a fresh turn scope.
1599
+ // Every terminal provider outcome counts as the response, including an error.
1600
+ if (this.#noticeAwaitingResponse &&
1601
+ (state === "cancelled" || state === undefined)) {
1602
+ this.#turnRequested = true;
1603
+ }
1604
+ else {
1605
+ this.#noticeAwaitingResponse = false;
1606
+ this.#clearTurnRequestIfNoPendingInput();
1607
+ }
1537
1608
  // A cancelled or failed response measures nothing, so the conversation keeps
1538
1609
  // the last real measurement instead of forgetting how large it had become.
1539
1610
  const inference = {
@@ -1614,6 +1685,8 @@ export class AgentBase {
1614
1685
  if (await this.#settleUnansweredCalls("The turn failed before this tool call finished.")) {
1615
1686
  await this.#appendFailure(error instanceof Error ? error.message : String(error));
1616
1687
  }
1688
+ this.#noticeAwaitingResponse = false;
1689
+ this.#clearTurnRequestIfNoPendingInput();
1617
1690
  }
1618
1691
  this.#turnAborted = abort.signal.aborted;
1619
1692
  }
@@ -1694,6 +1767,15 @@ export class AgentBase {
1694
1767
  const session = await this.#ensureSession(instructions, await this.#tools());
1695
1768
  const snapshot = [...this.#messages];
1696
1769
  await this.#settled();
1770
+ const compactionStart = {
1771
+ loopId: this.#loopId ?? createId(),
1772
+ turnId: this.#turnId ?? createId(),
1773
+ compactionId: createId(),
1774
+ contextTokens: this.#contextTokens,
1775
+ };
1776
+ this.#loopId = compactionStart.loopId;
1777
+ this.#turnId = compactionStart.turnId;
1778
+ await this.#invokeHook(this.#hooks.beforeCompaction, compactionStart);
1697
1779
  // Provider compaction is this turn's work, so it runs on this turn's lifetime: an
1698
1780
  // abort reaches the provider operation itself rather than waiting for it to finish
1699
1781
  // work nobody wants any more.
@@ -1702,20 +1784,30 @@ export class AgentBase {
1702
1784
  ...(this.#model === undefined ? {} : { model: this.#model }),
1703
1785
  });
1704
1786
  if (result.status === "failed") {
1787
+ await this.#invokeHook(this.#hooks.afterCompaction, {
1788
+ ...compactionStart,
1789
+ result,
1790
+ });
1705
1791
  throw new Error(result.message);
1706
1792
  }
1707
1793
  if (result.status === "completed") {
1794
+ const completed = { ...compactionStart, result };
1708
1795
  await this.#runInPersistenceLock(this.#ctx, async (lockCtx) => {
1709
1796
  // Physically delete the superseded records and write the replacement —
1710
1797
  // which keeps the messages that stay — in one atomic step.
1711
1798
  await this.#recordTransaction(lockCtx, async (txCtx) => {
1712
- await this.#deleteMessageIdentities(txCtx, await this.#persistence.load(txCtx));
1799
+ await this.#deleteRecordIdentities(txCtx, await this.#persistence.load(txCtx));
1800
+ await this.#historyKV.clear(txCtx);
1713
1801
  await this.#persistence.clearRecords(txCtx);
1802
+ if (this.#hooks.historyErasedTransact !== undefined) {
1803
+ await this.#withTransactionalContext(txCtx, (hookCtx) => this.#hooks.historyErasedTransact?.(hookCtx, completed));
1804
+ }
1714
1805
  await this.#persistence.append(txCtx, {
1715
1806
  type: "compaction",
1716
1807
  messages: result.context.messages,
1717
1808
  });
1718
1809
  });
1810
+ this.#rotateHistoryKV();
1719
1811
  this.#messages = [...result.context.messages];
1720
1812
  this.#lastRecordType = "compaction";
1721
1813
  });
@@ -1723,6 +1815,10 @@ export class AgentBase {
1723
1815
  // again until the next response measures the replacement.
1724
1816
  await this.#recordContextTokens(undefined);
1725
1817
  }
1818
+ await this.#invokeHook(this.#hooks.afterCompaction, {
1819
+ ...compactionStart,
1820
+ result,
1821
+ });
1726
1822
  this.#compaction = undefined;
1727
1823
  pending.resolve();
1728
1824
  }
@@ -1809,7 +1905,7 @@ export class AgentBase {
1809
1905
  await this.#persistence.append(ctx, record);
1810
1906
  }
1811
1907
  /** Remove deduplication identities for user records a history replacement is deleting. */
1812
- async #deleteMessageIdentities(ctx, records) {
1908
+ async #deleteRecordIdentities(ctx, records) {
1813
1909
  for (const record of records) {
1814
1910
  if (record.type === "user") {
1815
1911
  await this.#persistence.deleteValue(ctx, `message.${record.id}`);
@@ -1867,6 +1963,51 @@ export class AgentBase {
1867
1963
  // The turn already failed; a failing write must not escalate it.
1868
1964
  }
1869
1965
  }
1966
+ /** Move every pending hook notice into history as one atomic, ordered append batch. */
1967
+ async #consumeInjections() {
1968
+ return await this.#runInPersistenceLock(this.#ctx, async (lockCtx) => {
1969
+ if (this.#injections.length === 0)
1970
+ return false;
1971
+ const durable = new Set((await this.#persistence.readValues(lockCtx, "inject.")).map(({ key }) => key));
1972
+ const remaining = this.#injections.filter((entry) => durable.has(entry.key));
1973
+ if (remaining.length !== this.#injections.length) {
1974
+ this.#injections.splice(0, this.#injections.length, ...remaining);
1975
+ }
1976
+ if (this.#injections.length === 0)
1977
+ return false;
1978
+ const batch = [...this.#injections];
1979
+ await this.#recordTransaction(lockCtx, async (txCtx) => {
1980
+ for (const entry of batch) {
1981
+ await this.#persistence.deleteValue(txCtx, entry.key);
1982
+ await this.#appendRecord(txCtx, {
1983
+ type: "system",
1984
+ message: entry.message,
1985
+ });
1986
+ }
1987
+ await this.#recordPending(txCtx, "inference");
1988
+ });
1989
+ this.#injections.splice(0, batch.length);
1990
+ this.#messages.push(...batch.map(({ message }) => message));
1991
+ this.#lastRecordType = "system";
1992
+ this.#noticeAwaitingResponse = true;
1993
+ this.#turnRequested = true;
1994
+ return true;
1995
+ });
1996
+ }
1997
+ /** Drop a redundant requested turn only when no accepted input still needs one. */
1998
+ #clearTurnRequestIfNoPendingInput() {
1999
+ if (this.#steering.length === 0 &&
2000
+ this.#sends.length === 0 &&
2001
+ this.#injections.length === 0 &&
2002
+ !this.#noticeAwaitingResponse &&
2003
+ this.#compaction === undefined) {
2004
+ this.#turnRequested = false;
2005
+ }
2006
+ }
2007
+ /** Accepted notice work is drained even when close has already raised its admission barrier. */
2008
+ #hasNoticeWorkToFinish() {
2009
+ return this.#injections.length > 0 || this.#noticeAwaitingResponse;
2010
+ }
1870
2011
  /**
1871
2012
  * Move the oldest queued message — or, in "all" mode, every queued message — into the main
1872
2013
  * context store and the in-memory history. The moves run in one transaction, so a message
@@ -1981,7 +2122,7 @@ export class AgentBase {
1981
2122
  serviceTier,
1982
2123
  permissionMode,
1983
2124
  }), committed.signal);
1984
- const changeCtx = withAgentRunKV(withAgentKV(changeLifetime, this.#kv), this.#runKV);
2125
+ const changeCtx = withAgentRunKV(withAgentHistoryKV(withAgentKV(changeLifetime, this.#kv), this.#historyKV), this.#runKV);
1985
2126
  try {
1986
2127
  injected = await this.#hooks.modelChanged(changeCtx, {
1987
2128
  previousModel: this.#model,
@@ -2018,7 +2159,8 @@ export class AgentBase {
2018
2159
  await this.#persistence.deleteValue(txCtx, entry.key);
2019
2160
  }
2020
2161
  if (reset) {
2021
- await this.#deleteMessageIdentities(txCtx, await this.#persistence.load(txCtx));
2162
+ await this.#deleteRecordIdentities(txCtx, await this.#persistence.load(txCtx));
2163
+ await this.#historyKV.clear(txCtx);
2022
2164
  await this.#persistence.clearRecords(txCtx);
2023
2165
  // The erased conversation is what the measurement described.
2024
2166
  await this.#persistence.deleteValue(txCtx, "context");
@@ -2066,6 +2208,8 @@ export class AgentBase {
2066
2208
  });
2067
2209
  }
2068
2210
  });
2211
+ if (reset)
2212
+ this.#rotateHistoryKV();
2069
2213
  // Committed: from here the messages are part of the conversation, so what has to be
2070
2214
  // announced about them is decided now and reported once the lock is released.
2071
2215
  permissionChange = modeChange;
@@ -2084,11 +2228,7 @@ export class AgentBase {
2084
2228
  // This turn is answering the request that these messages raised. A send accepted
2085
2229
  // while the turn was already running raised it again, and letting that stand would
2086
2230
  // buy an extra turn with an empty queue and a full set of lifecycle hooks.
2087
- if (this.#steering.length === 0 &&
2088
- this.#sends.length === 0 &&
2089
- this.#compaction === undefined) {
2090
- this.#turnRequested = false;
2091
- }
2231
+ this.#clearTurnRequestIfNoPendingInput();
2092
2232
  if (changed) {
2093
2233
  this.#providerId = provider;
2094
2234
  this.#model = model;
@@ -2134,6 +2274,7 @@ export class AgentBase {
2134
2274
  let restored = messagesFromRecords(records);
2135
2275
  const steering = await this.#persistence.readValues(lockCtx, "steering.");
2136
2276
  const sends = await this.#persistence.readValues(lockCtx, "send.");
2277
+ const injections = await this.#persistence.readValues(lockCtx, "inject.");
2137
2278
  const pendingTools = await this.#persistence.readValues(lockCtx, "tool.");
2138
2279
  const settings = await this.#persistence.readValues(lockCtx, "settings");
2139
2280
  const context = await this.#persistence.readValues(lockCtx, "context");
@@ -2158,6 +2299,10 @@ export class AgentBase {
2158
2299
  };
2159
2300
  this.#steering = steering.map(({ key, value }) => entry(key, value));
2160
2301
  this.#sends = sends.map(({ key, value }) => entry(key, value));
2302
+ this.#injections = injections.map(({ key, value }) => ({
2303
+ key,
2304
+ message: structuredClone(value),
2305
+ }));
2161
2306
  // The persisted settings are the complete effective triple from the last change; an
2162
2307
  // absent field means that setting was effectively unset when it was written.
2163
2308
  const persisted = settings[0]?.value;
@@ -2468,7 +2613,7 @@ export class AgentBase {
2468
2613
  if (tool.parameters !== undefined && !Value.Check(tool.parameters, args)) {
2469
2614
  return failure(`The arguments for "${call.name}" did not match its schema.`);
2470
2615
  }
2471
- const callKV = this.#kv.scoped("call", entry.id).serialized();
2616
+ const callKV = this.#kv.scoped("call", entry.id);
2472
2617
  const callLifetime = new AbortController();
2473
2618
  let committing = false;
2474
2619
  const boundedCallKV = callKV.until(callLifetime.signal, () => !committing);