rcrewai 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -0
  3. data/README.md +133 -23
  4. data/ROADMAP.md +1 -1
  5. data/docs/api/agent.md +5 -2
  6. data/docs/api/configuration.md +36 -41
  7. data/docs/api/crew.md +34 -48
  8. data/docs/api/index.md +7 -0
  9. data/docs/api/task.md +10 -91
  10. data/docs/api/tools.md +19 -0
  11. data/docs/examples/api-integration.md +4 -4
  12. data/docs/examples/async-execution.md +4 -4
  13. data/docs/examples/code-review-crew.md +1 -1
  14. data/docs/examples/content-marketing-pipeline.md +3 -3
  15. data/docs/examples/custom-tools.md +8 -8
  16. data/docs/examples/customer-support.md +5 -5
  17. data/docs/examples/data-analysis-team.md +4 -4
  18. data/docs/examples/database-operations.md +4 -4
  19. data/docs/examples/ecommerce-operations.md +4 -4
  20. data/docs/examples/financial-analysis.md +3 -3
  21. data/docs/examples/hierarchical-crew.md +3 -2
  22. data/docs/examples/production-ready-crew.md +16 -10
  23. data/docs/examples/research-development.md +5 -5
  24. data/docs/examples/simple-research-crew.md +2 -2
  25. data/docs/examples/social-media.md +4 -4
  26. data/docs/examples/task-automation.md +2 -2
  27. data/docs/examples/tool-composition.md +42 -27
  28. data/docs/examples/web-scraping.md +6 -6
  29. data/docs/index.md +61 -44
  30. data/docs/tutorials/advanced-agents.md +194 -917
  31. data/docs/tutorials/agent-options.md +1 -1
  32. data/docs/tutorials/checkpointing.md +65 -0
  33. data/docs/tutorials/concurrency.md +57 -0
  34. data/docs/tutorials/custom-tools.md +198 -1143
  35. data/docs/tutorials/deployment.md +156 -155
  36. data/docs/tutorials/getting-started.md +69 -81
  37. data/docs/tutorials/index.md +19 -0
  38. data/docs/tutorials/interceptors-and-events.md +84 -0
  39. data/docs/tutorials/live-streaming.md +52 -0
  40. data/docs/tutorials/multiple-crews.md +70 -51
  41. data/docs/tutorials/providers.md +115 -0
  42. data/docs/upgrading-to-0.11.md +55 -0
  43. data/lib/rcrewai/agent.rb +0 -2
  44. data/lib/rcrewai/configuration.rb +64 -29
  45. data/lib/rcrewai/context_window.rb +12 -2
  46. data/lib/rcrewai/llm_clients/anthropic.rb +60 -9
  47. data/lib/rcrewai/llm_clients/base.rb +7 -0
  48. data/lib/rcrewai/llm_clients/bedrock.rb +29 -2
  49. data/lib/rcrewai/llm_clients/google.rb +36 -4
  50. data/lib/rcrewai/llm_clients/ollama.rb +17 -3
  51. data/lib/rcrewai/llm_clients/openai.rb +14 -1
  52. data/lib/rcrewai/llm_clients/openai_responses.rb +21 -2
  53. data/lib/rcrewai/pricing.rb +13 -3
  54. data/lib/rcrewai/tool_runner.rb +5 -1
  55. data/lib/rcrewai/version.rb +1 -1
  56. metadata +7 -1
@@ -8,6 +8,19 @@ description: Learn how to coordinate multiple AI crews for complex, multi-phase
8
8
 
9
9
  This tutorial demonstrates how to work with multiple crews to handle complex, multi-phase operations that require different specialized teams working together. You'll learn crew coordination, inter-crew communication, resource sharing, and orchestration patterns.
10
10
 
11
+ **What the gem provides.** RCrewAI gives you `Crew`, `Agent`, and `Task`, plus `crew.execute` and hooks such as `before_kickoff`. It has no built-in multi-crew layer, so the orchestrators, hubs, and managers on this page (`CrewPipeline`, `CrewCommunicationHub`, `SharedResourceManager`, and so on) are **example application code** that you own and can adapt. Each block also assumes the crews it mentions have been given agents and tasks.
12
+
13
+ **Passing context between crews.** Crews share nothing by default. The examples use this small helper of your own, which appends information to each task's description with the gem's `Task#enrich_description`:
14
+
15
+ ```ruby
16
+ # Application code: makes data available to every task in a crew.
17
+ def share_context(crew, context)
18
+ crew.tasks.each { |task| task.enrich_description("Shared context:\n#{context}") }
19
+ end
20
+ ```
21
+
22
+ Call it once per run, because enrichment accumulates on the task. To pass a previous crew's output, use the task results it returned: `results[:results].map { |r| r[:result] }`.
23
+
11
24
  ## Table of Contents
