RawMessageRecord#
Restore model context and preserve immutable original messages. See the guide.
- class zett_agent.extensions.persistence.RawMessageRecord(id, session_id, request_id, sequence, message, metadata, tags, started_at, completed_at, duration_ns, reasoning_started_at, reasoning_completed_at, reasoning_duration_ns, content_started_at, content_completed_at, content_duration_ns, input_tokens, output_tokens, cache_read_tokens, cache_write_tokens, reasoning_tokens, created_at, updated_at)[源代码]#
One immutable original message returned by session storage.
- 参数:
id (str)
session_id (str)
request_id (str)
sequence (int)
message (AnyMessage)
metadata (dict[str, JsonValue])
tags (dict[str, JsonValue])
started_at (datetime)
completed_at (datetime)
duration_ns (int)
reasoning_started_at (datetime | None)
reasoning_completed_at (datetime | None)
reasoning_duration_ns (int | None)
content_started_at (datetime | None)
content_completed_at (datetime | None)
content_duration_ns (int | None)
input_tokens (int | None)
output_tokens (int | None)
cache_read_tokens (int | None)
cache_write_tokens (int | None)
reasoning_tokens (int | None)
created_at (datetime)
updated_at (datetime)
- metadata: dict[str, JsonValue]#
Request-scoped application data captured independently of model messages.
- tags: dict[str, JsonValue]#
Request-scoped classifications captured independently of model messages.
- started_at: datetime#
UTC operation start; GENERATING for assistants, RUNNING_TOOL for tools, and append time for user-authored or directly imported messages.
- completed_at: datetime#
UTC operation completion; equal to started_at for instantaneous messages.
- duration_ns: int#
Total operation duration in nanoseconds, measured by a monotonic clock.
- reasoning_started_at: datetime | None#
UTC arrival time of the first streamed reasoning delta, when present.
- reasoning_completed_at: datetime | None#
UTC boundary where reasoning ended before content, tools, or completion.
- reasoning_duration_ns: int | None#
Monotonic elapsed reasoning time in nanoseconds; None if not observed.
- content_started_at: datetime | None#
UTC arrival time of the first streamed answer-content delta, when present.
- content_completed_at: datetime | None#
UTC final-response boundary for a streamed answer-content segment.
- content_duration_ns: int | None#
Monotonic elapsed content-streaming time in nanoseconds; None if absent.
- input_tokens: int | None#
Provider-reported prompt tokens for an assistant model response.
- output_tokens: int | None#
Provider-reported completion tokens, including reasoning when applicable.
- cache_read_tokens: int | None#
Input tokens served from a provider cache.
- cache_write_tokens: int | None#
Input tokens written into a provider cache when separately reported.
- reasoning_tokens: int | None#
Reasoning tokens included within output_tokens when separately reported.
- property total_tokens: int | None#
Return input plus output tokens when provider usage was recorded.
- property cache_hit_rate: float | None#
Return a zero-to-one input cache ratio, or None without input usage.