fix(librarian): replace nullable tool params with sentinel defaults

Ollama's OpenAI-compatible API mishandles anyOf[X, null] parameter
schemas. update_wiki_page (content/title/tags/description) and
smart_create_wiki_page (path) now use empty-string/empty-list
sentinels translated to None inside the tool, following the
biographer pattern from 9d7ce39.

Adds a snapshot test that walks every registered librarian tool's
emitted JSON schema and fails on any anyOf[..., null].

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-14 10:26:55 +02:00
co-authored by Claude Fable 5
parent 24fed8814f
commit 0708c759fc
3 changed files with 72 additions and 19 deletions
+22 -19
View File
@@ -793,10 +793,10 @@ async def read_urls_batch(
async def update_wiki_page(
page_id: int,
content: str | None = None,
title: str | None = None,
tags: list[str] | None = None,
description: str | None = None,
content: str = "",
title: str = "",
tags: list[str] = [], # noqa: B006 - sentinel, never mutated
description: str = "",
) -> str:
"""
Update an existing wiki page.
@@ -810,12 +810,15 @@ async def update_wiki_page(
- Updating tags to organize pages into dossiers
- Fixing descriptions or titles
Note: empty values are sentinels for "leave unchanged" (Ollama's
OpenAI-compatible API mishandles anyOf[X, null] parameter schemas).
Args:
page_id: ID of the page to update (get from search_wiki results)
content: New markdown content (optional - only if changing content)
title: New title (optional - only if renaming)
tags: New tag list (optional - replaces existing tags)
description: New description (optional)
content: New markdown content (empty = leave unchanged)
title: New title (empty = leave unchanged)
tags: New tag list, replaces existing tags (empty = leave unchanged)
description: New description (empty = leave unchanged)
Returns:
Confirmation with updated page details
@@ -829,21 +832,21 @@ async def update_wiki_page(
async with LibraryDeskClient() as client:
page = await client.update_wiki_page(
page_id=page_id,
content=content,
title=title,
tags=tags,
description=description,
content=content if content else None,
title=title if title else None,
tags=tags if tags else None,
description=description if description else None,
)
# Build update summary
updated_fields = []
if content is not None:
if content:
updated_fields.append("content")
if title is not None:
if title:
updated_fields.append("title")
if tags is not None:
if tags:
updated_fields.append("tags")
if description is not None:
if description:
updated_fields.append("description")
output_parts = [
@@ -948,7 +951,7 @@ async def create_wiki_page(
async def smart_create_wiki_page(
topic: str,
tags: list[str],
path: str | None = None,
path: str = "",
include_web_research: bool = True,
include_wiki_search: bool = True,
) -> str:
@@ -970,7 +973,7 @@ async def smart_create_wiki_page(
Args:
topic: The topic to research and create a page about
tags: List of tags/dossiers for categorization
path: Optional custom path (auto-generated from topic if not provided)
path: Optional custom path (empty = auto-generated from topic)
include_web_research: Whether to search the web (default: True)
include_wiki_search: Whether to search existing wiki (default: True)
@@ -986,7 +989,7 @@ async def smart_create_wiki_page(
response = await client.smart_create_wiki_page(
topic=topic,
tags=tags,
path=path,
path=path if path else None,
include_web_research=include_web_research,
include_wiki_search=include_wiki_search,
)