Class: Collavre::AiAgentService
- Inherits:
-
Object
- Object
- Collavre::AiAgentService
- Defined in:
- app/services/collavre/ai_agent_service.rb
Overview
Orchestrates AI agent execution for a task. Delegates specific concerns to specialized service objects:
-
AgentLifecycleManager: agent status, cancellation, heartbeats
-
ResponseStreamer: streaming content updates
-
ResponseFinalizer: comment finalization, review workflow
-
A2aDispatcher: agent-to-agent event dispatch
Constant Summary collapse
- CANCEL_CHECK_INTERVAL =
Compatibility alias for constants moved to AgentLifecycleManager
AiAgent::AgentLifecycleManager::CANCEL_CHECK_INTERVAL
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(task) ⇒ AiAgentService
constructor
A new instance of AiAgentService.
Constructor Details
#initialize(task) ⇒ AiAgentService
Returns a new instance of AiAgentService.
12 13 14 15 16 |
# File 'app/services/collavre/ai_agent_service.rb', line 12 def initialize(task) @task = task @agent = task.agent @context = task.trigger_event_payload end |
Instance Method Details
#call ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/services/collavre/ai_agent_service.rb', line 18 def call Current.set(user: @agent) do if @agent.claude_channel_agent? delegate_to_claude_channel else execute_llm_conversation end end rescue ApprovalPendingError => e summary = generate_approval_summary(e) AiAgent::ApprovalHandler.new( task: @task, agent: @agent, context: @context, creative: @creative, reply_comment: @reply_comment ).handle(e, summary: summary) raise rescue CancelledError handle_cancelled abort_agent_session_if_needed raise end |