Class: ClaudeAgentSDK::ResultMessage

Inherits:
Type
  • Object
show all
Defined in:
lib/claude_agent_sdk/types.rb

Overview

Result message with cost and usage information

Instance Attribute Summary collapse

Method Summary

Methods inherited from Type

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

Constructor Details

This class inherits a constructor from ClaudeAgentSDK::Type

Dynamic Method Handling

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

Instance Attribute Details

#api_error_statusObject

model_usage maps model name => per-model usage Hash, passed through verbatim from the CLI's modelUsage field, so its keys are camelCase (matches the TypeScript/Python SDKs' ModelUsage shape): inputTokens, outputTokens, cacheReadInputTokens, cacheCreationInputTokens, webSearchRequests, costUSD, contextWindow, maxOutputTokens, plus optional canonicalModel (canonical id used for the pricing lookup — may differ from the raw model-string key for provider-specific ids/aliases) and provider ('firstParty', 'bedrock', 'vertex', ...).

terminal_reason says why the query loop ended ("completed", "max_turns", "aborted_streaming", ...). "aborted_streaming" / "aborted_tools" mean the turn was cancelled via Client#interrupt (an interrupt control request). nil when the CLI did not report one (older CLI versions, or a result that bypassed the query loop such as a local slash command).



427
428
429
# File 'lib/claude_agent_sdk/types.rb', line 427

def api_error_status
  @api_error_status
end

#deferred_tool_useObject

DeferredToolUse, populated when a PreToolUse hook deferred



438
439
440
# File 'lib/claude_agent_sdk/types.rb', line 438

def deferred_tool_use
  @deferred_tool_use
end

#duration_api_msObject

model_usage maps model name => per-model usage Hash, passed through verbatim from the CLI's modelUsage field, so its keys are camelCase (matches the TypeScript/Python SDKs' ModelUsage shape): inputTokens, outputTokens, cacheReadInputTokens, cacheCreationInputTokens, webSearchRequests, costUSD, contextWindow, maxOutputTokens, plus optional canonicalModel (canonical id used for the pricing lookup — may differ from the raw model-string key for provider-specific ids/aliases) and provider ('firstParty', 'bedrock', 'vertex', ...).

terminal_reason says why the query loop ended ("completed", "max_turns", "aborted_streaming", ...). "aborted_streaming" / "aborted_tools" mean the turn was cancelled via Client#interrupt (an interrupt control request). nil when the CLI did not report one (older CLI versions, or a result that bypassed the query loop such as a local slash command).



427
428
429
# File 'lib/claude_agent_sdk/types.rb', line 427

def duration_api_ms
  @duration_api_ms
end

#duration_msObject

model_usage maps model name => per-model usage Hash, passed through verbatim from the CLI's modelUsage field, so its keys are camelCase (matches the TypeScript/Python SDKs' ModelUsage shape): inputTokens, outputTokens, cacheReadInputTokens, cacheCreationInputTokens, webSearchRequests, costUSD, contextWindow, maxOutputTokens, plus optional canonicalModel (canonical id used for the pricing lookup — may differ from the raw model-string key for provider-specific ids/aliases) and provider ('firstParty', 'bedrock', 'vertex', ...).

terminal_reason says why the query loop ended ("completed", "max_turns", "aborted_streaming", ...). "aborted_streaming" / "aborted_tools" mean the turn was cancelled via Client#interrupt (an interrupt control request). nil when the CLI did not report one (older CLI versions, or a result that bypassed the query loop such as a local slash command).



427
428
429
# File 'lib/claude_agent_sdk/types.rb', line 427

def duration_ms
  @duration_ms
end

#errorsObject

model_usage maps model name => per-model usage Hash, passed through verbatim from the CLI's modelUsage field, so its keys are camelCase (matches the TypeScript/Python SDKs' ModelUsage shape): inputTokens, outputTokens, cacheReadInputTokens, cacheCreationInputTokens, webSearchRequests, costUSD, contextWindow, maxOutputTokens, plus optional canonicalModel (canonical id used for the pricing lookup — may differ from the raw model-string key for provider-specific ids/aliases) and provider ('firstParty', 'bedrock', 'vertex', ...).

terminal_reason says why the query loop ended ("completed", "max_turns", "aborted_streaming", ...). "aborted_streaming" / "aborted_tools" mean the turn was cancelled via Client#interrupt (an interrupt control request). nil when the CLI did not report one (older CLI versions, or a result that bypassed the query loop such as a local slash command).



427
428
429
# File 'lib/claude_agent_sdk/types.rb', line 427

def errors
  @errors
