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

Method TotalCost

pkg/session/session.go:966–981  ·  view source on GitHub ↗

TotalCost computes the total cost of a session by walking all messages, sub-sessions, and summary items. It does not use the session-level Cost field, which exists only for backward-compatible persistence.

()

Source from the content-addressed store, hash-verified

964// sub-sessions, and summary items. It does not use the session-level Cost
965// field, which exists only for backward-compatible persistence.
966func (s *Session) TotalCost() float64 {
967 s.mu.RLock()
968 defer s.mu.RUnlock()
969
970 var cost float64
971 for _, item := range s.Messages {
972 switch {
973 case item.IsMessage():
974 cost += item.Message.Message.Cost
975 case item.IsSubSession():
976 cost += item.SubSession.TotalCost()
977 }
978 cost += item.Cost
979 }
980 return cost
981}
982
983// OwnCost returns only this session's direct cost: its own messages and
984// item-level costs (e.g. compaction). It excludes sub-session costs.

Callers 6

LoadFromSessionMethod · 0.80
gatherCostDataMethod · 0.80
sessionToDataFunction · 0.80
handleStreamFunction · 0.80
EmitStartupInfoMethod · 0.80
RunLLMFunction · 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

IsMessageMethod · 0.80
IsSubSessionMethod · 0.45

Tested by

no test coverage detected