Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

feat(parser): 支持用 null 取消目录文件数限制 (#5231)

Qin Haojie2f702a241220
diff --git a/docs/en/configuration/01-server.md b/docs/en/configuration/01-server.md
index 24dd21872..cee9556b5 100644
--- a/docs/en/configuration/01-server.md
+++ b/docs/en/configuration/01-server.md
@@ -388,6 +388,9 @@ Parsers live under `parsers`:
}
```
+`parsers.directory.max_files` defaults to `1000`; explicitly set it to `null`
+to disable the file-count limit. Other values must be positive integers.
+
`parsers.directory.max_concurrent` is shared by all directory imports in the
server event loop. With the default value `4`, one directory can run four
Understanding jobs concurrently, while multiple concurrent directories still
diff --git a/docs/zh/configuration/01-server.md b/docs/zh/configuration/01-server.md
index 8de2112ef..72cf958d0 100644
--- a/docs/zh/configuration/01-server.md
+++ b/docs/zh/configuration/01-server.md
@@ -388,6 +388,9 @@ Provider 和密钥管理配置见[加密指南](../guides/08-encryption.md)。
}
```
+`parsers.directory.max_files` 默认是 `1000`;显式设为 `null` 表示不限文件数,
+其他值必须是正整数。
+
`parsers.directory.max_concurrent` 由服务事件循环中的所有目录导入共享。默认值为
`4` 时,单个目录可以并发执行 4 个 Understanding 任务;多个目录同时导入时,合计仍最多
执行 4 个。
diff --git a/openviking/parse/parsers/directory.py b/openviking/parse/parsers/directory.py
index 8602d1eea..d8abdfe28 100644
--- a/openviking/parse/parsers/directory.py
+++ b/openviking/parse/parsers/directory.py
@@ -216,7 +216,10 @@ class DirectoryParser(BaseParser):
processable_files.append(
ClassifiedFile(entry_path, relative, CLASS_PROCESSABLE)
)
- if len(processable_files) > directory_config.max_files:
+ if (
+ directory_config.max_files is not None
+ and len(processable_files) > directory_config.max_files
+ ):
raise InvalidArgumentError("Feishu directory file limit exceeded")
processable_files.sort(key=lambda item: item.rel_path)
warnings.extend(scan_result.warnings)
diff --git a/openviking_cli/utils/config/parser_config.py b/openviking_cli/utils/config/parser_config.py
index fcd9ab4a4..34a8f0a9c 100644
--- a/openviking_cli/utils/config/parser_config.py
+++ b/openviking_cli/utils/config/parser_config.py
@@ -586,8 +586,8 @@ class DirectoryConfig(ParserConfig):
adding directory resources. When True (default), files maintain their
relative path hierarchy. When False, all files are flattened to a
single level under the resource root.
- max_files: Maximum number of selected files admitted by one Understanding
- directory import.
+ max_files: Optional maximum number of selected files admitted by one
+ Understanding or Feishu directory import. None means unlimited.
max_depth: Maximum nested directory depth below an Understanding directory
import root.
max_concurrent: Maximum concurrent Understanding jobs shared by all
@@ -595,7 +595,7 @@ class DirectoryConfig(ParserConfig):
"""
preserve_structure: bool = True
- max_files: int = 1000
+ max_files: Optional[int] = 1000
max_depth: int = 10
max_concurrent: int = 4
@@ -609,6 +609,8 @@ class DirectoryConfig(ParserConfig):
"max_concurrent",
):
value = getattr(self, name)
+ if name == "max_files" and value is None:
+ continue
if isinstance(value, bool) or not isinstance(value, int) or value <= 0:
raise ValueError(f"{name} must be a positive integer")
diff --git a/tests/test_config_loader.py b/tests/test_config_loader.py
index 8f019b0ef..300c1c154 100644
--- a/tests/test_config_loader.py
+++ b/tests/test_config_loader.py
@@ -208,7 +208,7 @@ def test_directory_safety_limits_load_from_parser_config():
{
"parsers": {
"directory": {
- "max_files": 20,
+ "max_files": None,
"max_depth": 5,
"max_concurrent": 2,
}
@@ -216,7 +216,7 @@ def test_directory_safety_limits_load_from_parser_config():
}
)
- assert config.directory.max_files == 20
+ assert config.directory.max_files is None
assert config.directory.max_depth == 5
assert config.directory.max_concurrent == 2