end

#fast_mode_stateObject

model_usage maps model name => per-model usage Hash, passed through verbatim from the CLI's modelUsage field, so its keys are camelCase (matches the TypeScript/Python SDKs' ModelUsage shape): inputTokens, outputTokens, cacheReadInputTokens, cacheCreationInputTokens, webSearchRequests, costUSD, contextWindow, maxOutputTokens, plus optional canonicalModel (canonical id used for the pricing lookup — may differ from the raw model-string key for provider-specific ids/aliases) and provider ('firstParty', 'bedrock', 'vertex', ...).

terminal_reason says why the query loop ended ("completed", "max_turns", "aborted_streaming", ...). "aborted_streaming" / "aborted_tools" mean the turn was cancelled via Client#interrupt (an interrupt control request). nil when the CLI did not report one (older CLI versions, or a result that bypassed the query loop such as a local slash command).



427
428
429
# File 'lib/claude_agent_sdk/types.rb', line 427

def fast_mode_state
  @fast_mode_state
end

#is_errorObject

model_usage maps model name => per-model usage Hash, passed through verbatim from the CLI's modelUsage field, so its keys are camelCase (matches the TypeScript/Python SDKs' ModelUsage shape): inputTokens, outputTokens, cacheReadInputTokens, cacheCreationInputTokens, webSearchRequests, costUSD, contextWindow, maxOutputTokens, plus optional canonicalModel (canonical id used for the pricing lookup — may differ from the raw model-string key for provider-specific ids/aliases) and provider ('firstParty', 'bedrock', 'vertex', ...).

terminal_reason says why the query loop ended ("completed", "max_turns", "aborted_streaming", ...). "aborted_streaming" / "aborted_tools" mean the turn was cancelled via Client#interrupt (an interrupt control request). nil when the CLI did not report one (older CLI versions, or a result that bypassed the query loop such as a local slash command).



427
428
429
# File 'lib/claude_agent_sdk/types.rb', line 427

def is_error
  @is_error
end

#model_usageObject

model_usage maps model name => per-model usage Hash, passed through verbatim from the CLI's modelUsage field, so its keys are camelCase (matches the TypeScript/Python SDKs' ModelUsage shape): inputTokens, outputTokens, cacheReadInputTokens, cacheCreationInputTokens, webSearchRequests, costUSD, contextWindow, maxOutputTokens, plus optional canonicalModel (canonical id used for the pricing lookup — may differ from the raw model-string key for provider-specific ids/aliases) and provider ('firstParty', 'bedrock', 'vertex', ...).

terminal_reason says why the query loop ended ("completed", "max_turns", "aborted_streaming", ...). "aborted_streaming" / "aborted_tools" mean the turn was cancelled via Client#interrupt (an interrupt control request). nil when the CLI did not report one (older CLI versions, or a result that bypassed the query loop such as a local slash command).



427
428
429
# File 'lib/claude_agent_sdk/types.rb', line 427

def model_usage
  @model_usage
end

#num_turnsObject

model_usage maps model name => per-model usage Hash, passed through verbatim from the CLI's modelUsage field, so its keys are camelCase (matches the TypeScript/Python SDKs' ModelUsage shape): inputTokens, outputTokens, cacheReadInputTokens, cacheCreationInputTokens, webSearchRequests, costUSD, contextWindow, maxOutputTokens, plus optional canonicalModel (canonical id used for the pricing lookup — may differ from the raw model-string key for provider-specific ids/aliases) and provider ('firstParty', 'bedrock', 'vertex', ...).

terminal_reason says why the query loop ended ("completed", "max_turns", "aborted_streaming", ...). "aborted_streaming" / "aborted_tools" mean the turn was cancelled via Client#interrupt (an interrupt control request). nil when the CLI did not report one (older CLI versions, or a result that bypassed the query loop such as a local slash command).



427
428
429
# File 'lib/claude_agent_sdk/types.rb', line 427

def num_turns
  @num_turns
end

#permission_denialsObject

model_usage maps model name => per-model usage Hash, passed through verbatim from the CLI's modelUsage field, so its keys are camelCase (matches the TypeScript/Python SDKs' ModelUsage shape): inputTokens, outputTokens, cacheReadInputTokens, cacheCreationInputTokens, webSearchRequests, costUSD, contextWindow, maxOutputTokens, plus optional canonicalModel (canonical id used for the pricing lookup — may differ from the raw model-string key for provider-specific ids/aliases) and provider ('firstParty', 'bedrock', 'vertex', ...).

