feat: add campaign context to Captain v2 prompts (#13644)
Co-authored-by: Aakash Bakhle <48802744+aakashb95@users.noreply.github.com>
This commit is contained in:
@@ -97,7 +97,8 @@ RSpec.describe Concerns::Agentable do
|
||||
expected_context = {
|
||||
base_key: 'base_value',
|
||||
conversation: { id: 123 },
|
||||
contact: { name: 'John' }
|
||||
contact: { name: 'John' },
|
||||
campaign: {}
|
||||
}
|
||||
|
||||
expect(Captain::PromptRenderer).to receive(:render).with(
|
||||
@@ -108,6 +109,26 @@ RSpec.describe Concerns::Agentable do
|
||||
dummy_instance.agent_instructions(context_double)
|
||||
end
|
||||
|
||||
it 'merges campaign data from context state' do
|
||||
context_double = instance_double(Agents::RunContext,
|
||||
context: {
|
||||
state: {
|
||||
conversation: { id: 123 },
|
||||
contact: { name: 'John' },
|
||||
campaign: { id: 10, title: 'Summer Sale', message: 'Check it out' }
|
||||
}
|
||||
})
|
||||
|
||||
expect(Captain::PromptRenderer).to receive(:render).with(
|
||||
'dummy_class',
|
||||
hash_including(
|
||||
campaign: { id: 10, title: 'Summer Sale', message: 'Check it out' }
|
||||
)
|
||||
)
|
||||
|
||||
dummy_instance.agent_instructions(context_double)
|
||||
end
|
||||
|
||||
it 'handles context without state' do
|
||||
context_double = instance_double(Agents::RunContext, context: {})
|
||||
|
||||
@@ -116,7 +137,8 @@ RSpec.describe Concerns::Agentable do
|
||||
hash_including(
|
||||
base_key: 'base_value',
|
||||
conversation: {},
|
||||
contact: {}
|
||||
contact: {},
|
||||
campaign: {}
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user