diff --git a/enterprise/app/services/captain/assistant/agent_runner_service.rb b/enterprise/app/services/captain/assistant/agent_runner_service.rb index a40e096e6..c832da93e 100644 --- a/enterprise/app/services/captain/assistant/agent_runner_service.rb +++ b/enterprise/app/services/captain/assistant/agent_runner_service.rb @@ -189,8 +189,8 @@ class Captain::Assistant::AgentRunnerService root_span = context_wrapper&.context&.dig(:__otel_tracing, :root_span) return unless root_span - credits_used = !context_wrapper.context[:captain_v2_handoff_tool_called] - root_span.set_attribute(format(ATTR_LANGFUSE_METADATA, 'credits_used'), credits_used) + credit_used = !context_wrapper.context[:captain_v2_handoff_tool_called] + root_span.set_attribute(format(ATTR_LANGFUSE_METADATA, 'credit_used'), credit_used.to_s) end def add_agent_thinking_callback(runner) diff --git a/spec/enterprise/services/captain/assistant/agent_runner_service_spec.rb b/spec/enterprise/services/captain/assistant/agent_runner_service_spec.rb index 04fa0f967..bbf712622 100644 --- a/spec/enterprise/services/captain/assistant/agent_runner_service_spec.rb +++ b/spec/enterprise/services/captain/assistant/agent_runner_service_spec.rb @@ -308,7 +308,7 @@ RSpec.describe Captain::Assistant::AgentRunnerService do end describe '#add_usage_metadata_callback' do - it 'sets credits_used=false when handoff tool is used' do + it 'sets credit_used=false when handoff tool is used' do service = described_class.new(assistant: assistant, conversation: conversation) runner = instance_double(Agents::AgentRunner) tool_complete_callback = nil @@ -333,11 +333,11 @@ RSpec.describe Captain::Assistant::AgentRunnerService do tool_complete_callback.call(Captain::Tools::HandoffTool.new(assistant).name, 'ok', context_wrapper) - expect(root_span).to receive(:set_attribute).with('langfuse.trace.metadata.credits_used', false) + expect(root_span).to receive(:set_attribute).with('langfuse.trace.metadata.credit_used', 'false') run_complete_callback.call('assistant', nil, context_wrapper) end - it 'sets credits_used=true when handoff tool is not used' do + it 'sets credit_used=true when handoff tool is not used' do service = described_class.new(assistant: assistant, conversation: conversation) runner = instance_double(Agents::AgentRunner) run_complete_callback = nil @@ -356,7 +356,7 @@ RSpec.describe Captain::Assistant::AgentRunnerService do service.send(:add_usage_metadata_callback, runner) - expect(root_span).to receive(:set_attribute).with('langfuse.trace.metadata.credits_used', true) + expect(root_span).to receive(:set_attribute).with('langfuse.trace.metadata.credit_used', 'true') run_complete_callback.call('assistant', nil, context_wrapper) end end