terminal_reason says why the query loop ended ("completed", "max_turns", "aborted_streaming", ...). "aborted_streaming" / "aborted_tools" mean the turn was cancelled via Client#interrupt (an interrupt control request). nil when the CLI did not report one (older CLI versions, or a result that bypassed the query loop such as a local slash command).



427
428
429
# File 'lib/claude_agent_sdk/types.rb', line 427

def permission_denials
  @permission_denials
end

#resultObject

model_usage maps model name => per-model usage Hash, passed through verbatim from the CLI's modelUsage field, so its keys are camelCase (matches the TypeScript/Python SDKs' ModelUsage shape): inputTokens, outputTokens, cacheReadInputTokens, cacheCreationInputTokens, webSearchRequests, costUSD, contextWindow, maxOutputTokens, plus optional canonicalModel (canonical id used for the pricing lookup — may differ from the raw model-string key for provider-specific ids/aliases) and provider ('firstParty', 'bedrock', 'vertex', ...).

terminal_reason says why the query loop ended ("completed", "max_turns", "aborted_streaming", ...). "aborted_streaming" / "aborted_tools" mean the turn was cancelled via Client#interrupt (an interrupt control request). nil when the CLI did not report one (older CLI versions, or a result that bypassed the query loop such as a local slash command).



427
428
429
# File 'lib/claude_agent_sdk/types.rb', line 427

def result
  @result
end

#session_idObject

model_usage maps model name => per-model usage Hash, passed through verbatim from the CLI's modelUsage field, so its keys are camelCase (matches the TypeScript/Python SDKs' ModelUsage shape): inputTokens, outputTokens, cacheReadInputTokens, cacheCreationInputTokens, webSearchRequests, costUSD, contextWindow, maxOutputTokens, plus optional canonicalModel (canonical id used for the pricing lookup — may differ from the raw model-string key for provider-specific ids/aliases) and provider ('firstParty', 'bedrock', 'vertex', ...).

terminal_reason says why the query loop ended ("completed", "max_turns", "aborted_streaming", ...). "aborted_streaming" / "aborted_tools" mean the turn was cancelled via Client#interrupt (an interrupt control request). nil when the CLI did not report one (older CLI versions, or a result that bypassed the query loop such as a local slash command).



427
428
429
# File 'lib/claude_agent_sdk/types.rb', line 427

def session_id
  @session_id
end

#stop_reasonObject

model_usage maps model name => per-model usage Hash, passed through verbatim from the CLI's modelUsage field, so its keys are camelCase (matches the TypeScript/Python SDKs' ModelUsage shape): inputTokens, outputTokens, cacheReadInputTokens, cacheCreationInputTokens, webSearchRequests, costUSD, contextWindow, maxOutputTokens, plus optional canonicalModel (canonical id used for the pricing lookup — may differ from the raw model-string key for provider-specific ids/aliases) and provider ('firstParty', 'bedrock', 'vertex', ...).

terminal_reason says why the query loop ended ("completed", "max_turns", "aborted_streaming", ...). "aborted_streaming" / "aborted_tools" mean the turn was cancelled via Client#interrupt (an interrupt control request). nil when the CLI did not report one (older CLI versions, or a result that bypassed the query loop such as a local slash command).



427
428
429
# File 'lib/claude_agent_sdk/types.rb', line 427

def stop_reason
  @stop_reason
end

#structured_outputObject

model_usage maps model name => per-model usage Hash, passed through verbatim from the CLI's modelUsage field, so its keys are camelCase (matches the TypeScript/Python SDKs' ModelUsage shape): inputTokens, outputTokens, cacheReadInputTokens, cacheCreationInputTokens, webSearchRequests, costUSD, contextWindow, maxOutputTokens, plus optional canonicalModel (canonical id used for the pricing lookup — may differ from the raw model-string key for provider-specific ids/aliases) and provider ('firstParty', 'bedrock', 'vertex', ...).

terminal_reason says why the query loop ended ("completed", "max_turns", "aborted_streaming", ...). "aborted_streaming" / "aborted_tools" mean the turn was cancelled via Client#interrupt (an interrupt control request). nil when the CLI did not report one (older CLI versions, or a result that bypassed the query loop such as a local slash command).



427
428
429
# File 'lib/claude_agent_sdk/types.rb', line 427

def structured_output
  @structured_output
end

#subtypeObject

model_usage maps model name => per-model usage Hash, passed through verbatim from the CLI's modelUsage field, so its keys are camelCase (matches the TypeScript/Python SDKs' ModelUsage shape): inputTokens, outputTokens, cacheReadInputTokens, cacheCreationInputTokens, webSearchRequests, costUSD, contextWindow, maxOutputTokens, plus optional canonicalModel (canonical id used for the pricing lookup — may differ from the raw model-string key for provider-specific ids/aliases) and provider ('firstParty', 'bedrock', 'vertex', ...).

