Class: Google::ADK::CallbackContext

Inherits:
ReadonlyContext show all
Defined in:
lib/google/adk/context.rb

Overview

Context for callbacks with mutable state

Direct Known Subclasses

ToolContext

Instance Attribute Summary collapse

Attributes inherited from ReadonlyContext

#agent_name, #invocation_id

Instance Method Summary collapse

Constructor Details

#initialize(invocation_id:, agent_name:, session:) ⇒ CallbackContext

Initialize callback context

Parameters:

  • invocation_id (String)

    Unique invocation ID

  • agent_name (String)

    Current agent name

  • session (Object)

    Session object with state



69
70
71
72
73
# File 'lib/google/adk/context.rb', line 69

def initialize(invocation_id:, agent_name:, session:)
  @invocation_id = invocation_id
  @agent_name = agent_name
  @session = session
end

Instance Attribute Details

#sessionObject (readonly)

Returns the value of attribute session.



62
63
64
# File 'lib/google/adk/context.rb', line 62

def session
  @session
end

Instance Method Details

#stateHash

Get mutable state from session

Returns:

  • (Hash)

    Mutable state hash



78
79
80
# File 'lib/google/adk/context.rb', line 78

def state
  @session.state
end

#update_state(updates) ⇒ Object

Update multiple state values

Parameters:

  • updates (Hash)

    Key-value pairs to update



85
86
87
# File 'lib/google/adk/context.rb', line 85

def update_state(updates)
  state.merge!(updates)
end