Skip to content

LLM Wiki is a cross-platform desktop application that turns your documents into an organized, interlinked knowledge base — automatically. Instead of traditional RAG (retrieve-and-answer from scratch every time), the LLM incrementally builds and maintains a persistent wiki from your sources。

TypeScript

feat: make reasoning during ingest selectable instead of hardcoded off

Thomas-Pivac99a26d0b89f
diff --git a/src/components/settings/preset-resolver.ts b/src/components/settings/preset-resolver.ts
index 47d09cce..2f62869f 100644
--- a/src/components/settings/preset-resolver.ts
+++ b/src/components/settings/preset-resolver.ts
@@ -35,6 +35,9 @@ export function resolveConfig(
const maxContextSize =
ov.maxContextSize ?? preset.suggestedContextSize ?? fallback.maxContextSize
const reasoning = ov.reasoning ?? { mode: "auto" as const }
+ // Carried alongside `reasoning`: without it the ingest selector would save a
+ // value the resolved config drops, and ingest would keep using the default.
+ const ingestReasoning = ov.ingestReasoning ?? { mode: "off" as const }
const localCliIsolation = ov.localCliIsolation === true
const codexCliTimeoutMinutes =
typeof ov.codexCliTimeoutMinutes === "number" && Number.isFinite(ov.codexCliTimeoutMinutes)
@@ -61,6 +64,7 @@ export function resolveConfig(
maxContextSize,
apiMode: ov.apiMode ?? preset.apiMode ?? "chat_completions",
reasoning,
+ ingestReasoning,
localCliIsolation: false,
requestTimeoutMinutes,
customHeaders,
@@ -77,6 +81,7 @@ export function resolveConfig(
customEndpoint: fallback.customEndpoint,
maxContextSize,
reasoning,
+ ingestReasoning,
localCliIsolation: false,
requestTimeoutMinutes,
customHeaders,
@@ -95,6 +100,7 @@ export function resolveConfig(
azureModelFamily: ov.azureModelFamily ?? preset.azureModelFamily ?? "auto",
maxContextSize,
reasoning,
+ ingestReasoning,
localCliIsolation: false,
requestTimeoutMinutes,
customHeaders,
@@ -113,6 +119,7 @@ export function resolveConfig(
customEndpoint: fallback.customEndpoint,
maxContextSize,
reasoning,
+ ingestReasoning,
localCliIsolation,
codexCliTimeoutMinutes: preset.provider === "codex-cli" ? codexCliTimeoutMinutes : undefined,
requestTimeoutMinutes,
@@ -131,6 +138,7 @@ export function resolveConfig(
customEndpoint: fallback.customEndpoint,
maxContextSize,
reasoning,
+ ingestReasoning,
localCliIsolation: false,
requestTimeoutMinutes,
customHeaders,
diff --git a/src/components/settings/sections/llm-provider-section.tsx b/src/components/settings/sections/llm-provider-section.tsx
index 425fc964..36aac719 100644
--- a/src/components/settings/sections/llm-provider-section.tsx
+++ b/src/components/settings/sections/llm-provider-section.tsx
@@ -380,6 +380,8 @@ function PresetRow({
const azureModelFamily = ov.azureModelFamily ?? preset.azureModelFamily ?? "auto"
const context = ov.maxContextSize ?? preset.suggestedContextSize ?? 131072
const reasoning = ov.reasoning ?? { mode: "auto" as const }
+ // "off" by default: what ingest hardcoded before it was settable.
+ const ingestReasoning = ov.ingestReasoning ?? { mode: "off" as const }
const localCliIsolation = ov.localCliIsolation === true
const codexCliTimeoutMinutes = Math.max(1, Math.min(240, ov.codexCliTimeoutMinutes ?? 10))
const requestTimeoutMinutes = Math.max(1, Math.min(1440, ov.requestTimeoutMinutes ?? 30))
@@ -770,6 +772,19 @@ function PresetRow({
onChange={(reasoning) => onChange({ reasoning })}
/>
+ <ReasoningControls
+ value={ingestReasoning}
+ config={resolvedConfig}
+ onChange={(ingestReasoning) => onChange({ ingestReasoning })}
+ title={t("settings.sections.llm.reasoning.ingestTitle", {
+ defaultValue: "Reasoning during ingest",
+ })}
+ hint={t("settings.sections.llm.reasoning.ingestHint", {
+ defaultValue:
+ "Off is usually right: ingest asks for structured output and thinking costs time without helping. Raise it only if the model refuses to run with reasoning disabled.",
+ })}
+ />
+
<div className="space-y-2 rounded-md border p-3">
<div>
<div className="text-sm font-medium">
@@ -830,10 +845,15 @@ function ReasoningControls({
value,
config,
onChange,
+ title,
+ hint,
}: {
value: ReasoningConfig
config: LlmConfig
onChange: (value: ReasoningConfig) => void
+ /** Defaults to the chat reasoning label; the ingest control passes its own. */
+ title?: string
+ hint?: string
}) {
const { t } = useTranslation()
const capabilities = resolveReasoningCapabilities(config)
@@ -852,7 +872,8 @@ function ReasoningControls({
return (
<div className="space-y-2">
- <Label>{t("settings.sections.llm.reasoning.title")}</Label>
+ <Label>{title ?? t("settings.sections.llm.reasoning.title")}</Label>
+ {hint && <p className="text-xs text-muted-foreground">{hint}</p>}
<div className="flex flex-wrap gap-1.5">
{modes.map((m) => {
const active = normalizedValue.mode === m.value
diff --git a/src/i18n/en.json b/src/i18n/en.json
index 4c698535..e071f2fe 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -619,7 +619,10 @@
"max": "Max",
"custom": "Custom",
"budgetTokens": "thinking budget tokens",
- "hint": "Structured tasks such as ingest may override this to Off to avoid reasoning-only responses."
+
+ "hint": "Structured tasks such as ingest may override this to Off to avoid reasoning-only responses.",
+ "ingestTitle": "Reasoning during ingest",
+ "ingestHint": "Off is usually right: ingest asks for structured output and thinking costs time without helping. Raise it only if the model refuses to run with reasoning disabled."
}
},
"embedding": {
diff --git a/src/i18n/it.json b/src/i18n/it.json
index cdf7a3f2..6c6c3eab 100644
--- a/src/i18n/it.json
+++ b/src/i18n/it.json
@@ -619,7 +619,10 @@
"max": "Massimo",
"custom": "Personalizzato",
"budgetTokens": "token di budget per il ragionamento",
- "hint": "Le attività strutturate come l'elaborazione dei documenti possono forzare questo valore su Disattivo per evitare risposte di solo ragionamento."
+
+ "hint": "Le attività strutturate come l'elaborazione dei documenti possono forzare questo valore su Disattivo per evitare risposte di solo ragionamento.",
+ "ingestTitle": "Ragionamento durante l'ingest",
+ "ingestHint": "Di norma va tenuto spento: l'ingest chiede output strutturato e il ragionamento costa tempo senza migliorarlo. Alzalo solo se il modello si rifiuta di funzionare con il ragionamento disattivato."
}
},
"embedding": {
diff --git a/src/i18n/ru.json b/src/i18n/ru.json
index 38665c2d..1e5a034b 100644
--- a/src/i18n/ru.json
+++ b/src/i18n/ru.json
@@ -619,7 +619,10 @@
"max": "Макс.",
"custom": "Пользовательское",
"budgetTokens": "токенов бюджета размышления",
- "hint": "Структурированные задачи (например, обработка) могут переопределять этот параметр на «Выкл.», чтобы избежать ответов только с размышлением."
+
+ "hint": "Структурированные задачи (например, обработка) могут переопределять этот параметр на «Выкл.», чтобы избежать ответов только с размышлением.",
+ "ingestTitle": "Рассуждение при импорте",
+ "ingestHint": "Обычно лучше выключить: импорт запрашивает структурированный вывод, а рассуждение отнимает время, не улучшая результат. Повышайте только если модель отказывается работать с выключенным рассуждением."
}
},
"embedding": {
diff --git a/src/i18n/zh.json b/src/i18n/zh.json
index c3eb9a19..b5b99ec8 100644
--- a/src/i18n/zh.json
+++ b/src/i18n/zh.json
@@ -619,7 +619,10 @@
"max": "最大",
"custom": "自定义",
"budgetTokens": "thinking token 预算",
- "hint": "结构化任务(如 ingest)可能会自动关闭 reasoning,避免模型只输出思考过程而没有正文。"
+
+ "hint": "结构化任务(如 ingest)可能会自动关闭 reasoning,避免模型只输出思考过程而没有正文。",
+ "ingestTitle": "导入时的推理",
+ "ingestHint": "通常应关闭:导入需要结构化输出,推理只会增加耗时而无助于质量。仅当模型拒绝在关闭推理的情况下运行时才调高。"
}
},
"embedding": {
diff --git a/src/lib/anytxt-search.ts b/src/lib/anytxt-search.ts
index e6e97604..026cd348 100644
--- a/src/lib/anytxt-search.ts
+++ b/src/lib/anytxt-search.ts
@@ -3,6 +3,7 @@ import type { AnyTxtConfig, LlmConfig } from "@/stores/wiki-store"
import { normalizePath } from "@/lib/path-utils"
import { streamChat } from "@/lib/llm-client"
import type { WebSearchResult } from "./web-search"
+import { resolveIngestReasoning } from "@/lib/reasoning-capabilities"
export const DEFAULT_ANYTXT_ENDPOINT = "http://127.0.0.1:9920"
export const DEFAULT_ANYTXT_FILTER_EXT = "*"
@@ -112,7 +113,7 @@ export async function rewriteAnyTxtQueries(queries: string[], llmConfig: LlmConf
onError: () => {},
},
undefined,
- { temperature: 0.1, max_tokens: 512, reasoning: { mode: "off" } },
+ { temperature: 0.1, max_tokens: 512, reasoning: resolveIngestReasoning(llmConfig) },
)
const rewritten = parseAnyTxtQueryRewrite(output)
diff --git a/src/lib/dedup-runner.ts b/src/lib/dedup-runner.ts
index 18cae472..893d1070 100644
--- a/src/lib/dedup-runner.ts
+++ b/src/lib/dedup-runner.ts
@@ -60,6 +60,7 @@ import {
type MergeResult,
} from "./dedup"
import { loadNotDuplicates } from "./dedup-storage"
+import { resolveIngestReasoning } from "@/lib/reasoning-capabilities"
/**
* Wrap streamChat into the (system, user, signal) → string shape
@@ -104,7 +105,7 @@ export function buildDedupLlmCall(
// unrecognized reasoning model behind a custom endpoint) doesn't
// spend its whole budget on reasoning and run the stream to the
// 30-min backstop — which surfaces as a bare "Request cancelled".
- { temperature: 0.1, reasoning: { mode: "off" }, max_tokens: maxTokens },
+ { temperature: 0.1, reasoning: resolveIngestReasoning(llmConfig), max_tokens: maxTokens },
).catch((err) => {
streamError = err instanceof Error ? err : new Error(String(err))
resolve()
diff --git a/src/lib/ingest-reasoning.test.ts b/src/lib/ingest-reasoning.test.ts
new file mode 100644
index 00000000..41a7c620
--- /dev/null
+++ b/src/lib/ingest-reasoning.test.ts
@@ -0,0 +1,66 @@
+import { describe, expect, it } from "vitest"
+import { resolveIngestReasoning } from "./reasoning-capabilities"
+import { getProviderConfig } from "./llm-providers"
+import { resolveConfig } from "@/components/settings/preset-resolver"
+import type { LlmConfig } from "@/stores/wiki-store"
+
+const openAiConfig: LlmConfig = {
+ provider: "openai",
+ apiKey: "k",
+ model: "gpt-5",
+ ollamaUrl: "",
+ customEndpoint: "",
+ maxContextSize: 128000,
+}
+
+describe("ingest reasoning is settable instead of hardcoded off", () => {
+ it("defaults to off, preserving the behaviour ingest had when it was hardcoded", () => {
+ expect(resolveIngestReasoning(openAiConfig)).toEqual({ mode: "off" })
+ })
+
+ it("uses the configured mode when the user picks one", () => {
+ expect(resolveIngestReasoning({ ...openAiConfig, ingestReasoning: { mode: "low" } }))
+ .toEqual({ mode: "low" })
+ })
+
+ it("keeps chat reasoning independent of ingest reasoning", () => {
+ const config: LlmConfig = {
+ ...openAiConfig,
+ reasoning: { mode: "high" },
+ ingestReasoning: { mode: "off" },
+ }
+ expect(resolveIngestReasoning(config)).toEqual({ mode: "off" })
+ expect(config.reasoning).toEqual({ mode: "high" })
+ })
+
+ it("is not normalized here, so off cannot decay to auto on auto-only providers", () => {
+ // Normalizing in both places turned "off" into "auto" for providers whose
+ // capability list is auto-only, silently re-enabling the thinking that
+ // ingest disables on purpose. The provider layer normalizes; this does not.
+ const autoOnly: LlmConfig = {
+ ...openAiConfig,
+ provider: "custom",
+ customEndpoint: "https://example.invalid/v1",
+ }
+ expect(resolveIngestReasoning(autoOnly)).toEqual({ mode: "off" })
+ })
+
+ it("reaches the wire: the selected effort ends up in the request body", () => {
+ const withLow = { ...openAiConfig, ingestReasoning: { mode: "low" as const } }
+ const body = getProviderConfig(withLow).buildBody(
+ [{ role: "user", content: "hi" }],
+ { reasoning: resolveIngestReasoning(withLow) },
+ ) as Record<string, unknown>
+ expect(body.reasoning_effort).toBe("low")
+ })
+
+ it("survives the preset resolver, which drops fields it does not carry", () => {
+ const resolved = resolveConfig(
+ { id: "openai", label: "OpenAI", provider: "openai" } as never,
+ { ingestReasoning: { mode: "low" } },
+ openAiConfig,
+ )
+ expect(resolved.ingestReasoning).toEqual({ mode: "low" })
+ expect(resolveIngestReasoning(resolved)).toEqual({ mode: "low" })
+ })
+})
diff --git a/src/lib/ingest.ts b/src/lib/ingest.ts
index f02fd0db..79026fa3 100644
--- a/src/lib/ingest.ts
+++ b/src/lib/ingest.ts
@@ -331,6 +331,7 @@ import {
loadProjectWikiSchemaRouting,
validateWikiPageRouting,
} from "@/lib/wiki-schema"
+import { resolveIngestReasoning } from "@/lib/reasoning-capabilities"
// Legacy export kept for backward compatibility with existing diagnostic
// tests. The live pipeline goes through parseFileBlocks() below, which
@@ -1043,7 +1044,7 @@ async function autoIngestImpl(
},
},
signal,
- { temperature: 0.1, reasoning: { mode: "off" }, max_tokens: 4096 },
+ { temperature: 0.1, reasoning: resolveIngestReasoning(llmConfig), max_tokens: 4096 },
)
}
@@ -1100,7 +1101,7 @@ async function autoIngestImpl(
signal,
{
temperature: 0.1,
- reasoning: { mode: "off" },
+ reasoning: resolveIngestReasoning(llmConfig),
max_tokens: computeIngestGenerationMaxTokens(llmConfig.maxContextSize),
},
)
@@ -1146,7 +1147,7 @@ async function autoIngestImpl(
signal,
{
temperature: 0.1,
- reasoning: { mode: "off" },
+ reasoning: resolveIngestReasoning(llmConfig),
max_tokens: computeIngestReviewMaxTokens(llmConfig.maxContextSize),
},
)
@@ -1223,7 +1224,7 @@ async function autoIngestImpl(
signal,
{
temperature: 0.1,
- reasoning: { mode: "off" },
+ reasoning: resolveIngestReasoning(llmConfig),
// A repair must regenerate the complete FILE body. Reusing the
// smaller review budget can immediately truncate the same long page
// that exhausted the original response.
@@ -2942,7 +2943,7 @@ async function analyzeLongSourceInChunks(
},
},
signal,
- { temperature: 0.1, reasoning: { mode: "off" }, max_tokens: 4096 },
+ { temperature: 0.1, reasoning: resolveIngestReasoning(llmConfig), max_tokens: 4096 },
)
throwIfIngestAborted(signal, activityId)
diff --git a/src/lib/reasoning-capabilities.ts b/src/lib/reasoning-capabilities.ts
index 3a6c4a2e..26e6abcc 100644
--- a/src/lib/reasoning-capabilities.ts
+++ b/src/lib/reasoning-capabilities.ts
@@ -106,6 +106,25 @@ export function normalizeReasoningForProvider(
return resolveReasoningCapabilities(config).normalize(requested)
}
+/**
+ * Reasoning for ingest's structured calls. Ingest hardcodes `{ mode: "off" }`
+ * at every call site, which is the right default — thinking buys little on
+ * structured extraction and a model that spends its budget on chain-of-thought
+ * can return empty `content`, losing the page — but it is wrong as a *rule*:
+ * some models reject disabling reasoning outright and answer 400, so every
+ * ingest call fails with no way to fix it from the UI. Making it settable is
+ * what lets those providers be used; "off" stays the default so existing
+ * setups behave exactly as before.
+ *
+ * Deliberately not normalized here: the provider layer already normalizes when
+ * it builds the payload, and normalizing twice turns "off" into "auto" for
+ * providers whose capability list is auto-only, quietly re-enabling the
+ * thinking ingest disables on purpose.
+ */
+export function resolveIngestReasoning(config: LlmConfig): ReasoningConfig {
+ return config.ingestReasoning ?? { mode: "off" }
+}
+
export function isAdaptiveAnthropicModel(config: LlmConfig): boolean {
return config.provider === "anthropic" && isClaude46OrLater(config.model)
}
diff --git a/src/lib/vision-caption.ts b/src/lib/vision-caption.ts
index 140f2cb3..465c964a 100644
--- a/src/lib/vision-caption.ts
+++ b/src/lib/vision-caption.ts
@@ -39,6 +39,7 @@
*/
import type { LlmConfig } from "@/stores/wiki-store"
import { streamChat, type ChatMessage } from "./llm-client"
+import { resolveIngestReasoning } from "@/lib/reasoning-capabilities"
/**
* The "no surrounding text" prompt — same factual / verbatim /
@@ -219,7 +220,7 @@ export async function captionImage(
// often burns the small caption budget on thinking and produces
// no usable alt text. Disable reasoning for caption calls unless
// this helper grows an explicit caption-reasoning option.
- reasoning: { mode: "off" },
+ reasoning: resolveIngestReasoning(llmConfig),
},
)
diff --git a/src/stores/wiki-store.ts b/src/stores/wiki-store.ts
index 7a408f32..863b7732 100644
--- a/src/stores/wiki-store.ts
+++ b/src/stores/wiki-store.ts
@@ -35,6 +35,17 @@ interface LlmConfig {
maxContextSize: number // max context window in characters
apiMode?: CustomApiMode
reasoning?: ReasoningConfig
+ /** Reasoning for ingest's structured calls. See LlmConfig.ingestReasoning. */
+ ingestReasoning?: ReasoningConfig
+ /**
+ * Reasoning for ingest's structured calls (analysis, page generation,
+ * captioning, dedup), kept separate from `reasoning` because the two want
+ * opposite things: chat benefits from thinking, whereas ingest asks for
+ * structured output thousands of times and a model that spends its budget on
+ * chain-of-thought can end the stream with empty `content` — a lost page.
+ * Defaults to "off", which is what ingest hardcoded before this was settable.
+ */
+ ingestReasoning?: ReasoningConfig
/**
* Local CLI providers only. When true, LLM Wiki asks Claude/Codex CLI
* to ignore user-level rules/config/MCP/tool state where the CLI exposes