ClaudeCode.Message.SystemMessage.CompactBoundary (ClaudeCode v0.36.3)

View Source

Represents a conversation compaction boundary message from the Claude CLI.

Compact boundary messages indicate that the CLI has compacted the conversation history to reduce token usage. This message provides metadata about the compaction.

Matches the official SDK schema:

{
  type: "system",
  subtype: "compact_boundary",
  uuid: string,
  session_id: string,
  compact_metadata: {
    trigger: "manual" | "auto",
    pre_tokens: number
  }
}

Summary

Functions

Type guard to check if a value is a CompactBoundary.

Creates a new CompactBoundary from JSON data.

Types

t()

@type t() :: %ClaudeCode.Message.SystemMessage.CompactBoundary{
  compact_metadata: %{trigger: String.t(), pre_tokens: non_neg_integer()},
  session_id: String.t(),
  subtype: :compact_boundary,
  type: :system,
  uuid: String.t()
}

Functions

compact_boundary?(arg1)

@spec compact_boundary?(any()) :: boolean()

Type guard to check if a value is a CompactBoundary.

new(json)

@spec new(map()) ::
  {:ok, t()} | {:error, :invalid_message_type | {:missing_fields, [atom()]}}

Creates a new CompactBoundary from JSON data.

Examples

iex> CompactBoundary.new(%{
...>   "type" => "system",
...>   "subtype" => "compact_boundary",
...>   "uuid" => "...",
...>   "session_id" => "...",
...>   "compact_metadata" => %{"trigger" => "auto", "pre_tokens" => 5000}
...> })
{:ok, %CompactBoundary{...}}

iex> CompactBoundary.new(%{"type" => "assistant"})
{:error, :invalid_message_type}