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

Method OwnCost

pkg/session/session.go:987–999  ·  view source on GitHub ↗

OwnCost returns only this session's direct cost: its own messages and item-level costs (e.g. compaction). It excludes sub-session costs. This is used for live event emissions where sub-sessions report their own costs separately.

()

Source from the content-addressed store, hash-verified

985// This is used for live event emissions where sub-sessions report their
986// own costs separately.
987func (s *Session) OwnCost() float64 {
988 s.mu.RLock()
989 defer s.mu.RUnlock()
990
991 var cost float64
992 for _, item := range s.Messages {
993 if item.IsMessage() {
994 cost += item.Message.Message.Cost
995 }
996 cost += item.Cost
997 }
998 return cost
999}
1000
1001// now returns the session's current time, falling back to time.Now for
1002// sessions created without a clock (e.g. JSON deserialization).

Callers 2

SessionUsageFunction · 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 1

IsMessageMethod · 0.80