Skip to content

Commit b482c33

Browse files
committed
docs(timeout): show in config example; trim docstrings
- README: list `timeout` in the main config.yaml example (marked optional) instead of a separate advanced-options paragraph - config: shorten the resolve_timeout / _runtime_timeout / get_timeout_extra_args comments
1 parent 47f0956 commit b482c33

2 files changed

Lines changed: 11 additions & 33 deletions

File tree

README.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ OpenKB settings are initialized by `openkb init` and stored in `.openkb/config.y
358358
model: gpt-5.4 # LLM model (any LiteLLM-supported provider)
359359
language: en # Wiki output language
360360
pageindex_threshold: 20 # PDF pages threshold for PageIndex
361+
timeout: 1200 # (optional) per-request LLM timeout in seconds; defaults to LiteLLM's 600s
361362
```
362363
363364
Model names use `provider/model` LiteLLM [format](https://docs.litellm.ai/docs/providers) (OpenAI models can omit the prefix):
@@ -369,7 +370,7 @@ Model names use `provider/model` LiteLLM [format](https://docs.litellm.ai/docs/p
369370
| Gemini | `gemini/gemini-3.1-pro-preview` |
370371

371372
<details>
372-
<summary><i>Advanced options (<code>entity_types</code>, <code>extra_headers</code>, <code>timeout</code>, OAuth):</i></summary>
373+
<summary><i>Advanced options (<code>entity_types</code>, <code>extra_headers</code>, OAuth):</i></summary>
373374
<br>
374375

375376
`entity_types` (optional): a YAML list overriding the entity-type vocabulary used for entity pages; omit it to use the default `person`, `organization`, `place`, `product`, `work`, `event`, `other`.
@@ -382,12 +383,6 @@ extra_headers:
382383
Copilot-Integration-Id: vscode-chat
383384
```
384385

385-
`timeout` (optional): the per-request LLM timeout in seconds, forwarded to LiteLLM on all of OpenKB's own calls (compile, query, chat, lint, skill). Defaults to LiteLLM's own 600s; raise it for slow local backends (e.g. Ollama on large inputs) that would otherwise hit `litellm.Timeout`. (PageIndex long-document indexing manages its own timeout and is not affected.)
386-
387-
```yaml
388-
timeout: 1200
389-
```
390-
391386
Subscription-based providers that authenticate via OAuth device flow (e.g. `chatgpt/*`, `github_copilot/*`) need no API key; OpenKB skips the missing-key warning for them.
392387

393388
</details>

openkb/config.py

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,10 @@ def resolve_extra_headers(config: dict) -> dict[str, str]:
138138

139139

140140
def resolve_timeout(config: dict) -> float | None:
141-
"""Resolve the optional ``timeout:`` config key into a positive float of seconds.
142-
143-
LiteLLM applies a 600-second per-request timeout by default, which can be
144-
too short for slow local backends (e.g. Ollama on large inputs). Users
145-
raise it via a ``timeout:`` value in config.yaml; the result is forwarded
146-
to LiteLLM's ``timeout`` parameter on OpenKB's own LLM calls.
147-
148-
Accepts an int or float number of seconds (a numeric string is coerced).
149-
Returns ``None`` — meaning "use LiteLLM's default" — when the key is
150-
absent, and logs a warning and returns ``None`` when it is present but not
151-
a finite positive number. Booleans are rejected (``True``/``False`` aren't
152-
durations), as are ``nan``/``inf`` (which YAML's ``.nan``/``.inf`` produce).
141+
"""Resolve the optional ``timeout:`` key to a finite positive number of seconds.
142+
143+
Returns ``None`` (use LiteLLM's default) when absent or invalid; rejects
144+
bools and ``nan``/``inf``, warning when present but unusable.
153145
"""
154146
raw = config.get("timeout")
155147
if raw is None:
@@ -199,11 +191,8 @@ def get_extra_headers() -> dict[str, str]:
199191
return dict(_runtime_extra_headers)
200192

201193

202-
# Process-wide LLM request timeout in seconds, resolved from the active KB's
203-
# config by the CLI entry points (cli._setup_llm_key). LLM call sites read it
204-
# via get_timeout() so the value doesn't have to be threaded through every
205-
# compile/agent call chain — mirroring extra headers above. ``None`` means
206-
# "use LiteLLM's built-in default".
194+
# Process-wide LLM request timeout (seconds), set from config by the CLI and
195+
# read at the call sites via get_timeout(). None = use LiteLLM's default.
207196
_runtime_timeout: float | None = None
208197

209198

@@ -219,16 +208,10 @@ def get_timeout() -> float | None:
219208

220209

221210
def get_timeout_extra_args() -> dict[str, float] | None:
222-
"""Return ``{"timeout": <seconds>}`` for the Agents SDK, or ``None``.
223-
224-
The openai-agents ``ModelSettings`` has no ``timeout`` field, so the
225-
configured timeout reaches the agent paths (query/chat/lint/skill) via
226-
``ModelSettings(extra_args=...)``, which the LiteLLM provider forwards to
227-
the underlying completion call — keeping those calls consistent with the
228-
compiler's direct ``litellm`` calls. ``None`` when no timeout is configured.
211+
"""Timeout as Agents-SDK ``ModelSettings.extra_args`` (it has no ``timeout``
212+
field), or ``None``. The LiteLLM provider forwards it to the completion call.
229213
"""
230-
timeout = _runtime_timeout
231-
return {"timeout": timeout} if timeout is not None else None
214+
return {"timeout": _runtime_timeout} if _runtime_timeout is not None else None
232215

233216

234217
def load_config(config_path: Path) -> dict[str, Any]:

0 commit comments

Comments
 (0)