Skip to content

v1.7.1 — fix #3: no silent empty optimized prompt

Choose a tag to compare

@a-radwan-20 a-radwan-20 released this 14 Jun 10:51

What's new in 1.7.1

Patch fixing #3: some models returned a silent empty optimizedPrompt. No MCP tool surface changes.

Fixed

optimize / critique / clarify could silently return empty text when the LLM produced no content. Two distinct causes, now handled uniformly in src/engine/llm/client.ts:

  1. Thinking-channel models (DeepSeek, qwen-thinking, some gateways) return the chain-of-thought under a field name simpleGenerate wasn't reading. It read only message.reasoning; it now reads reasoning / thinking / reasoning_content via a new pure extractAssistantContent().
  2. gpt-oss harmony format over Ollama's /v1 shim (the actual #3 case, confirmed from the raw response): completion_tokens > 0 but content: "" with no thinking field — the harmony final channel is never mapped into content.

Recover-or-fail-loud: when content is empty (regardless of any thinking field), simpleGenerate retries once with a final-answer-only directive + larger budget. If still empty, it throws LLMError with a completion_tokens diagnostic. The engine catches it, degrades to the original prompt (non-empty), and surfaces a structured error. Callers never again get a silent empty optimized prompt.

Not fixed (tracked on #3)

Genuinely recovering gpt-oss harmony output needs Ollama's native /api/chat — fragile, provider-specific, wrong size for a patch. The silent-failure harm is fully resolved; affected users get the original prompt back + a diagnostic pointing at non-reasoning models or /api/chat.

Tests

  • New npm run test:thinking — a deterministic mock-based battery (no live cloud model) locking the regression: all three field names extract; thinking-only recovers via retry; the harmony shape (empty content + no thinking field + completion_tokens: 306) retries then throws; normal responses pass through untouched. Added to test:all.
  • The live reasoning battery's R3 now asserts the real invariant: real output OR loud degradation, never silent-empty.

Install

```bash
npm install -g clarifyprompt-mcp@1.7.1
```