MCPcopy Create free account
hub / github.com/coder/aibridge / RecordToolUsage

Method RecordToolUsage

example/recorder.go:130–152  ·  view source on GitHub ↗
(ctx context.Context, req *aibridge.ToolUsageRecord)

Source from the content-addressed store, hash-verified

128}
129
130func (r *SQLiteRecorder) RecordToolUsage(ctx context.Context, req *aibridge.ToolUsageRecord) error {
131 metadata, _ := json.Marshal(req.Metadata)
132 input, _ := json.Marshal(req.Args)
133
134 var serverURL *string
135 if req.ServerURL != nil {
136 serverURL = req.ServerURL
137 }
138
139 var invocationError *string
140 if req.InvocationError != nil {
141 errStr := req.InvocationError.Error()
142 invocationError = &errStr
143 }
144
145 _, err := r.stmtInsertToolUsage.ExecContext(ctx,
146 uuid.NewString(), req.InterceptionID, req.MsgID, serverURL, req.Tool, string(input), req.Injected, invocationError, string(metadata), req.CreatedAt,
147 )
148 if err != nil {
149 r.logger.Warn(ctx, "failed to record tool usage", slog.Error(err))
150 }
151 return err
152}

Callers

nothing calls this directly

Calls 1

ErrorMethod · 0.45

Tested by

no test coverage detected