Class: Agent::Sessions::Readers::Qwen
- Defined in:
- lib/agent/sessions/readers/qwen.rb
Overview
Qwen Code chat files. PROVISIONAL, like the adapter: written against tokentelemetry's parser of this format, not against real Qwen output.
The record shape is Anthropic's — type user/assistant, message.content as an array of typed parts, message.usage with the same five spellings Claude uses. This is deliberately NOT a subclass of Readers::Claude despite that overlap: Claude's reader also carries Claude Code's sidecar machinery (spilled tool output, subagent transcripts, uuid/parentUuid branching), none of which is known to exist here, and inheriting would mean disabling each one and then re-checking every future Claude change against an agent nobody can test. Two readers with two evidence bases will drift honestly; one reader pretending to serve both will drift silently.
Constant Summary collapse
- CONTENT_PARTS =
{ "text" => :text, "thinking" => :thinking, "tool_use" => :tool_use, "tool_result" => :tool_result, "image" => :image }.freeze
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#usage ⇒ Object
Session totals, deduplicated by message.id the way Claude's are: the same API response can stream into one record per content block, and both agents speak the same wire format.
Methods inherited from Base
#branching?, #compactions, #each_message, #fidelity, #initialize, #messages, #partial?, #tree, #warnings
Constructor Details
This class inherits a constructor from Agent::Sessions::Readers::Base
Instance Method Details
#usage ⇒ Object
Session totals, deduplicated by message.id the way Claude's are: the same API response can stream into one record per content block, and both agents speak the same wire format. Unverified for Qwen — if its writer does not repeat ids, this dedup is simply a no-op.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/agent/sessions/readers/qwen.rb', line 27 def usage seen = {} total = nil each_record do |record, _line_number| usage = usage_from(record) next unless usage id = record.dig("message", "id") next if id && seen[id] seen[id] = true if id total = total ? total + usage : usage end total end |