Class: Agent::SessionContext::Renderers::JSON

Inherits:
Object
  • Object
show all
Defined in:
lib/agent/session_context/renderers/json.rb

Instance Method Summary collapse

Instance Method Details

#call(value) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/agent/session_context/renderers/json.rb', line 7

def call(value)
  # A Loop must never reach Serializer.serialize directly: Serializer
  # walks any Data object generically by its members, and Loop holds
  # round_trips -> Message#raw, the full on-disk record with every
  # prompt and tool-result body. LoopView#to_h is the Hash that
  # already strips bodies down to sizes and tool names — serialize
  # THAT, never the Loop itself.
  return ::JSON.generate(Serializer.serialize(LoopView.new(value).to_h)) if value.is_a?(Loop)

  ::JSON.generate(Serializer.serialize(value))
end