Default retrieval to 6 chunks instead of 2

chunks is a total per request, split across the attached sources, so an
agent with two sources and the default of 2 got a single chunk from each,
and its answers changed with whichever chunk won. 6 gives three per
source for about 4-5k more input tokens per retrieval turn.

Every literal default moves from 2 to 6: the request default, the
retrievers, the internal search tool, workflow agent nodes, scheduled and
headless runs, agent create/update/import, the source retrieval config and
the frontend forms. Existing agents and sources keep what they store; a
source saved with chunks=2 now counts as configured at 2, which is pinned
by a test.

Headless runs also read chunks=0 as unset (`or 2`), so an agent with
retrieval switched off retrieved anyway on scheduled runs; 0 now stays 0.
This commit is contained in:
arc53-machine committed 2026-09-28 14:34:50 +01:00
1 parent 1c19ed8ce2
commit ab3dbfa1be
33 files changed
+187 -46

No files matched your search

+3 -1
View File
@@ -153,7 +153,9 @@ def _run_agent_headless(
source_active = str(src_row["id"])
retriever_kind = src_row.get("retriever", retriever_kind)
source = {"active_docs": source_active}
chunks = int(agent_config.get("chunks", 2) or 2)
# ``chunks=0`` switches retrieval off; only a missing value takes the default.
raw_chunks = agent_config.get("chunks")
chunks = 6 if raw_chunks in (None, "") else int(raw_chunks)
prompt_id = agent_config.get("prompt_id", "default")
user_api_key = agent_config.get("key")
agent_id = _resolve_agent_id(agent_config)
+2 -2
View File
@@ -36,7 +36,7 @@ class InternalSearchTool(Tool):
source=self.config.get("source", {}),
chat_history=[],
prompt="",
chunks=int(self.config.get("chunks", 2)),
chunks=int(self.config.get("chunks", 6)),
doc_token_limit=int(self.config.get("doc_token_limit", 50000)),
model_id=self.config.get("model_id", "docsgpt-local"),
model_user_id=self.config.get("model_user_id"),
@@ -464,7 +464,7 @@ def add_internal_search_tool(tools_dict: Dict, retriever_config: Dict) -> None:
def build_internal_tool_config(
source: Dict,
retriever_name: str = "classic",
chunks: int = 2,
chunks: int = 6,
doc_token_limit: int = 50000,
sources: Optional[List[Dict]] = None,
model_id: str = "docsgpt-local",
+1 -1
View File
@@ -45,7 +45,7 @@ class AgentNodeConfig(BaseModel):
stream_to_user: bool = True
tools: List[str] = Field(default_factory=list)
sources: List[str] = Field(default_factory=list)
chunks: str = "2"
chunks: str = "6"
retriever: str = ""
model_id: Optional[str] = None
json_schema: Optional[Dict[str, Any]] = None
+2 -2
View File
@@ -429,7 +429,7 @@ class WorkflowEngine:
else {}
),
"retriever_name": node_config.retriever or "classic",
"chunks": int(node_config.chunks) if node_config.chunks else 2,
"chunks": int(node_config.chunks) if node_config.chunks else 6,
"model_id": node_model_id,
"llm_name": node_llm_name,
"api_key": node_api_key,
@@ -1388,7 +1388,7 @@ class WorkflowEngine:
source={"active_docs": self._authorized_node_sources(node_config.sources)},
chat_history=[],
prompt="",
chunks=int(node_config.chunks) if node_config.chunks else 2,
chunks=int(node_config.chunks) if node_config.chunks else 6,
decoded_token=self.agent.decoded_token,
)
docs = retriever.search(query)