Class: ClaudeAgentSDK::TaskUpdatedMessage

Inherits:
SystemMessage show all
Defined in:
lib/claude_agent_sdk/types.rb

Overview

Task updated system message (background task lifecycle state change).

The CLI emits system/task_updated events as a task moves through its lifecycle. patch carries the changed fields (e.g. status, end_time); when patch is terminal (see TERMINAL_TASK_STATUSES) the task has finished. A background task's terminal state can arrive only as a TaskUpdatedMessage with no accompanying TaskNotificationMessage — e.g. a task stopped via TaskStop reports status "killed" here and the matching notification is sometimes suppressed. Consumers tracking active task IDs should clear them on a terminal status from either message.

Parsed defensively in the constructor — a lifecycle event must never raise: status is derived from patch (not a top-level field); a non-Hash or absent patch falls back to {}; and task_id defaults to "" (never nil, matching the Python SDK) so consumers can rely on it always being a String. The full patch is preserved on #patch for callers that need more than the status.

Instance Attribute Summary collapse

Attributes inherited from SystemMessage

#data, #subtype

Instance Method Summary collapse

Methods inherited from Type

#[], #[]=, from_hash, #to_h, wrap

Constructor Details

#initialize(attributes = {}) ⇒ TaskUpdatedMessage

Returns a new instance of TaskUpdatedMessage.



402
403
404
405
406
407
# File 'lib/claude_agent_sdk/types.rb', line 402

def initialize(attributes = {})
  super
  @task_id ||= ''
  @patch = {} unless @patch.is_a?(Hash)
  @status = @patch[:status]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ClaudeAgentSDK::Type

Instance Attribute Details

#patchObject

Returns the value of attribute patch.



400
401
402
# File 'lib/claude_agent_sdk/types.rb', line 400

def patch
  @patch
end

#session_idObject

Returns the value of attribute session_id.



400
401
402
# File 'lib/claude_agent_sdk/types.rb', line 400

def session_id
  @session_id
end

#statusObject

Returns the value of attribute status.



400
401
402
# File 'lib/claude_agent_sdk/types.rb', line 400

def status
  @status
end

#task_idObject

Returns the value of attribute task_id.



400
401
402
# File 'lib/claude_agent_sdk/types.rb', line 400

def task_id
  @task_id
end

#uuidObject

Returns the value of attribute uuid.



400
401
402
# File 'lib/claude_agent_sdk/types.rb', line 400

def uuid
  @uuid
end