fix(captain): default temperature to 0.5 and remove UI control (#14879)

# Pull Request Template

## Description

- Default temperature to 0.5 and remove UI control
- No migrations needed for existing accounts, their current settings are
preserved

## Type of change

- [x] New feature (non-breaking change which adds functionality)

## How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. Please also list any relevant details
for your test configuration.

locally and spec

## Checklist:

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my code
- [x] I have commented on my code, particularly in hard-to-understand
areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [x] Any dependent changes have been merged and published in downstream
modules
This commit is contained in:
Aakash Bakhle
2026-06-30 15:14:03 +05:30
committed by GitHub
parent 9caceea858
commit 926a9d8a69
6 changed files with 24 additions and 31 deletions
@@ -29,7 +29,6 @@ const initialState = {
handoffMessage: '',
resolutionMessage: '',
instructions: '',
temperature: 1,
};
const state = reactive({ ...initialState });
@@ -57,7 +56,6 @@ const updateStateFromAssistant = assistant => {
state.handoffMessage = config.handoff_message;
state.resolutionMessage = config.resolution_message;
state.instructions = config.instructions;
state.temperature = config.temperature || 1;
};
const handleSystemMessagesUpdate = async () => {
@@ -80,7 +78,6 @@ const handleSystemMessagesUpdate = async () => {
...props.assistant.config,
handoff_message: state.handoffMessage,
resolution_message: state.resolutionMessage,
temperature: state.temperature || 1,
},
};
@@ -131,26 +128,6 @@ watch(
class="z-0"
/>
<div class="flex flex-col gap-2">
<label class="text-sm font-medium text-n-slate-12">
{{ t('CAPTAIN.ASSISTANTS.FORM.TEMPERATURE.LABEL') }}
</label>
<div class="flex items-center gap-4">
<input
v-model="state.temperature"
type="range"
min="0"
max="1"
step="0.1"
class="w-full"
/>
<span class="text-sm text-n-slate-12">{{ state.temperature }}</span>
</div>
<p class="text-sm text-n-slate-11 italic">
{{ t('CAPTAIN.ASSISTANTS.FORM.TEMPERATURE.DESCRIPTION') }}
</p>
</div>
<div>
<Button
:label="t('CAPTAIN.ASSISTANTS.FORM.UPDATE')"
@@ -494,10 +494,6 @@
"PLACEHOLDER": "Enter assistant name",
"ERROR": "The name is required"
},
"TEMPERATURE": {
"LABEL": "Response Temperature",
"DESCRIPTION": "Adjust how creative or restrictive the assistant's responses should be. Lower values produce more focused and deterministic responses, while higher values allow for more creative and varied outputs."
},
"DESCRIPTION": {
"LABEL": "Description",
"PLACEHOLDER": "Enter assistant description",
@@ -96,7 +96,7 @@ module Captain::ChatHelper
end
def temperature
@assistant&.config&.[]('temperature').to_f || 1
@assistant&.config&.[]('temperature').presence&.to_f || 0.5
end
def resolved_account_id
+3 -1
View File
@@ -1,13 +1,15 @@
module Concerns::Agentable
extend ActiveSupport::Concern
DEFAULT_TEMPERATURE = 0.5
def agent
Agents::Agent.new(
name: agent_name,
instructions: ->(context) { agent_instructions(context) },
tools: agent_tools,
model: agent_model,
temperature: temperature.to_f || 0.7,
temperature: temperature.presence&.to_f || DEFAULT_TEMPERATURE,
response_schema: agent_response_schema
)
end
@@ -56,11 +56,11 @@ RSpec.describe Concerns::Agentable do
dummy_instance.agent
end
it 'converts nil temperature to 0.0' do
it 'uses default temperature when temperature is nil' do
dummy_instance.temperature = nil
expect(Agents::Agent).to receive(:new).with(
hash_including(temperature: 0.0)
hash_including(temperature: 0.5)
)
dummy_instance.agent
@@ -39,6 +39,24 @@ RSpec.describe Captain::Llm::AssistantChatService do
service.generate_response(message_history: [{ role: 'user', content: 'Hello' }])
end
it 'uses default temperature when assistant config does not include temperature' do
expect(mock_chat).to receive(:with_temperature).with(0.5).and_return(mock_chat)
allow(mock_chat).to receive(:ask).and_return(mock_response)
service = described_class.new(assistant: assistant, conversation: conversation)
service.generate_response(message_history: [{ role: 'user', content: 'Hello' }])
end
it 'preserves explicit assistant config temperature' do
assistant.update!(config: assistant.config.merge('temperature' => 1.0))
expect(mock_chat).to receive(:with_temperature).with(1.0).and_return(mock_chat)
allow(mock_chat).to receive(:ask).and_return(mock_response)
service = described_class.new(assistant: assistant, conversation: conversation)
service.generate_response(message_history: [{ role: 'user', content: 'Hello' }])
end
it 'passes channel_type to the agent session instrumentation' do
service = described_class.new(assistant: assistant, conversation: conversation)