Skip to content

Feature/token limit exception - #4

Merged
jeffpaul merged 2 commits into
WordPress:trunkfrom
saarnilauri:feature/token-limit-exception
Aug 24, 2026
Merged

jeffpaul merged 2 commits into
WordPress:trunkfrom
saarnilauri:feature/token-limit-exception

Conversation

@saarnilauri

Copy link
Copy Markdown
Contributor

Implement token limit exception handling

Summary

  • Throws TokenLimitReachedException when Anthropic API returns max_tokens or model_context_window_exceeded as the stop reason, instead of silently resolving to a FinishReasonEnum::length() value
  • Introduces DEFAULT_MAX_TOKENS = 4096 as a public constant on AnthropicTextGenerationModel, replacing the previous magic number and making the fallback value accessible for error reporting
  • Bumps the wordpress/php-ai-client dev dependency to ^1.1 (from ^0.4 || dev-trunk) which introduces the TokenLimitReachedException class

@superdav42 superdav42 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good. Thanks

@jeffpaul
jeffpaul merged commit 1e88ab9 into WordPress:trunk Aug 24, 2026
1 check passed
@whyisjake whyisjake mentioned this pull request Oct 1, 2026
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.

3 participants