Skip to content

Fix paper review JSON parse when Hub reasoning models empty content - #17

Draft
znsoftm wants to merge 1 commit into
cursor/papers-translate-concurrency-7d3bfrom
cursor/review-reasoning-tokens-6fc9
Draft

znsoftm wants to merge 1 commit into
cursor/papers-translate-concurrency-7d3bfrom
cursor/review-reasoning-tokens-6fc9

Conversation

@znsoftm

@znsoftm znsoftm commented Sep 14, 2026

Copy link
Copy Markdown
Member

Hub auto reasoning models can return HTTP 200 while spending max_tokens on reasoning_content and leaving message.content empty. extractChatContent previously returned that empty string, so parseReviewAnalysis failed with unexpected end of JSON input on POST /papers/review/{id}/generate.

Changes

  • Raise reviewMaxTokens from 2500 to 12288 so reasoning plus a full four-section Chinese JSON review can fit.
  • Harden extractChatContent:
    • Clear error when content is empty (empty chat content (finish_reason=…))
    • Recover an embedded JSON object from reasoning_content / reasoning when present
  • parseReviewAnalysis rejects empty input with empty analysis JSON instead of a raw JSON EOF.
  • Tests for empty content, reasoning-only Hub 200 shapes, JSON recovery, and the new token budget.

Base

Stacked on cursor/papers-translate-concurrency-7d3b (merge target of the 解读 review feature, PR #11). main does not yet include papers review generation.

Tests

go test ./... passes, including:

  • TestExtractChatContentShapes
  • TestGenerateReviewOpenAIReasoningOnly
  • TestGenerateReviewOpenAIEmptyContentError
  • TestReviewMaxTokensBudget
Open in Web Open in Cursor 

Hub auto models can spend max_tokens on reasoning_content and return HTTP 200 with an empty message.content. extractChatContent now errors clearly on empty content, recovers an embedded JSON object from reasoning when present, and review generation requests 12288 max_tokens so reasoning plus a full Chinese review can both fit.

Co-authored-by: Daniel <znsoft@163.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants