-
Notifications
You must be signed in to change notification settings - Fork 265
Expand file tree
/
Copy pathChatExecutionContext.swift
More file actions
35 lines (29 loc) · 1.48 KB
/
ChatExecutionContext.swift
File metadata and controls
35 lines (29 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//
// ChatExecutionContext.swift
// osaurus
//
// TaskLocal context populated by the chat engine before dispatching every
// tool call so per-session state (the agent todo, file-operation undo
// log, method telemetry, etc.) can be addressed by the active session.
//
import Foundation
/// TaskLocal storage carrying the active chat session / agent / batch ids
/// down through tool execution. The chat engine seeds these in
/// `ChatSession.send` (and equivalent headless paths) so any tool reading
/// them picks up the right scope without an explicit parameter.
public enum ChatExecutionContext {
/// The current chat session id whose tool calls are running. Tools that
/// need per-conversation state (todo store, file-op undo log, method
/// telemetry) key off this.
@TaskLocal public static var currentSessionId: String?
/// The current batch ID for grouped operations (nil for non-batch operations).
@TaskLocal public static var currentBatchId: UUID?
/// The agent ID whose context is active for the current execution.
@TaskLocal public static var currentAgentId: UUID?
/// Assistant turn dispatching the current tool call. Used by `speak`
/// to bind TTS playback to the right message bubble
@TaskLocal public static var currentAssistantTurnId: UUID?
/// Specific tool invocation id. Used by `speak` so the inline card
/// can swap its check for a spinner while its audio plays
@TaskLocal public static var currentToolCallId: String?
}