terminal_reason says why the query loop ended ("completed", "max_turns", "aborted_streaming", ...). "aborted_streaming" / "aborted_tools" mean the turn was cancelled via Client#interrupt (an interrupt control request). nil when the CLI did not report one (older CLI versions, or a result that bypassed the query loop such as a local slash command).



427
428
429
# File 'lib/claude_agent_sdk/types.rb', line 427

def subtype
  @subtype
end

#terminal_reasonObject

model_usage maps model name => per-model usage Hash, passed through verbatim from the CLI's modelUsage field, so its keys are camelCase (matches the TypeScript/Python SDKs' ModelUsage shape): inputTokens, outputTokens, cacheReadInputTokens, cacheCreationInputTokens, webSearchRequests, costUSD, contextWindow, maxOutputTokens, plus optional canonicalModel (canonical id used for the pricing lookup — may differ from the raw model-string key for provider-specific ids/aliases) and provider ('firstParty', 'bedrock', 'vertex', ...).

terminal_reason says why the query loop ended ("completed", "max_turns", "aborted_streaming", ...). "aborted_streaming" / "aborted_tools" mean the turn was cancelled via Client#interrupt (an interrupt control request). nil when the CLI did not report one (older CLI versions, or a result that bypassed the query loop such as a local slash command).



427
428
429
# File 'lib/claude_agent_sdk/types.rb', line 427

def terminal_reason
  @terminal_reason
end

#total_cost_usdObject

model_usage maps model name => per-model usage Hash, passed through verbatim from the CLI's modelUsage field, so its keys are camelCase (matches the TypeScript/Python SDKs' ModelUsage shape): inputTokens, outputTokens, cacheReadInputTokens, cacheCreationInputTokens, webSearchRequests, costUSD, contextWindow, maxOutputTokens, plus optional canonicalModel (canonical id used for the pricing lookup — may differ from the raw model-string key for provider-specific ids/aliases) and provider ('firstParty', 'bedrock', 'vertex', ...).

terminal_reason says why the query loop ended ("completed", "max_turns", "aborted_streaming", ...). "aborted_streaming" / "aborted_tools" mean the turn was cancelled via Client#interrupt (an interrupt control request). nil when the CLI did not report one (older CLI versions, or a result that bypassed the query loop such as a local slash command).



427
428
429
# File 'lib/claude_agent_sdk/types.rb', line 427

def total_cost_usd
  @total_cost_usd
end

#usageObject

model_usage maps model name => per-model usage Hash, passed through verbatim from the CLI's modelUsage field, so its keys are camelCase (matches the TypeScript/Python SDKs' ModelUsage shape): inputTokens, outputTokens, cacheReadInputTokens, cacheCreationInputTokens, webSearchRequests, costUSD, contextWindow, maxOutputTokens, plus optional canonicalModel (canonical id used for the pricing lookup — may differ from the raw model-string key for provider-specific ids/aliases) and provider ('firstParty', 'bedrock', 'vertex', ...).

terminal_reason says why the query loop ended ("completed", "max_turns", "aborted_streaming", ...). "aborted_streaming" / "aborted_tools" mean the turn was cancelled via Client#interrupt (an interrupt control request). nil when the CLI did not report one (older CLI versions, or a result that bypassed the query loop such as a local slash command).



427
428
429
# File 'lib/claude_agent_sdk/types.rb', line 427

def usage
  @usage
end

#uuidObject

model_usage maps model name => per-model usage Hash, passed through verbatim from the CLI's modelUsage field, so its keys are camelCase (matches the TypeScript/Python SDKs' ModelUsage shape): inputTokens, outputTokens, cacheReadInputTokens, cacheCreationInputTokens, webSearchRequests, costUSD, contextWindow, maxOutputTokens, plus optional canonicalModel (canonical id used for the pricing lookup — may differ from the raw model-string key for provider-specific ids/aliases) and provider ('firstParty', 'bedrock', 'vertex', ...).

terminal_reason says why the query loop ended ("completed", "max_turns", "aborted_streaming", ...). "aborted_streaming" / "aborted_tools" mean the turn was cancelled via Client#interrupt (an interrupt control request). nil when the CLI did not report one (older CLI versions, or a result that bypassed the query loop such as a local slash command).



427
428
429
# File 'lib/claude_agent_sdk/types.rb', line 427

def uuid
  @uuid
end