Records reasoning, citations (the FAQs the assistant found), the tool path, and the model for each V1 Captain reply in a new captain_message_generations table. The assistant reports the source IDs it actually used so cited FAQs can be flagged, and handoff messages capture the transfer reason. Agents can expand any Captain message in the conversation (a sparkle toggle on the timestamp line) to see this breakdown, fetched on demand from a dedicated endpoint. Model is shown only in development. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
24 lines
638 B
Ruby
24 lines
638 B
Ruby
module Captain::ChatGenerationPath
|
|
private
|
|
|
|
# Ordered trace of tool executions during a run: [{ 'tool' =>, 'arguments' =>, 'result' => }].
|
|
# Consumed by the assistant chat service to persist the generation path on the message.
|
|
def generation_path
|
|
@generation_path ||= []
|
|
end
|
|
|
|
def track_generation_step(tool_call)
|
|
generation_path << {
|
|
'tool' => tool_call.name.to_s,
|
|
'arguments' => tool_call.try(:arguments)
|
|
}
|
|
end
|
|
|
|
def record_generation_step_result(result)
|
|
step = generation_path.find { |s| !s.key?('result') }
|
|
return if step.blank?
|
|
|
|
step['result'] = result.to_s.truncate(2000)
|
|
end
|
|
end
|