shouldExtract method

bool shouldExtract()

Whether extraction should be triggered based on current state.

Implementation

bool shouldExtract() {
  if (_state.extractionInProgress) return false;

  if (!_state.initialized) {
    return _state.tokensSinceLastExtraction >= config.initThresholdTokens;
  }

  return _state.tokensSinceLastExtraction >= config.updateThresholdTokens &&
      _state.toolCallsSinceLastExtraction >= config.toolCallThreshold;
}