Skip to content

[BUG]: calculate_max_tokens doesn't recognize claude-haiku-4-5 (same class as #312) #317

Description

@Shearerbeard

Summary

calculate_max_tokens in rig's Anthropic provider doesn't recognize claude-haiku-4-5 (the latest Haiku model). When max_tokens is omitted from [agent.llm] config, the safety-net default returns None → the provider errors with `max_tokens` must be set for Anthropic. Same class of bug as #312, different model.

Reproduction

Use claude-haiku-4-5 in agent.llm with orchestration enabled, omitting max_tokens:

[agent]
name = "Aura Orchestrator"
system_prompt = "..."
turn_depth = 5

[agent.llm]
provider = "anthropic"
api_key = "{{ env.ANTHROPIC_API_KEY }}"
model = "claude-haiku-4-5"

[orchestration]
enabled = true

If max_tokens is set explicitly in config, the bug is not triggered (the value is propagated directly). The bug only fires when max_tokens is omitted and rig's calculate_max_tokens fallback is consulted.

Relevant log output

WARN  aura::orchestration::orchestrator: Planning attempt 1 failed after 0.0s: CompletionError: RequestError: `max_tokens` must be set for Anthropic
ERROR aura_web_server::streaming::handlers: Stream error: Planning failed: CompletionError: RequestError: `max_tokens` must be set for Anthropic

Root cause

Anthropic changed their naming convention at the 4-series boundary:

  • Old: claude-3-5-haiku (generation before tier) — matched by rig's starts_with("claude-3-5-haiku") → 8192
  • New: claude-haiku-4-5 (tier before generation) — matches no existing prefix in calculate_max_tokens

Verified with a standalone test:

claude-haiku-4-5               => None
claude-haiku-4-5-20251001      => None
claude-3-5-haiku               => Some(8192)
claude-sonnet-5                => Some(64000)  # fixed in #312

Fix

Add a new branch to calculate_max_tokens and calculate_max_tokens_custom in rig-core/src/providers/anthropic/completion.rs:

} else if model.starts_with("claude-haiku-4") {
    Some(64000)
}

Uses claude-haiku-4 as the prefix (covers claude-haiku-4-5 and future claude-haiku-4-x variants). Default of 64000 matches Haiku 4.5's 64k max output (per Anthropic's model docs). This is a new branch, not an || addition to an existing one — Haiku 4.5's 64k max output is 8x higher than the existing claude-3-5-haiku default of 8192, so it can't share that branch.

Same PR pattern as #312: rig fork PR to mezmo/rig targeting mezmo, then bump the rev pin in aura's Cargo.toml.

Additional Context

Searched Issues

  • No similar issues found

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. added a commit that references this issue on Sep 8, 2026
    636aae3
  2. added a commit that references this issue on Sep 10, 2026
    cda2d3e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions