---
title: "onDeactivate(perform:)"
framework: foundationmodels
role: symbol
role_heading: Instance Method
path: "foundationmodels/languagemodelsession/dynamicprofile/ondeactivate(perform:)"
---

# onDeactivate(perform:)

Runs an action when this dynamic profile becomes inactive.

## Declaration

```swift
func onDeactivate(perform action: sending @escaping @isolated(any) () async -> Void) -> some LanguageModelSession.DynamicProfile

```

## Mentioned in

Composing dynamic sessions with instructions and profiles

## Discussion

Discussion A profile becomes inactive when it is no longer included in the session’s resolved configuration after previously being active. Use this to tear down state tied to the profile’s lifecycle: struct MyDynamicProfile: LanguageModelSession.DynamicProfile {   var body: some LanguageModelSession.DynamicProfile {     Profile {       Instructions("You are a helpful assistant.")     }     .onDeactivate {       activeProfile = nil     }   } }

## See Also

### Observing life cycle modifiers

- [onActivate(perform:)](foundationmodels/languagemodelsession/dynamicprofile/onactivate(perform:).md)
- [onPrompt(perform:)](foundationmodels/languagemodelsession/dynamicprofile/onprompt(perform:).md)
- [onResponse(perform:)](foundationmodels/languagemodelsession/dynamicprofile/onresponse(perform:).md)
- [onToolCall(perform:)](foundationmodels/languagemodelsession/dynamicprofile/ontoolcall(perform:).md)
- [onToolOutput(perform:)](foundationmodels/languagemodelsession/dynamicprofile/ontooloutput(perform:).md)
