feat: use new tools

This commit is contained in:
Shivam Mishra
2025-07-15 14:22:27 +05:30
parent c51d2d3c93
commit 1fce8d1183
4 changed files with 7 additions and 18 deletions
@@ -27,7 +27,7 @@ class Captain::Conversation::ResponseBuilderJob < ApplicationJob
def generate_and_process_response
@response = if captain_v2_enabled?
Captain::Assistant::AgentRunnerService.new(assistant: @assistant, user: find_conversation_user).generate_response(
Captain::Assistant::AgentRunnerService.new(assistant: @assistant).generate_response(
message_history: collect_previous_messages
)
else
@@ -114,13 +114,4 @@ class Captain::Conversation::ResponseBuilderJob < ApplicationJob
def captain_v2_enabled?
true
end
def find_conversation_user
# TODO: IMPORTANT - The assistant agents are user-facing and their tools should NOT need permission limits.
# The tools themselves must be built to ensure they don't perform any wrong/harmful actions.
# Currently returning first admin as a temporary solution.
# Future: Consider creating a dedicated system user for assistant operations.
account.administrators.first
end
end
+2 -2
View File
@@ -54,8 +54,8 @@ class Captain::Scenario < ApplicationRecord
"#{title} Agent".titleize
end
def agent_tools(user)
resolved_tools.map { |tool| self.class.resolve_tool_class(tool[:id]) }.map { |tool| tool.new(assistant, user: user) }
def agent_tools
resolved_tools.map { |tool| self.class.resolve_tool_class(tool[:id]) }.map { |tool| tool.new(assistant) }
end
def resolved_instructions
+1 -1
View File
@@ -36,7 +36,7 @@ module Agentable
self.class.name.demodulize.underscore
end
def agent_tools(_user)
def agent_tools
[] # Default implementation, override if needed
end
@@ -6,9 +6,8 @@ class Captain::Assistant::AgentRunnerService
label_list custom_attributes additional_attributes
].freeze
def initialize(assistant:, user: nil, conversation: nil)
def initialize(assistant:, conversation: nil)
@assistant = assistant
@user = user
@conversation = conversation
end
@@ -100,7 +99,6 @@ class Captain::Assistant::AgentRunnerService
def build_state
state = {
account_id: @assistant.account_id,
user_id: @user&.id,
assistant_id: @assistant.id,
assistant_config: @assistant.config
}
@@ -111,8 +109,8 @@ class Captain::Assistant::AgentRunnerService
end
def build_and_wire_agents
assistant_agent = @assistant.agent(@user)
scenario_agents = @assistant.scenarios.enabled.map { |scenario| scenario.agent(@user) }
assistant_agent = @assistant.agent(nil)
scenario_agents = @assistant.scenarios.enabled.map { |scenario| scenario.agent(nil) }
assistant_agent.register_handoffs(*scenario_agents) if scenario_agents.any?
scenario_agents.each { |scenario_agent| scenario_agent.register_handoffs(assistant_agent) }