llmist 15.7.1 → 15.8.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/dist/index.cjs CHANGED
@@ -9131,6 +9131,13 @@ var init_builder = __esm({
9131
9131
  // When a gadget calls withParentContext(ctx), these observers are
9132
9132
  // also called for gadget events in the subagent
9133
9133
  parentObservers;
9134
+ // Shared rate limit tracker from parent for coordinated throttling
9135
+ // When a gadget calls withParentContext(ctx), this tracker is shared
9136
+ // so all agents in the tree respect aggregate RPM/TPM limits
9137
+ sharedRateLimitTracker;
9138
+ // Shared retry config from parent for consistent backoff behavior
9139
+ // When a gadget calls withParentContext(ctx), this config is shared
9140
+ sharedRetryConfig;
9134
9141
  constructor(client) {
9135
9142
  this.client = client;
9136
9143
  }
@@ -9777,6 +9784,12 @@ var init_builder = __esm({
9777
9784
  if (ctx.parentObservers && !this.parentObservers) {
9778
9785
  this.parentObservers = ctx.parentObservers;
9779
9786
  }
9787
+ if (ctx.rateLimitTracker && !this.sharedRateLimitTracker) {
9788
+ this.sharedRateLimitTracker = ctx.rateLimitTracker;
9789
+ }
9790
+ if (ctx.retryConfig && !this.sharedRetryConfig) {
9791
+ this.sharedRetryConfig = ctx.retryConfig;
9792
+ }
9780
9793
  return this;
9781
9794
  }
9782
9795
  /**
@@ -10156,7 +10169,10 @@ ${endPrefix}`
10156
10169
  parentNodeId: this.parentContext?.nodeId,
10157
10170
  baseDepth: this.parentContext ? (this.parentContext.depth ?? 0) + 1 : 0,
10158
10171
  // Parent observer hooks for subagent visibility
10159
- parentObservers: this.parentObservers
10172
+ parentObservers: this.parentObservers,
10173
+ // Shared rate limit tracker and retry config (for coordinated limits across subagents)
10174
+ sharedRateLimitTracker: this.sharedRateLimitTracker,
10175
+ sharedRetryConfig: this.sharedRetryConfig
10160
10176
  };
10161
10177
  return new Agent(AGENT_INTERNAL_KEY, options);
10162
10178
  }
@@ -11068,7 +11084,7 @@ var init_executor = __esm({
11068
11084
  init_parser();
11069
11085
  init_typed_gadget();
11070
11086
  GadgetExecutor = class {
11071
- constructor(registry, requestHumanInput, logger, defaultGadgetTimeoutMs, errorFormatterOptions, client, mediaStore, agentConfig, subagentConfig, tree, parentNodeId, baseDepth, parentObservers, currentObservers) {
11087
+ constructor(registry, requestHumanInput, logger, defaultGadgetTimeoutMs, errorFormatterOptions, client, mediaStore, agentConfig, subagentConfig, tree, parentNodeId, baseDepth, parentObservers, currentObservers, rateLimitTracker, retryConfig) {
11072
11088
  this.registry = registry;
11073
11089
  this.requestHumanInput = requestHumanInput;
11074
11090
  this.defaultGadgetTimeoutMs = defaultGadgetTimeoutMs;
@@ -11081,6 +11097,8 @@ var init_executor = __esm({
11081
11097
  this.baseDepth = baseDepth;
11082
11098
  this.parentObservers = parentObservers;
11083
11099
  this.currentObservers = currentObservers;
11100
+ this.rateLimitTracker = rateLimitTracker;
11101
+ this.retryConfig = retryConfig;
11084
11102
  this.logger = logger ?? createLogger({ name: "llmist:executor" });
11085
11103
  this.errorFormatter = new GadgetExecutionErrorFormatter(errorFormatterOptions);
11086
11104
  this.argPrefix = errorFormatterOptions?.argPrefix ?? GADGET_ARG_PREFIX;
@@ -11251,7 +11269,11 @@ var init_executor = __esm({
11251
11269
  // When a subagent uses withParentContext(ctx), it will receive these
11252
11270
  // and call them for gadget events in addition to its own hooks
11253
11271
  // Merge child and parent observers so both get called (child first, then parent)
11254
- parentObservers: mergeObservers(this.currentObservers, this.parentObservers)
11272
+ parentObservers: mergeObservers(this.currentObservers, this.parentObservers),
11273
+ // Shared rate limit tracker for coordinated throttling across subagents
11274
+ rateLimitTracker: this.rateLimitTracker,
11275
+ // Shared retry config for consistent backoff behavior across subagents
11276
+ retryConfig: this.retryConfig
11255
11277
  };
11256
11278
  let rawResult;
11257
11279
  if (timeoutMs && timeoutMs > 0) {
@@ -11792,7 +11814,11 @@ var init_stream_processor = __esm({
11792
11814
  // Parent observer hooks for subagent visibility
11793
11815
  options.parentObservers,
11794
11816
  // Current agent's observers for subagent inheritance
11795
- options.hooks?.observers
11817
+ options.hooks?.observers,
11818
+ // Shared rate limit tracker for coordinated throttling across subagents
11819
+ options.rateLimitTracker,
11820
+ // Shared retry config for consistent backoff behavior across subagents
11821
+ options.retryConfig
11796
11822
  );
11797
11823
  }
11798
11824
  /**
@@ -12799,10 +12825,14 @@ var init_agent = __esm({
12799
12825
  );
12800
12826
  }
12801
12827
  this.signal = options.signal;
12802
- this.retryConfig = resolveRetryConfig(options.retryConfig);
12803
- const rateLimitConfig = resolveRateLimitConfig(options.rateLimitConfig);
12804
- if (rateLimitConfig.enabled) {
12805
- this.rateLimitTracker = new RateLimitTracker(options.rateLimitConfig);
12828
+ this.retryConfig = options.sharedRetryConfig ?? resolveRetryConfig(options.retryConfig);
12829
+ if (options.sharedRateLimitTracker) {
12830
+ this.rateLimitTracker = options.sharedRateLimitTracker;
12831
+ } else {
12832
+ const rateLimitConfig = resolveRateLimitConfig(options.rateLimitConfig);
12833
+ if (rateLimitConfig.enabled) {
12834
+ this.rateLimitTracker = new RateLimitTracker(options.rateLimitConfig);
12835
+ }
12806
12836
  }
12807
12837
  this.agentContextConfig = {
12808
12838
  model: this.model,
@@ -13092,7 +13122,10 @@ var init_agent = __esm({
13092
13122
  priorCompletedInvocations: this.completedInvocationIds,
13093
13123
  priorFailedInvocations: this.failedInvocationIds,
13094
13124
  // Parent observer hooks for subagent visibility
13095
- parentObservers: this.parentObservers
13125
+ parentObservers: this.parentObservers,
13126
+ // Shared rate limit tracker and retry config for subagents
13127
+ rateLimitTracker: this.rateLimitTracker,
13128
+ retryConfig: this.retryConfig
13096
13129
  });
13097
13130
  for await (const event of processor.process(stream2)) {
13098
13131
  if (event.type === "stream_complete") {