Skip to content

improvement(blocks): extract model config subBlocks into shared utils#3162

Open
waleedlatif1 wants to merge 1 commit intostagingfrom
fix/visibility
Open

improvement(blocks): extract model config subBlocks into shared utils#3162
waleedlatif1 wants to merge 1 commit intostagingfrom
fix/visibility

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • Extracted model config subBlocks (reasoning effort, verbosity, thinking level, temperature, max tokens) from agent block into shared getModelConfigSubBlocks() and MODEL_CONFIG_INPUTS helpers in blocks/utils.ts
  • Refactored agent block to use the shared helpers, removing ~200 lines of inline config

Type of Change

  • Refactor (no behavior change)

Testing

Tested with tsc --noEmit - no type errors

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 Feb 7, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Feb 7, 2026 0:24am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 7, 2026

Greptile Overview

Greptile Summary

Extracted model configuration logic (reasoning effort, verbosity, thinking level, temperature, max tokens) from the agent block into reusable utilities (getModelConfigSubBlocks() and MODEL_CONFIG_INPUTS) in blocks/utils.ts. The refactoring removes ~230 lines of duplicated code from agent.ts while preserving all functionality.

Key Changes:

  • New shared utilities can be reused by future LLM-based blocks
  • Improved input descriptions (removed model-specific references like "for GPT-5 models" that could become outdated)
  • Minor UI reordering: temperature and maxTokens fields now appear before Azure/Vertex/Bedrock configuration fields in the UI
  • All logic, conditions, and dynamic option fetching preserved exactly as before

Code Quality:

  • Proper JSDoc documentation added
  • Clean separation of concerns following established patterns (getProviderCredentialSubBlocks precedent)
  • No circular dependencies introduced
  • Type-safe with as const assertions

Confidence Score: 5/5

  • Safe to merge with minimal risk - clean refactoring that preserves all functionality
  • This is a well-executed refactoring that extracts duplicated configuration logic into reusable utilities. The code is a direct copy-paste with only minor improvements (better descriptions). No logic changes, no new features, just better code organization. The minor UI reordering is acceptable and may even improve UX by grouping model configs together.
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/blocks/utils.ts Added getModelConfigSubBlocks() and MODEL_CONFIG_INPUTS to centralize model configuration logic - well-structured extraction with proper JSDoc
apps/sim/blocks/blocks/agent.ts Refactored to use shared utilities, removing ~230 lines of inline config - minor UI field ordering change (temperature/maxTokens moved earlier)

Sequence Diagram

sequenceDiagram
    participant Agent as agent.ts
    participant Utils as blocks/utils.ts
    participant Providers as @/providers/utils
    participant Stores as Workflow Stores
    
    Note over Agent,Utils: Before: Inline Config (230 lines)
    Agent->>Agent: Define reasoningEffort subBlock
    Agent->>Agent: Define verbosity subBlock
    Agent->>Agent: Define thinkingLevel subBlock
    Agent->>Agent: Define temperature (max=1) subBlock
    Agent->>Agent: Define temperature (max=2) subBlock
    Agent->>Agent: Define maxTokens subBlock
    Agent->>Agent: Define input types for all configs
    
    Note over Agent,Utils: After: Shared Utilities
    Agent->>Utils: ...getModelConfigSubBlocks()
    Utils->>Providers: Import model config helpers
    Utils->>Utils: Define 6 config subBlocks
    Utils->>Stores: fetchOptions() queries workflow state
    Stores-->>Utils: Return blockValues with model
    Utils->>Providers: getReasoningEffortValuesForModel(model)
    Utils->>Providers: getVerbosityValuesForModel(model)
    Utils->>Providers: getThinkingLevelsForModel(model)
    Utils-->>Agent: Return config subBlocks array
    
    Agent->>Utils: ...MODEL_CONFIG_INPUTS
    Utils-->>Agent: Return config input definitions
    
    Note over Agent,Utils: Result: ~230 lines removed from agent.ts
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.

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

},
},

...getModelConfigSubBlocks(),
Copy link

Choose a reason for hiding this comment

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

SubBlock ordering changed, moving temperature/maxTokens earlier in UI

Low Severity

The refactoring changes the ordering of subBlocks in the UI. Originally, temperature and maxTokens appeared after the memory-related fields (slidingWindowTokens). By using ...getModelConfigSubBlocks() at line 139, these fields now appear earlier, right after vertexCredential and before azureEndpoint. The PR description states "no behavior change" but this alters the visual arrangement users see in advanced mode.

Fix in Cursor Fix in Web

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