12
25
  1. [Understanding Multi-Crew Architecture](#understanding-multi-crew-architecture)
13
26
  2. [Crew Coordination Patterns](#crew-coordination-patterns)
@@ -86,6 +99,21 @@ senior_developer = RCrewAI::Agent.new(
86
99
 
87
100
  dev_crew.add_agent(tech_lead)
88
101
  dev_crew.add_agent(senior_developer)
102
+
103
+ # Every crew needs at least one task before it can run
104
+ research_crew.add_task(RCrewAI::Task.new(
105
+ name: "market_analysis",
106
+ description: "Analyze the market for an AI-powered analytics dashboard",
107
+ agent: market_researcher,
108
+ expected_output: "Market analysis with key trends"
109
+ ))
110
+
111
+ dev_crew.add_task(RCrewAI::Task.new(
112
+ name: "technical_plan",
113
+ description: "Write a technical plan for the dashboard",
114
+ agent: senior_developer,
115
+ expected_output: "Technical plan with milestones"
116
+ ))
89
117
  ```
90
118
 
91
119
  ## Crew Coordination Patterns
@@ -109,7 +137,8 @@ class CrewPipeline
109
137
 
110
138
  # Pass previous results as context
111
139
  if index > 0
112
- crew.add_shared_context(@pipeline_results[index - 1])
140
+ previous_outputs = @pipeline_results[index - 1][:results].map { |r| r[:result] }
141
+ share_context(crew, previous_outputs.join("\n\n"))
113
142
  end
114
143
 
115
144
  # Execute crew
@@ -192,7 +221,7 @@ class ParallelCrewOrchestrator
192
221
 
193
222
  {
194
223
  crew_name: crew.name,
195
- success: true,
224
+ success: result[:failed_tasks].zero?, # failed tasks don't raise
196
225
  result: result,
197
226
  duration: duration,
198
227
  priority: crew_config[:priority]
@@ -346,7 +375,7 @@ class ECommerceOrchestrator
346
375
 
347
376
  # Pass research context to product crew
348
377
  research_context = extract_key_insights(research_results)
349
- @product_crew.add_shared_context(research_context)
378
+ share_context(@product_crew, research_context)
350
379
 
351
380
  product_results = @product_crew.execute
352
381
 
@@ -363,7 +392,7 @@ class ECommerceOrchestrator
363
392
 
364
393
  # Pass product specs to tech crew
365
394
  product_context = extract_technical_requirements(product_results)
366
- @tech_crew.add_shared_context(product_context)
395
+ share_context(@tech_crew, product_context)
367
396
 
368
397
  tech_results = @tech_crew.execute
369
398
 
@@ -535,7 +564,7 @@ class ContentMarketingCampaign
535
564
  crew.add_agent(copywriter)
536
565
 
537
566
  # Add shared context
538
- crew.add_shared_context(@shared_resources)
567
+ share_context(crew, @shared_resources)
539
568
 
540
569
  # Content tasks
541
570
  crew.add_task(RCrewAI::Task.new(
@@ -566,7 +595,7 @@ class ContentMarketingCampaign
566
595
  )
567
596
 
568
597
  crew.add_agent(seo_specialist)
569
- crew.add_shared_context(@shared_resources)
598
+ share_context(crew, @shared_resources)
570
599
 
571
600
  crew.add_task(RCrewAI::Task.new(
572
601
  name: "keyword_research",
@@ -596,7 +625,7 @@ class ContentMarketingCampaign
596
625
  )
597
626
 
598
627
  crew.add_agent(social_manager)
599
- crew.add_shared_context(@shared_resources)
628
+ share_context(crew, @shared_resources)
600
629
 
601
630
  crew.add_task(RCrewAI::Task.new(
602
631
  name: "social_content",
@@ -619,7 +648,7 @@ class ContentMarketingCampaign
619
648
  )
620
649
 
621
650
  crew.add_agent(email_specialist)
622
- crew.add_shared_context(@shared_resources)
651
+ share_context(crew, @shared_resources)
623
652
 
624
653
  crew.add_task(RCrewAI::Task.new(
625
654
  name: "email_sequence",
@@ -642,7 +671,7 @@ class ContentMarketingCampaign
642
671
  )
643
672
 
644
673
  crew.add_agent(data_analyst)
645
- crew.add_shared_context(@shared_resources)
674
+ share_context(crew, @shared_resources)
646
675
 
647
676
  crew.add_task(RCrewAI::Task.new(
648
677
  name: "tracking_setup",
@@ -667,7 +696,7 @@ class ContentMarketingCampaign
667
696
 
668
697
  {
669
698
  crew_type: crew_type,
670
- success: true,
699
+ success: results[:failed_tasks].zero?, # failed tasks don't raise
671
700
  results: results,
672
701
  duration: duration,
673
702
  crew_name: crew.name
@@ -730,7 +759,8 @@ class ContentMarketingCampaign
730
759
  end
731
760
  end
732
761
 
733
- # Thread pool executor for parallel crew execution
762
+ # Application code: a small thread pool for parallel crew execution.
763
+ # concurrent-ruby, already a dependency of the gem, is a sturdier option.
734
764
  class ThreadPoolExecutor
735
765
  def initialize(max_threads: 5)
736
766
  @max_threads = max_threads
@@ -760,25 +790,22 @@ end
760
790
  class Future
761
791
  def initialize(&block)
762
792
  @block = block
763
- @executed = false
793
+ @done = Queue.new
764
794
  @result = nil
765
795
  @error = nil
766
796
  end
767
797
 
768
798
  def execute
769
- return if @executed
770
-
771
- begin
772
- @result = @block.call
773
- rescue => e
774
- @error = e
775
- ensure
776
- @executed = true
777
- end
799
+ @result = @block.call
800
+ rescue => e
801
+ @error = e
802
+ ensure
803
+ @done.close
778
804
  end
779
805
 
806
+ # Blocks until the block has finished.
780
807
  def value
781
- return @result if @executed && @error.nil?
808
+ @done.pop
782
809
  raise @error if @error
783
810
  @result
784
811
  end
@@ -886,11 +913,11 @@ class ResourceAwareCrew < RCrewAI::Crew
886
913
  shared_data = get_shared_resource("processed_data")
887
914
 
888
915
  if shared_config
889
- add_shared_context(shared_config)
916
+ share_context(self, shared_config)
890
917
  end
891
918
 
892
919
  if shared_data
893
- add_shared_context({ shared_data: shared_data })
920
+ share_context(self, { shared_data: shared_data })
894
921
  end
895
922
  end
896
923
 
@@ -913,12 +940,13 @@ end
913
940
  research_crew = ResourceAwareCrew.new("market_research")
914
941
  development_crew = ResourceAwareCrew.new("product_development")
915
942
  marketing_crew = ResourceAwareCrew.new("marketing_launch")
943
+ # ...add agents and tasks to each crew, as in the earlier examples
916
944
 
917
945
  # Share global configuration
918
946
  $resource_manager.store_resource("global_config", {
919
947
  product_name: "AI Analytics Platform",
920
948
  target_market: "B2B SaaS",
921
- launch_date: "2024-Q2",
949
+ launch_date: "next quarter",
922
950
  budget: "$500K"
923
951
  }, "orchestrator")
924
952
 
@@ -1158,7 +1186,7 @@ class CommunicatingCrew < RCrewAI::Crew
1158
1186
 
1159
1187
  def handle_data_sharing(message)
1160
1188
  puts "📊 Data shared from #{message[:from]}"
1161
- add_shared_context(message[:content])
1189
+ share_context(self, message[:content])
1162
1190
  end
1163
1191
 
1164
1192
  def handle_coordination(message)
@@ -1177,6 +1205,7 @@ end
1177
1205
  frontend_crew = CommunicatingCrew.new("frontend_team")
1178
1206
  backend_crew = CommunicatingCrew.new("backend_team")
1179
1207
  qa_crew = CommunicatingCrew.new("qa_team")
1208
+ # ...add agents and tasks to each crew, as in the earlier examples
1180
1209
 
1181
1210
  # Setup communication subscriptions
1182
1211
  frontend_crew.subscribe_to("backend_team", message_types: [:api_ready, :schema_update])
@@ -1236,15 +1265,16 @@ class MultiCrewOrchestrator
1236
1265
  crew_config = @crews[crew_name]
1237
1266
  crew = crew_config[:crew]
1238
1267
 
1239
- # Wait for dependencies
1240
- wait_for_dependencies(crew_name)
1268
+ # Confirm dependencies succeeded
1269
+ check_dependencies(crew_name)
1241
1270
 
1242
1271
  # Mark as running
1243
1272
  crew_config[:status] = :running
1244
1273
 
1245
1274
  begin
1246
- # Execute crew
1275
+ # Execute crew. Failed tasks don't raise, so check for them here.
1247
1276
  result = crew.execute
1277
+ raise "#{result[:failed_tasks]} task(s) failed" if result[:failed_tasks].positive?
1248
1278
 
1249
1279
  # Mark as completed
1250
1280
  crew_config[:status] = :completed
@@ -1300,7 +1330,7 @@ class MultiCrewOrchestrator
1300
1330
 
1301
1331
  temp_visited.delete(crew_name)
1302
1332
  visited.add(crew_name)
1303
- result.unshift(crew_name)
1333
+ result << crew_name # dependencies were added first
1304
1334
  end
1305
1335
 
1306
1336
  @crews.keys.each do |crew_name|
@@ -1310,19 +1340,15 @@ class MultiCrewOrchestrator
1310
1340
  result
1311
1341
  end
1312
1342
 
1313
- def wait_for_dependencies(crew_name)
1343
+ def check_dependencies(crew_name)
1314
1344
  dependencies = @execution_graph[crew_name]
1315
1345
  return if dependencies.empty?
1316
1346
 
1317
- puts "⏳ Waiting for dependencies: #{dependencies.join(', ')}"
1318
-
1347
+ # Crews run one at a time in dependency order, so every dependency has
1348
+ # already finished by now. Stop if one of them didn't succeed.
1319
1349
  dependencies.each do |dep_name|
1320
- while @crews[dep_name][:status] != :completed
1321
- if @crews[dep_name][:status] == :failed
1322
- raise "Dependency #{dep_name} failed, cannot execute #{crew_name}"
1323
- end
1324
-
1325
- sleep(1)
1350
+ unless @crews[dep_name][:status] == :completed
1351
+ raise "Dependency #{dep_name} did not complete, cannot execute #{crew_name}"
1326
1352
  end
1327
1353
  end
1328
1354
 
@@ -1337,11 +1363,7 @@ class MultiCrewOrchestrator
1337
1363
  dependent_crew = @crews[dependent_name][:crew]
1338
1364
 
1339
1365
  # Share results as context
1340
- if dependent_crew.respond_to?(:add_shared_context)
1341
- dependent_crew.add_shared_context({
1342
- "#{crew_name}_results" => results
1343
- })
1344
- end
1366
+ share_context(dependent_crew, "#{crew_name} results:\n#{results[:results].map { |r| r[:result] }.join("\n\n")}")
1345
1367
  end
1346
1368
  end
1347
1369
 
@@ -1416,6 +1438,7 @@ class MultiCrewOrchestrator
1416
1438
  end
1417
1439
 
1418
1440
  # Example: Complex Software Release Pipeline
1441
+ # (planning_crew, dev_crew, and the others are crews you've already built)
1419
1442
  orchestrator = MultiCrewOrchestrator.new
1420
1443
 
1421
1444
  # Add crews with dependencies
@@ -1517,12 +1540,9 @@ class ProductionMultiCrewSystem
1517
1540
  # Basic health check
1518
1541
  crew = crew_info[:crew]
1519
1542
 
1520
- health_status = if crew.respond_to?(:health_check)
1521
- crew.health_check
1522
- else
1523
- # Default health check
1524
- { status: :healthy, agents: crew.agents.length }
1525
- end
1543
+ # Crews have no built-in health check, so this only reports their size.
1544
+ # Replace it with whatever "healthy" means for your application.
1545
+ health_status = { status: crew.agents.any? ? :healthy : :unhealthy, agents: crew.agents.length }
1526
1546
 
1527
1547
  crew_info[:health] = health_status[:status]
1528
1548
  crew_info[:last_health_check] = Time.now
@@ -1687,6 +1707,5 @@ Now that you understand multi-crew operations:
1687
1707
  1. Try the [Production Deployment]({{ site.baseurl }}/tutorials/deployment) tutorial
1688
1708
  2. Review the [API Documentation]({{ site.baseurl }}/api/) for detailed reference
1689
1709
  3. Check out [Advanced Examples]({{ site.baseurl }}/examples/) for complex scenarios
1690
- 4. Explore [Integration Patterns]({{ site.baseurl }}/guides/) for enterprise use
1691
1710
 
1692
1711
  Multi-crew systems are essential for building scalable AI operations that can handle complex, enterprise-level workflows with reliability and efficiency.
@@ -0,0 +1,115 @@
1
+ ---
2
+ layout: tutorial
3
+ title: LLM Providers
4
+ description: Configure OpenAI, Anthropic, Google, Azure, Ollama, Bedrock, Snowflake Cortex, OpenAI-compatible endpoints and the Responses API
5
+ ---
6
+
7
+ # LLM Providers
8
+
9
+ RCrewAI has nine providers behind one interface. You choose one globally with
10
+ `config.llm_provider`, and any agent can override it.
11
+
12
+ | `llm_provider` | Needs | API key from |
13
+ |---|---|---|
14
+ | `:openai` | | `OPENAI_API_KEY` |
15
+ | `:openai_responses` | | `OPENAI_API_KEY` |
16
+ | `:anthropic` | | `ANTHROPIC_API_KEY` or `CLAUDE_API_KEY` |
17
+ | `:google` | | `GOOGLE_API_KEY` or `GEMINI_API_KEY` |
18
+ | `:azure` | `base_url`, `deployment_name`, `api_version` | `AZURE_OPENAI_API_KEY` |
19
+ | `:ollama` | a model | none |
20
+ | `:openai_compatible` | `base_url`, a model | `config.api_key` or `LLM_API_KEY` |
21
+ | `:bedrock` | `aws_region`, a model | `config.api_key` or `LLM_API_KEY` |
22
+ | `:snowflake` | `snowflake_account`, a model | `config.api_key` or `LLM_API_KEY` |
23
+
24
+ ## Examples
25
+
26
+ ```ruby
27
+ # OpenAI
28
+ RCrewAI.configure do |config|
29
+ config.llm_provider = :openai
30
+ config.openai_model = 'gpt-4o'
31
+ end
32
+
33
+ # Anthropic
34
+ RCrewAI.configure do |config|
35
+ config.llm_provider = :anthropic
36
+ config.anthropic_model = 'claude-opus-5-5'
37
+ end
38
+
39
+ # Google
40
+ RCrewAI.configure do |config|
41
+ config.llm_provider = :google
42
+ config.google_model = 'gemini-3.8-flash'
43
+ end
44
+
45
+ # Azure OpenAI
46
+ RCrewAI.configure do |config|
47
+ config.llm_provider = :azure
48
+ config.base_url = 'https://your-resource.openai.azure.com/'
49
+ config.deployment_name = 'your-deployment'
50
+ config.api_version = '2024-10-21'
51
+ end
52
+
53
+ # Ollama (local, no key). Set OLLAMA_HOST or config.base_url if it isn't on
54
+ # http://localhost:11434.
55
+ RCrewAI.configure do |config|
56
+ config.llm_provider = :ollama
57
+ config.model = 'llama3.1'
58
+ end
59
+
60
+ # Any endpoint speaking OpenAI Chat Completions:
61
+ # Together, Groq, Fireworks, vLLM, LiteLLM, OpenRouter, your own gateway
62
+ RCrewAI.configure do |config|
63
+ config.llm_provider = :openai_compatible
64
+ config.base_url = 'https://api.groq.com/openai/v1'
65
+ config.api_key = ENV['GROQ_API_KEY']
66
+ config.model = 'your-model'
67
+ end
68
+
69
+ # AWS Bedrock (Converse API)
70
+ RCrewAI.configure do |config|
71
+ config.llm_provider = :bedrock
72
+ config.aws_region = 'us-east-1' # or AWS_REGION / AWS_DEFAULT_REGION
73
+ config.api_key = ENV['BEDROCK_API_KEY']
74
+ config.model = 'your-bedrock-model-id'
75
+ end
76
+
77
+ # Snowflake Cortex
78
+ RCrewAI.configure do |config|
79
+ config.llm_provider = :snowflake
80
+ config.snowflake_account = 'your-account' # or SNOWFLAKE_ACCOUNT
81
+ config.api_key = ENV['SNOWFLAKE_TOKEN']
82
+ config.model = 'your-cortex-model'
83
+ end
84
+ ```
85
+
86
+ ## Provider limitations
87
+
88
+ - **Anthropic and `temperature`:** current Claude models reject `temperature`, so the
89
+ client only sends one you set yourself. If you set `config.temperature` for other
90
+ providers, clear it on Claude agents with `llm: { provider: :anthropic, temperature: nil }`.
91
+ - **Anthropic and `max_tokens`:** current Claude models always think, and thinking counts
92
+ toward `max_tokens` (default 4000). Raise it if replies get cut off.
93
+ - **Bedrock auth:** `api_key` is sent as a bearer token, which covers Bedrock API
94
+ keys and gateways in front of Bedrock. SigV4 signing isn't built in; you can sign
95
+ requests yourself in a [`before_request` hook]({{ site.baseurl }}/tutorials/interceptors-and-events).
96
+ - **Responses API:** `:openai_responses` doesn't stream. It shares `openai_model`
97
+ and `openai_api_key` with `:openai`.
98
+ - **Live streaming features:** `cancel:` and `cached_tokens` are Anthropic-only. See
99
+ [Live Streaming]({{ site.baseurl }}/tutorials/live-streaming).
100
+
101
+ ## Per-agent overrides
102
+
103
+ ```ruby
104
+ writer = RCrewAI::Agent.new(name: 'writer', role: 'Writer', goal: 'Write',
105
+ llm: :anthropic) # provider only
106
+
107
+ analyst = RCrewAI::Agent.new(name: 'analyst', role: 'Analyst', goal: 'Analyze',
108
+ llm: { provider: :openai, model: 'gpt-4o-mini', temperature: 0.2 })
109
+ ```
110
+
111
+ `llm:` also takes a pre-built client. An override never changes the global
112
+ configuration.
113
+
114
+ An override inherits the global `temperature` unless it sets its own. `temperature: nil`
115
+ clears it.
@@ -0,0 +1,55 @@
1
+ # Upgrading to RCrewAI 0.8 through 0.11
2
+
3
+ These releases are almost entirely additive. To see what's new, read the tutorials on
4
+ [providers](tutorials/providers.md), [checkpointing](tutorials/checkpointing.md),
5
+ [interceptors and events](tutorials/interceptors-and-events.md),
6
+ [concurrency](tutorials/concurrency.md) and [live streaming](tutorials/live-streaming.md).
7
+
8
+ ## Check these
9
+
10
+ **Tools now run in parallel (0.9).** If a model requests several tools in one turn, they
11
+ run concurrently. If your tools share state and aren't thread-safe, or call a
12
+ rate-limited API, set `parallel_tools: false` on those agents.
13
+
14
+ **Subclasses overriding `execute_task` (since 0.7.1).** The method is now called with a
15
+ `stream:` keyword, so `def execute_task(task)` fails with `wrong number of arguments`:
16
+
17
+ ```ruby
18
+ def execute_task(task, stream: nil, **opts)
19
+ super
20
+ end
21
+ ```
22
+
23
+ **Stream subscribers (0.8).** Delivery is now serialized, so a subscriber's own mutex is
24
+ no longer needed. Keeping it is harmless.
25
+
26
+ **Dropped dependencies (0.8.1).** `anthropic`, `ruby-openai` and `faraday-multipart` are
27
+ no longer installed with the gem. If your app uses them directly, add them to your
28
+ Gemfile.
29
+
30
+ ## 0.11
31
+
32
+ **Agents with tools should start working on real providers,** and this release changes how configuration resolves. Check these:
33
+
34
+ - **`config.model` now takes effect.** It used to be ignored on `:openai`, `:anthropic`,
35
+ `:google` and `:azure`. If you set it, check that it names the model you want, because
36
+ you may have been running on a default.
37
+ - **`:ollama`, `:openai_compatible`, `:bedrock` and `:snowflake` now need a model.**
38
+ Without one they raise `ConfigurationError` rather than sending `gpt-4`.
39
+ - **`:ollama` no longer needs an API key,** so you can remove any placeholder key.
40
+ - **`:openai_responses` now uses `openai_model`.** It always sent `gpt-4` before.
41
+
42
+ It also updates Anthropic support for current Claude models:
43
+
44
+ - **Anthropic no longer receives the default `temperature`.** Only a value you set is
45
+ sent. If you set `config.temperature` and use current Claude models, remove it or clear
46
+ it per agent with `llm: { provider: :anthropic, temperature: nil }`.
47
+ - **Tool calls now use each provider's real format.** Before, requests after a tool call
48
+ were malformed on every provider. Agents with tools should start working, so check any
49
+ retries or workarounds you added for those failures.
50
+ - **The default models changed.** `:anthropic` now defaults to `claude-opus-5-5` and
51
+ `:google` to `gemini-3.8-flash`. If you rely on a default, check the cost and output, or
52
+ set a model explicitly. Claude prices in the built-in table were also corrected, so
53
+ reported costs may change.
54
+ - **Delegation and answer revision no longer pass `temperature: 0.2`.** On other providers
55
+ they now use your configured temperature.
data/lib/rcrewai/agent.rb CHANGED
@@ -157,7 +157,6 @@ module RCrewAI
157
157
  # Use LLM to create proper delegation
158
158
  response = llm_client.chat(
159
159
  messages: [{ role: 'user', content: delegation_prompt }],
160
- temperature: 0.2,
161
160
  max_tokens: 1000
162
161
  )
163
162
 
@@ -511,7 +510,6 @@ module RCrewAI
511
510
 
512
511
  response = llm_client.chat(
513
512
  messages: [{ role: 'user', content: revision_prompt }],
514
- temperature: 0.2,
515
513
  max_tokens: 1000
516
514
  )
517
515
 
@@ -2,26 +2,38 @@
2
2
 
3
3
  module RCrewAI
4
4
  class Configuration
5
- attr_accessor :llm_provider, :api_key, :model, :temperature, :max_tokens, :timeout,
5
+ # Used when neither +<provider>_model+ nor +model+ has been set.
6
+ DEFAULT_MODELS = {
7
+ openai: 'gpt-4',
8
+ anthropic: 'claude-opus-5-5',
9
+ google: 'gemini-3.8-flash',
10
+ azure: 'gpt-4'
11
+ }.freeze
12
+
13
+ # Sent by providers that take a temperature when none has been set. The
14
+ # Anthropic client sends only #explicit_temperature, because current Claude
15
+ # models reject the field.
16
+ DEFAULT_TEMPERATURE = 0.1
17
+
18
+ # Providers that authenticate some other way, or not at all.
19
+ KEYLESS_PROVIDERS = %i[ollama].freeze
20
+
21
+ attr_accessor :llm_provider, :api_key, :model, :max_tokens, :timeout,
6
22
  :openai_api_key, :anthropic_api_key, :google_api_key, :azure_api_key,
7
- :openai_model, :anthropic_model, :google_model, :azure_model,
8
23
  :base_url, :api_version, :deployment_name,
9
24
  :aws_region, :snowflake_account,
10
25
  :pricing, :ollama_native_tools, :log_level
26
+ attr_writer :openai_model, :anthropic_model, :google_model, :azure_model
27
+
28
+ DEFAULT_MODELS.each do |provider, default|
29
+ define_method("#{provider}_model") { instance_variable_get("@#{provider}_model") || default }
30
+ end
11
31
 
12
32
  def initialize
13
33
  @llm_provider = :openai
14
- @model = 'gpt-4'
15
- @temperature = 0.1
16
34
  @max_tokens = 4000
17
35
  @timeout = 120
18
36
 
19
- # Default models for each provider
20
- @openai_model = 'gpt-4'
21
- @anthropic_model = 'claude-3-sonnet-20240229'
22
- @google_model = 'gemini-pro'
23
- @azure_model = 'gpt-4'
24
-
25
37
  @aws_region = nil
26
38
  @snowflake_account = nil
27
39
 
@@ -33,9 +45,23 @@ module RCrewAI
33
45
  load_from_env
34
46
  end
35
47
 
48
+ def temperature
49
+ @temperature_set ? @temperature : DEFAULT_TEMPERATURE
50
+ end
51
+
52
+ def temperature=(value)
53
+ @temperature = value
54
+ @temperature_set = true
55
+ end
56
+
57
+ # The temperature the user chose, or nil if they never set one.
58
+ def explicit_temperature
59
+ @temperature if @temperature_set
60
+ end
61
+
36
62
  def api_key
37
63
  case @llm_provider
38
- when :openai
64
+ when :openai, :openai_responses
39
65
  @openai_api_key || @api_key
40
66
  when :anthropic
41
67
  @anthropic_api_key || @api_key
@@ -48,49 +74,49 @@ module RCrewAI
48
74
  end
49
75
  end
50
76
 
77
+ # Resolution order: an explicit +<provider>_model+, then +model+, then the
78
+ # provider's default. Providers without a default must be given a model.
51
79
  def model
52
- case @llm_provider
53
- when :openai
54
- @openai_model || @model
55
- when :anthropic
56
- @anthropic_model || @model
57
- when :google
58
- @google_model || @model
59
- when :azure
60
- @azure_model || @model
61
- else
62
- @model
63
- end
80
+ family = model_family(@llm_provider)
81
+ explicit = instance_variable_get("@#{family}_model") if DEFAULT_MODELS.key?(family)
82
+ explicit || @model || DEFAULT_MODELS[family]
64
83
  end
65
84
 
66
85
  # Returns a copy of this configuration with the given per-agent overrides
67
86
  # applied. The original configuration is left untouched, so agents can each
68
87
  # target a different provider/model without mutating global state.
69
88
  #
70
- # config.with_overrides(provider: :anthropic, model: 'claude-3-opus-20240229')
71
- def with_overrides(provider: nil, model: nil, api_key: nil, temperature: nil)
89
+ # config.with_overrides(provider: :anthropic, model: 'claude-opus-5-5')
90
+ #
91
+ # Pass temperature: nil to clear a global temperature for this copy.
92
+ def with_overrides(provider: nil, model: nil, api_key: nil, temperature: :inherit)
72
93
  copy = dup
73
94
  copy.llm_provider = provider.to_sym if provider
74
95
  target = copy.llm_provider
75
96
 
76
- copy.public_send("#{target}_model=", model) if model && copy.respond_to?("#{target}_model=")
97
+ # A global +model+ names a model on the global provider; it must not
98
+ # follow an agent that switches to a different one.
99
+ copy.model = nil if target != llm_provider
100
+
101
+ family = model_family(target)
102
+ copy.public_send("#{family}_model=", model) if model && copy.respond_to?("#{family}_model=")
77
103
  copy.model = model if model
78
104
 
79
105
  copy.public_send("#{target}_api_key=", api_key) if api_key && copy.respond_to?("#{target}_api_key=")
80
106
  copy.api_key = api_key if api_key
81
107
 
82
- copy.temperature = temperature unless temperature.nil?
108
+ copy.temperature = temperature unless temperature == :inherit
83
109
  copy
84
110
  end
85
111
 
86
112
  def validate!
87
113
  raise ConfigurationError, 'LLM provider must be set' if @llm_provider.nil?
88
- raise ConfigurationError, "API key must be set for #{@llm_provider}" if api_key.nil? || api_key.empty?
114
+ raise ConfigurationError, "API key must be set for #{@llm_provider}" if api_key_missing?
89
115
  raise ConfigurationError, "Model must be set for #{@llm_provider}" if model.nil? || model.empty?
90
116
  end
91
117
 
92
118
  def supported_providers
93
- %i[openai anthropic google azure ollama]
119
+ LLMClient::PROVIDERS.keys
94
120
  end
95
121
 
96
122
  def provider_supported?(provider)
@@ -99,6 +125,15 @@ module RCrewAI
99
125
 
100
126
  private
101
127
 
128
+ # The Responses API is OpenAI under another request shape: same models, same key.
129
+ def model_family(provider)
130
+ provider == :openai_responses ? :openai : provider
131
+ end
132
+
133
+ def api_key_missing?
134
+ !KEYLESS_PROVIDERS.include?(@llm_provider.to_sym) && (api_key.nil? || api_key.empty?)
135
+ end
136
+
102
137
  def load_from_env
103
138
  @openai_api_key = ENV['OPENAI_API_KEY']
104
139
  @anthropic_api_key = ENV['ANTHROPIC_API_KEY'] || ENV['CLAUDE_API_KEY']
@@ -16,11 +16,21 @@ module RCrewAI
16
16
  'gpt-4-turbo' => 128_000,
17
17
  'gpt-4' => 8_192,
18
18
  'gpt-3.5-turbo' => 16_385,
19
- 'claude-opus-4-7' => 200_000,
20
- 'claude-sonnet-4-6' => 200_000,
19
+ 'claude-fable-5-1' => 1_000_000,
20
+ 'claude-opus-5-5' => 1_000_000,
21
+ 'claude-opus-5' => 1_000_000,
22
+ 'claude-opus-4-8' => 1_000_000,
23
+ 'claude-opus-4-7' => 1_000_000,
24
+ 'claude-opus-4-6' => 1_000_000,
25
+ 'claude-sonnet-5-5' => 1_000_000,
26
+ 'claude-sonnet-5' => 1_000_000,
27
+ 'claude-sonnet-4-6' => 1_000_000,
28
+ 'claude-haiku-5-5' => 1_000_000,
21
29
  'claude-haiku-4-5' => 200_000,
22
30
  'claude-3-5-sonnet-20241022' => 200_000,
23
31
  'claude-3-haiku-20240307' => 200_000,
32
+ 'gemini-3.8-flash' => 1_000_000,
33
+ 'gemini-3.5-flash-lite' => 1_000_000,
24
34
  'gemini-1.5-pro' => 1_000_000,
25
35
  'gemini-1.5-flash' => 1_000_000
26
36
  }.freeze