MCPcopy Create free account
hub / github.com/codehamr/codehamr / TestMessageTokensCountsToolCallArguments

Function TestMessageTokensCountsToolCallArguments

internal/ctx/ctx_test.go:45–54  ·  view source on GitHub ↗

TestMessageTokensCountsToolCallArguments pins ToolCall.Arguments accounting in Message.Tokens: it feeds the budget on every tool-using turn, yet no other test populates Arguments. Asserts the delta so the +8 per-message overhead can't mask a dropped Arguments loop.

(t *testing.T)

Source from the content-addressed store, hash-verified

43// in Message.Tokens: it feeds the budget on every tool-using turn, yet no
44// other test populates Arguments. Asserts the delta so the +8 per-message
45// overhead can't mask a dropped Arguments loop.
46func TestMessageTokensCountsToolCallArguments(t *testing.T) {
47 base := Message{Role: RoleAssistant, ToolCalls: []ToolCall{{Name: "bash"}}}.Tokens()
48 withArgs := Message{Role: RoleAssistant, ToolCalls: []ToolCall{
49 {Name: "bash", Arguments: map[string]any{"cmd": "echo hello world"}},
50 }}.Tokens()
51 // args add Tokens("cmd")=1 + Tokens(fmt.Sprint("echo hello world"))=4 = 5.
52 if got := withArgs - base; got != 5 {
53 t.Fatalf("argument cost = %d, want 5 (Message.Tokens must account for ToolCall.Arguments)", got)
54 }
55}
56
57// TestMessageTokensCountsReasoning: replayed reasoning items ride on every

Callers

nothing calls this directly

Calls 1

TokensMethod · 0.80

Tested by

no test coverage detected