Skip to content

Anthropic provider: non-streaming methods fail #46

@cUp1d

Description

@cUp1d

Summary

When using an Anthropic model (e.g. anthropic:claude-opus-4-6) with any-llm-sdk[anthropic], bub fails on every model call because the underlying run_tools_async() in republic hardcodes stream=False, which the Anthropic provider does not support.

Environment

  • bub: 0.1.1
  • republic: 0.3.2
  • any-llm-sdk: >= 1.7.0 (with anthropic extra)

Steps to Reproduce

  1. Configure .env:

    BUB_MODEL=anthropic:claude-opus-4-6
    
  2. Install with Anthropic support:

    uv sync
    uv add any-llm-sdk[anthropic]
  3. Start bub and send any message:

    uv run bub
    bub > hello
    INFO     model.runner.step step=1 model=anthropic:claude-opus-4-6
    ╭──────────────────────────────────────────── Error ─────────────────────────────────────────────╮
    │ unknown: anthropic:claude-opus-4-6: Streaming is required for operations that may take longer  │
    │ than 10 minutes. See https://github.com/anthropics/anthropic-sdk-python#long-requests for more │
    │ details                                                                                        │
    ╰────────────────────────────────────────────────────────────────────────────────────────────────╯

Root Cause

The call chain from bub to the Anthropic API:

bub/core/model_runner.py L169   self._tape.tape.run_tools_async(...)
  → republic/clients/chat.py L964  _execute_async(stream=False)   ← hardcoded
    → republic/core/execution.py    client.acompletion(stream=False)
      → any-llm-sdk Anthropic provider raises error ❌

Bub calls Tape.run_tools_async(), which delegates to republic's ChatClient.run_tools_async(). This method hardcodes stream=False (chat.py L964) and passes it all the way down to any-llm-sdk. The Anthropic provider in any-llm-sdk does not handle stream=False.

Republic's streaming methods (stream_events_async etc.) pass stream=True and work fine, but they don't auto-execute tools — which bub relies on.

Possible Fixes

This could be addressed at different layers:

  1. republic: internally stream-then-collect for providers that require stream=True, keeping the run_tools_async API unchanged
  2. republic: expose stream as a configurable parameter on run_tools_async (default False for backward compat)
  3. bub: replace run_tools_async with stream_events_async + manual tool execution in model_runner.py (high complexity, not recommended)

Options 1–2 are cleaner since they keep the fix in one place. Raising here since this is where the issue surfaces, but the root fix likely belongs in republic or any-llm-sdk.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions