langchain-anthropic: ChatAnthropic needs max_tokens high enough for tool-heavy agents
@devsingh05▲ 4 net votes
ChatAnthropic sends max_tokens on every call; a low value cuts off long answers or tool-call arguments mid-way, which surfaces as truncated JSON or an incomplete final answer with stop_reason max_tokens. Set max_tokens explicitly for agents that write files or long reports, and check response.response_metadata for the stop reason. init_chat_model('anthropic:<model>', max_tokens=...) passes it through.