feat(statestore): record a usage row for every model call

Task agent runs and MCP sampling record against their task (billed to the
task's org); gateway chat turns, titles, sampling and curators record
against the system org. Rows carry source, workflow, step, alias,
provider/model and tokens for later chargeback.
This commit is contained in:
sam committed 2026-10-10 18:32:43 +11:00
1 parent 12b9a57404
commit e4ea2eaabc
31 files changed
+1068 -322

No files matched your search

+1 -1
View File
@@ -233,7 +233,7 @@ func runTask(ctx context.Context, req taskrun.Request, dependencies taskDependen
if len(req.MCPServers) > 0 {
llm = modelloop.NewRuntime(req.Providers, req.Cfg.ModelLimits)
}
mcpSet, mcpErr := startMCPProviders(ctx, req.MCPServers, taskSamplingHandler(llm, req.Cfg), log)
mcpSet, mcpErr := startMCPProviders(ctx, req.MCPServers, taskSamplingHandler(llm, req.Cfg, samplingUsageRecorder(dependencies.store, req.Task, log)), log)
if mcpSet != nil {
defer mcpSet.cleanup(ctx, log)
}