Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

Summary

Anthropic models streaming vs non-streaming token limits.

Type of Change

  • Bug fix
  • New feature

Testing

Tested manually with @Sg312

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Jan 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
docs Ready Ready Preview, Comment Jan 27, 2026 0:49am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 25, 2026

Greptile Overview

Greptile Summary

This PR implements differentiated token limits for Anthropic models based on whether requests are streaming or non-streaming, addressing timeout issues with non-streaming requests.

Key Changes:

  • Added maxOutputTokens capability to model definitions with separate max (streaming) and default (non-streaming) values
  • Anthropic Claude 4.x/Opus models now use 64K tokens for streaming, 4096 for non-streaming (previously hardcoded 1024)
  • Claude 3.x computer use models use 8192 tokens for both modes
  • Implemented getMaxOutputTokensForModel() function to dynamically select appropriate limits
  • Added UI field for users to manually configure max output tokens
  • Increased browser automation timeout from 3 to 10 minutes (related change)

Issues Found:

  • Documentation inconsistency in apps/sim/providers/utils.ts:999 - comment states 8192 but implementation uses 4096

Confidence Score: 4/5

  • Safe to merge with one minor documentation fix needed
  • The implementation is sound and addresses a real issue with timeout problems on non-streaming requests. The logic correctly differentiates between streaming (max tokens) and non-streaming (default tokens) modes. Only issue is a documentation comment that doesn't match the implementation (states 8192 but code uses 4096).
  • Pay attention to apps/sim/providers/utils.ts for the documentation fix

Important Files Changed

Filename Overview
apps/sim/providers/models.ts Added maxOutputTokens capability with streaming vs non-streaming limits for Anthropic models; implemented getMaxOutputTokensForModel() function
apps/sim/providers/anthropic/index.ts Updated default max_tokens from hardcoded 1024 to dynamic value using getMaxOutputTokensForModel() based on streaming mode
apps/sim/providers/bedrock/index.ts Updated default maxTokens from hardcoded 4096 to dynamic value using getMaxOutputTokensForModel() based on streaming mode
apps/sim/providers/utils.ts Added getMaxOutputTokensForModel() wrapper function with documentation inconsistency (mentions 8192 but returns 4096)
apps/sim/blocks/blocks/agent.ts Added maxTokens UI input field and schema definition to allow users to configure max output tokens
apps/sim/tools/browser_use/run_task.ts Increased MAX_POLL_TIME_MS from 180000 (3 min) to 600000 (10 min) to accommodate longer browser automation tasks

Sequence Diagram

sequenceDiagram
    participant User
    participant Agent
    participant Provider as Anthropic/Bedrock Provider
    participant Models as models.ts
    participant API as Anthropic/Bedrock API

    User->>Agent: Configure agent with model & maxTokens
    Agent->>Provider: executeRequest(model, stream, maxTokens)
    
    alt maxTokens provided by user
        Provider->>Provider: Use Number.parseInt(request.maxTokens)
    else maxTokens not provided
        Provider->>Models: getMaxOutputTokensForModel(model, stream)
        
        alt Streaming request
            Models-->>Provider: Return maxOutputTokens.max (e.g., 64000)
        else Non-streaming request
            Models-->>Provider: Return maxOutputTokens.default (e.g., 4096)
        end
    end
    
    Provider->>API: API call with determined max_tokens
    API-->>Provider: Response (within token limit)
    Provider-->>Agent: ProviderResponse
    Agent-->>User: Generated content
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@icecrasher321
Copy link
Collaborator Author

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@icecrasher321 icecrasher321 merged commit 5189473 into staging Jan 27, 2026
12 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/claude-tokenlim branch January 27, 2026 02:37
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.

2 participants