MCPcopy Index your code
hub / github.com/docker/docker-agent / ApplyCompaction

Method ApplyCompaction

pkg/session/session.go:573–579  ·  view source on GitHub ↗

ApplyCompaction atomically resets the session's cumulative token counts and appends a summary item under s.mu so concurrent readers (e.g. the persistence observer's UpdateSession snapshot) cannot observe the new tokens without the matching summary item.

(inputTokens, outputTokens int64, item Item)

Source from the content-addressed store, hash-verified

571// (e.g. the persistence observer's UpdateSession snapshot) cannot
572// observe the new tokens without the matching summary item.
573func (s *Session) ApplyCompaction(inputTokens, outputTokens int64, item Item) {
574 s.mu.Lock()
575 defer s.mu.Unlock()
576 s.InputTokens = inputTokens
577 s.OutputTokens = outputTokens
578 s.Messages = append(s.Messages, item)
579}
580
581// AddSubSession adds a sub-session to the session
582func (s *Session) AddSubSession(subSession *Session) {

Callers 2

doCompactMethod · 0.80

Implementers 7

fakeSessionpkg/tools/lifecycle/supervisor_test.go
sessionClientpkg/tools/mcp/session_client.go
mockMCPClientpkg/tools/mcp/mcp_test.go
reconnectableMockClientpkg/tools/mcp/mcp_test.go
failingInitClientpkg/tools/mcp/reconnect_test.go
clientSessionpkg/tools/mcp/mcp.go
lspSessionpkg/tools/builtin/lsp/lsp_lifecycle.go

Calls 2

LockMethod · 0.45
UnlockMethod · 0.45

Tested by 1