<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "FoundationModels",
  "identifier" : "/documentation/FoundationModels/SessionPropertyValues",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Foundation Models"
    ],
    "preciseIdentifier" : "s:16FoundationModels21SessionPropertyValuesC"
  },
  "title" : "SessionPropertyValues"
}
-->

# SessionPropertyValues

A container for property values.

```
final class SessionPropertyValues
```

## Overview

Use session property values across your session. To help manage the context window, access
[`history`](/documentation/FoundationModels/SessionPropertyValues/history) to modify the transcript for the session:

```swift
struct CompactingProfile: LanguageModelSession.DynamicProfile {
    @SessionProperty(\.history)
    var history

    var body: some LanguageModelSession.DynamicProfile {
        Profile {
            // Custom instructions and tools that you define.
        }
        .onResponse { _ in
            // Compact the history when the entries exceed a certain limit.
            if history.count > 100 {
                history = Array(history.suffix(50))
            }
        }
    }
}
```

Because updating the transcript history can cause cache invalidations for some
models, carefully consider how you modify an existing transcript. For more
information, see [Optimizing key-value caching in language model sessions](/documentation/FoundationModels/optimizing-key-value-caching-in-language-model-sessions).

Use [`SessionPropertyEntry()`](/documentation/FoundationModels/SessionPropertyEntry()) to create custom session properties.

## Topics

### Accessing the session history and instructions

[`var history: Transcript.HistoryView`](/documentation/FoundationModels/SessionPropertyValues/history)

The history portion of the session’s transcript.

### Accessing the subscript

[`subscript<K>(K.Type) -> K.Value`](/documentation/FoundationModels/SessionPropertyValues/subscript(_:))

Accesses the value stored for the given session property key.

## Relationships

### Conforms To

[`Copyable`](/documentation/Swift/Copyable)

[`Escapable`](/documentation/Swift/Escapable)

[`Observable`](/documentation/Observation/Observable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Sendable`](/documentation/Swift/Sendable)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)