@agent-assistant/core 0.2.19 → 0.2.20

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.
Files changed (2) hide show
  1. package/dist/core.js +19 -10
  2. package/package.json +1 -1
package/dist/core.js CHANGED
@@ -1,6 +1,6 @@
1
- const DEFAULT_HANDLER_TIMEOUT_MS = 30_000;
1
+ const DEFAULT_HANDLER_TIMEOUT_MS = 5 * 60_000;
2
2
  const DEFAULT_MAX_CONCURRENT_HANDLERS = 10;
3
- const STOP_DRAIN_TIMEOUT_MS = 30_000;
3
+ const DRAIN_MARGIN_MS = 5_000;
4
4
  export class AssistantDefinitionError extends Error {
5
5
  constructor(message) {
6
6
  super(message);
@@ -206,14 +206,23 @@ export function createAssistant(definition, adapters) {
206
206
  return;
207
207
  }
208
208
  drainWaiter ??= createDeferred();
209
- await Promise.race([
210
- drainWaiter.promise,
211
- new Promise((_, reject) => {
212
- setTimeout(() => {
213
- reject(new Error(`Timed out waiting ${STOP_DRAIN_TIMEOUT_MS}ms for in-flight handlers to drain`));
214
- }, STOP_DRAIN_TIMEOUT_MS);
215
- }),
216
- ]);
209
+ const drainTimeoutMs = constraints.handlerTimeoutMs + DRAIN_MARGIN_MS;
210
+ let timeoutHandle;
211
+ try {
212
+ await Promise.race([
213
+ drainWaiter.promise,
214
+ new Promise((_, reject) => {
215
+ timeoutHandle = setTimeout(() => {
216
+ reject(new Error(`Timed out waiting ${drainTimeoutMs}ms for in-flight handlers to drain`));
217
+ }, drainTimeoutMs);
218
+ }),
219
+ ]);
220
+ }
221
+ finally {
222
+ if (timeoutHandle) {
223
+ clearTimeout(timeoutHandle);
224
+ }
225
+ }
217
226
  }
218
227
  function runNext() {
219
228
  while (lifecycleState === 'started' &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-assistant/core",
3
- "version": "0.2.19",
3
+ "version": "0.2.20",
4
4
  "description": "Assistant definition, lifecycle, and runtime composition for Agent Assistant SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",