MCPcopy Create free account
hub / github.com/coder/coder / TestRecordToolUsage

Function TestRecordToolUsage

aibridge/intercept/responses/base_internal_test.go:86–226  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

84}
85
86func TestRecordToolUsage(t *testing.T) {
87 t.Parallel()
88
89 id := uuid.MustParse("11111111-1111-1111-1111-111111111111")
90
91 tests := []struct {
92 name string
93 response *oairesponses.Response
94 expected []*recorder.ToolUsageRecord
95 }{
96 {
97 name: "nil_response",
98 response: nil,
99 expected: nil,
100 },
101 {
102 name: "empty_output",
103 response: &oairesponses.Response{
104 ID: "resp_123",
105 },
106 expected: nil,
107 },
108 {
109 name: "empty_tool_args",
110 response: &oairesponses.Response{
111 ID: "resp_456",
112 Output: []oairesponses.ResponseOutputItemUnion{
113 {
114 Type: "function_call",
115 CallID: "call_abc",
116 Name: "get_weather",
117 Arguments: "",
118 },
119 },
120 },
121 expected: []*recorder.ToolUsageRecord{
122 {
123 InterceptionID: id.String(),
124 MsgID: "resp_456",
125 ToolCallID: "call_abc",
126 Tool: "get_weather",
127 Args: "",
128 Injected: false,
129 },
130 },
131 },
132 {
133 name: "multiple_tool_calls",
134 response: &oairesponses.Response{
135 ID: "resp_789",
136 Output: []oairesponses.ResponseOutputItemUnion{
137 {
138 Type: "function_call",
139 CallID: "call_1",
140 Name: "get_weather",
141 Arguments: `{"location": "NYC"}`,
142 },
143 {

Callers

nothing calls this directly

Calls 7

RecordedToolUsagesMethod · 0.95
RunMethod · 0.65
ContextMethod · 0.65
StringMethod · 0.45
LenMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected