When a model uses a server-side tool, the response transcript contains segments representing the activity. In the transcript, prose appears in text segments, while tool calls appear as empty segments holding the call's place.
To detect and render these activities (like web searches) inline, use entry.claudeServerToolActivity(for: segment). A call appears as soon as the model issues it, and its outcome is filled in when the result arrives in the same response.
To access all round-trips in a conversation, use session.transcript.claudeServerToolActivities.
for case .response(let entry) in session.transcript {
for segment in entry.segments {
if let activity = entry.claudeServerToolActivity(for: segment) {
if case .webSearch(let search) = activity.content { print("Searched for \(search.query)") }
} else if case .text(let text) = segment {
print(text.content)
}
}
}