Skip to content

docs(anthropic): add preset config and expand setup instructions; fix max_tokens truncation - #212

Open
citizen204 wants to merge 2 commits into
minitap-ai:mainfrom
citizen204:docs-feat-anthropic-preset
Open

docs(anthropic): add preset config and expand setup instructions; fix max_tokens truncation#212
citizen204 wants to merge 2 commits into
minitap-ai:mainfrom
citizen204:docs-feat-anthropic-preset

Conversation

@citizen204

Copy link
Copy Markdown
Contributor

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.py

  • get_anthropic_llm: adds max_tokens=8192. LangChain's ChatAnthropic defaults max_tokens=1024, which silently truncates responses for long agent plans (screenshot analysis → action descriptions can easily exceed 1 K tokens). Every other provider either passes max_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

  • Adds an "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

  • Expands the one-line Anthropic NOTE into a proper **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_KEY and then manually sets "provider": "anthropic" in their config:

  1. Has to guess which model names are valid.
  2. Gets responses silently cut off at ~1 024 tokens when the executor or cortex agent produces a longer-than-expected plan.

Test plan

  • llm.py change is a one-line max_tokens=8192 addition — no logic change, no tests required.
  • llm-config.defaults.jsonc JSON is valid (verify with python -m json.tool after stripping comments, or your preferred JSONC linter).
  • README diff renders correctly (standard Markdown; the **Using Anthropic Claude:** heading and numbered list follow the same pattern as the MiniMax section above).

🤖 Generated with Claude Code

…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>
@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • rat-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a0f83198-aa81-4c0d-916b-a5eb6e1be4ba

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.
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.

1 participant