docs(anthropic): add preset config and expand setup instructions; fix max_tokens truncation - #212
Open
citizen204 wants to merge 2 commits into
Open
docs(anthropic): add preset config and expand setup instructions; fix max_tokens truncation#212citizen204 wants to merge 2 commits into
citizen204 wants to merge 2 commits into
Conversation
…ns; fix max_tokens - Add `anthropic` preset to llm-config.defaults.jsonc (claude-sonnet-4-6 + claude-haiku-4-5-20251001 fallback), matching the existing minimax preset so users can copy it into their override config in one step. - Expand the README Anthropic section from a bare NOTE into a full setup guide (step-by-step, like the MiniMax section). - Set max_tokens=8192 in get_anthropic_llm: LangChain's ChatAnthropic defaults to 1024, which is too short for agent plans that describe full phone-automation sequences and can cause mid-response truncation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ChatAnthropic exposes the output-token limit via a field named max_tokens that is aliased to max_tokens_to_sample, so the synthesized __init__ only advertises the alias and pyright flags max_tokens=8192 as reportCallIssue. Pass the value by its public name (matching the Anthropic API parameter and langchain-anthropic's own integration tests) and add a type: ignore[call-arg], which is the same convention used elsewhere in this repo.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The Anthropic provider (
feat: add Anthropic/Claude as LLM provider, #196) was added with minimal documentation and a silent truncation bug compared to the other providers. This PR brings it to parity with the MiniMax provider.Changes
minitap/mobile_use/services/llm.pyget_anthropic_llm: addsmax_tokens=8192. LangChain'sChatAnthropicdefaultsmax_tokens=1024, which silently truncates responses for long agent plans (screenshot analysis → action descriptions can easily exceed 1 K tokens). Every other provider either passesmax_tokens=None(Google/Vertex) or inherits a higher limit from its own defaults; Anthropic needs an explicit value because the Anthropic API requires it. 8 192 is safe for all current Claude models and covers the longest expected agent outputs.llm-config.defaults.jsonc"anthropic"preset (mirroring the"minimax"preset already present) so users can get started without hand-editing every agent node. Recommended model:claude-sonnet-4-6; fallback:claude-haiku-4-5-20251001.README.md**Using Anthropic Claude:**section, exactly matching the MiniMax section's structure (numbered steps + available-models line), so users know to copy the preset and which models to expect.Why
Without these changes, a user who follows the README to set
ANTHROPIC_API_KEYand then manually sets"provider": "anthropic"in their config:Test plan
llm.pychange is a one-linemax_tokens=8192addition — no logic change, no tests required.llm-config.defaults.jsoncJSON is valid (verify withpython -m json.toolafter stripping comments, or your preferred JSONC linter).**Using Anthropic Claude:**heading and numbered list follow the same pattern as the MiniMax section above).🤖 Generated with Claude Code