Class: ActionMCP::ToolExecutionJob
- Inherits:
-
ActiveJob::Base
- Object
- ActiveJob::Base
- ActionMCP::ToolExecutionJob
- Includes:
- ActiveJob::Continuable
- Defined in:
- app/jobs/action_mcp/tool_execution_job.rb
Overview
ActiveJob for executing tools asynchronously in task-augmented mode Part of MCP 2025-11-25 Tasks specification with ActiveJob::Continuable support
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.handle_job_discard(job, error) ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'app/jobs/action_mcp/tool_execution_job.rb', line 115 def self.handle_job_discard(job, error) task_id = job.arguments.first task = Session::Task.find_by(id: task_id) return unless task&.persisted? return if task.terminal? Rails.logger.error "[ToolExecutionJob] Discarding job for task #{task_id}: #{error.class} - #{error.message}" Rails.logger.error error.backtrace&.first(10)&.join("\n") task.update( status_message: "Job failed: #{error.message}", continuation_state: { step: :failed, error: { class: error.class.name, message: error. }, timestamp: Time.current.iso8601 } ) task.mark_failed! end |
Instance Method Details
#perform(task_id, tool_name, arguments, meta = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/jobs/action_mcp/tool_execution_job.rb', line 23 def perform(task_id, tool_name, arguments, = {}) @task = step(:load_task, task_id) return if @task.nil? || @task.terminal? @session = step(:validate_session, @task) return unless @session @tool = step(:prepare_tool, @session, tool_name, arguments, @task) return unless @tool step(:execute_tool) do result = execute_with_reloader(@tool, @session) update_task_result(@task, result) end end |