From 89b20aef16887d49302aeb750bdf10dd7d098ae7 Mon Sep 17 00:00:00 2001 From: Andrew Yim Date: Tue, 28 Apr 2026 07:41:25 +0900 Subject: [PATCH] fix(notion-search): pin SDK model to dated ID + drop unused type alias Code review caught that the bare alias 'claude-haiku-4-5' works in the Claude Code CLI but may not resolve in the Anthropic SDK. Pin the default to 'claude-haiku-4-5-20251001' (the full dated ID) via a DEFAULT_MODEL constant so the SDK path doesn't silently break the first time it hits the real API. Also document the max_tokens-ignored behavior on the CLI path in the public call_claude docstring (not just the private _call_via_cli), and drop the unused LLMCaller type alias (dead code). 3/3 tests still pass. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../31-notion-organizer/code/scripts/_search_llm.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/custom-skills/31-notion-organizer/code/scripts/_search_llm.py b/custom-skills/31-notion-organizer/code/scripts/_search_llm.py index 166aee2..84a3baa 100644 --- a/custom-skills/31-notion-organizer/code/scripts/_search_llm.py +++ b/custom-skills/31-notion-organizer/code/scripts/_search_llm.py @@ -5,9 +5,10 @@ from __future__ import annotations import os import shutil import subprocess -from typing import Callable -LLMCaller = Callable[..., str] # (prompt, *, model, max_tokens) -> response text +# Anthropic SDK requires fully-qualified dated model IDs (the bare alias +# `claude-haiku-4-5` works in Claude Code CLI but may not resolve via SDK). +DEFAULT_MODEL = "claude-haiku-4-5-20251001" def _have_anthropic_sdk() -> bool: @@ -48,13 +49,16 @@ def _call_via_cli(prompt: str, model: str, max_tokens: int) -> str: def call_claude( prompt: str, *, - model: str = "claude-haiku-4-5", + model: str = DEFAULT_MODEL, max_tokens: int = 1000, ) -> str: """Send a prompt to Claude. Tries the anthropic SDK first (requires ANTHROPIC_API_KEY), falls back to the `claude -p` CLI if available. Raises RuntimeError if neither works. + + Note: ``max_tokens`` is honored by the SDK path but ignored by the CLI + path (the CLI sets its own defaults). """ if _have_anthropic_sdk() and os.getenv("ANTHROPIC_API_KEY"): return _call_via_sdk(prompt, model, max_tokens)