gateway: images, videos and embeddings are listed on Routing (zzzkl3994)

zzzkl3994 on Discord: a video made through the magpie-image MCP was in
Usage → Requests but never on Routing → Requests. The MCP's requests do
go through the gateway, but `images`, `videosCreate` and `retrieve`
(embeddings, rerank, audio transcriptions) wrote their usage row and
began no route, so the routing trace never had them. Only the chat
path, the Codex backend, titles and System One began routes.

Each now begins one route (media_route.go, sideRoute) with the caller's
agent and session, the model as asked, the provider and the routing
group. Each key, account or group member asked is a try, put in Order
so the page finds its seat. The route ends with the status, error and
tokens, and the usage row names it in RouteID. Route.Usage is for
display and is not a second ledger row, so nothing is counted twice.
An image's accounts are tried in drawOnAccounts, which gets the route
through the request's context. A video's polls and its download are the
same generation; they add no route, as they add no usage row. A video
turned away before any vendor was asked ends its route as failed.
Route.Kind stays empty.

Run:
- New tests (media_route_test.go): TestImageIsOnRouting,
  TestFailedImageIsOnRouting, TestVideoIsOnRoutingOnce (create, three
  polls and the download give one route and one usage row),
  TestRefusedVideoIsOnRouting and TestEmbeddingAndRerankAreOnRouting.
  All are red at 5d24bc6cc without the fix ("Routing lists 0 routes")
  and green with it (wsl-run). Their neighbours pass too:
  TestVideoIsStartedPolledAndFetched, TestImageGroupMovesOnToTheNextMember,
  TestCallerUsageVideos and TestEmbeddingsGoToTheModelsProvider.
- Broken by hand. With RouteID dropped from the image's usage row, both
  image tests go red ("isn't the one the usage row names (0)"). With
  sideRoute.end always writing status 200, TestRefusedVideoIsOnRouting
  goes red.
- Full suite at 5d24bc6cc plus this change (wsl-run, `go test -tags
  nogui ./... -timeout 45m -count=1`): 77 packages ok. internal/agent
  has 4 reds (TestInstalledVersion, TestGrokInstalled,
  TestCopilotFolderFromAnIDEPluginIsNotTheCLI and
  TestOmpDetectedWithPiDir), all already filed for the WSL box at main
  in #4033.
- GOOS=windows and GOOS=linux `go vet ./internal/gateway` (mote): ok.
- Rebased on 4d9058a98, then on 95b40fb2f (redact and library only).
  internal/gateway and internal/imagemcp at the 4d9058a98
  head (mote-run) are still running when this is pushed.

Not tried:
- A real generate_video through the MCP in the GUI. The Routing page's
  GUI suite wasn't run, as no GUI file changed; the route has the shape
  the page already reads (Order, Tries, Kind "").
This commit is contained in:
yetone
2026-10-29 15:58:20 +08:00
parent 95b40fb2f1
commit 5f6a46630a
6 changed files with 362 additions and 8 deletions
File diff suppressed because one or more lines are too long
+15 -3
View File
@@ -553,9 +553,16 @@ func (s *Server) images(edit bool) http.HandlerFunc {
fail(maskStatus(err), err.Error())
return
}
noteMasked(r, "image", hits, d.Prompt, 0, p.ID, call.Model)
// the Routing page lists it as it does a chat, each account or
// member asked a try of its one route (sideRoute)
var grp *GroupRef
if isGroup {
grp = groupRef(g, ms)
}
side := s.beginSide(r, start, call.Model, p.ID, grp)
side.masked(noteMasked(r, "image", hits, d.Prompt, side.id(), p.ID, call.Model))
call.Provider, call.To = p.ID, provider.Chat
ctx, cancel := drawWithin(r.Context(), drawTimeout())
ctx, cancel := drawWithin(withSide(r.Context(), side), drawTimeout())
defer cancel()
// the account that drew, or refused last, is the one recorded
var (
@@ -588,7 +595,8 @@ func (s *Server) images(edit bool) http.HandlerFunc {
if p.Account == nil && p.Key != "" {
providerKeyID, providerKeyName = provider.KeyID(p.Key), p.KeyName
}
appendUsage(r, usage.Record{Operation: "generate_content", Time: start, Agent: call.Agent, Via: call.Via, Provider: p.ID, Host: p.Where(), Model: model, Requested: call.Model, ProviderKeyID: providerKeyID, ProviderKeyName: providerKeyName, ProviderAccount: accountOf(p),
side.end(p, model, call.Status, err, Usage{Input: out.Input, Output: out.Output})
appendUsage(r, usage.Record{RouteID: side.id(), Operation: "generate_content", Time: start, Agent: call.Agent, Via: call.Via, Provider: p.ID, Host: p.Where(), Model: model, Requested: call.Model, ProviderKeyID: providerKeyID, ProviderKeyName: providerKeyName, ProviderAccount: accountOf(p),
Input: out.Input, Output: out.Output, Millis: call.Millis, Status: call.Status, Session: sessionOf(r.Header)})
if err != nil {
call.Error = err.Error()
@@ -918,7 +926,9 @@ func viaFor(p provider.Provider, model string) drawVia {
func (s *Server) drawOnAccounts(ctx context.Context, r *http.Request, p provider.Provider, model string, d drawing) (provider.Provider, drawn, int, time.Time, error) {
if p.Account == nil && p.Key == "" {
// no key and no account (a local ollama): nothing to go over
tried := sideOf(ctx).try(candidateOf(p, model))
out, code, err := s.draw(ctx, p, model, d)
tried(code, err)
return p, out, code, time.Time{}, err
}
q := p
@@ -970,7 +980,9 @@ func (s *Server) drawOnAccounts(ctx context.Context, r *http.Request, p provider
var err error
for i, c := range cs {
p = c.p
tried := sideOf(ctx).try(c)
out, code, err = s.draw(ctx, p, model, d)
tried(code, err)
if err != nil && ctx.Err() == nil {
restDrawer(c, code, err.Error())
}
+19 -2
View File
@@ -4,6 +4,7 @@ import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
@@ -174,6 +175,13 @@ func (s *Server) serveRetrieval(w http.ResponseWriter, r *http.Request, path, op
tries = probeOne(tries) // of those resting, only the one back soonest (#1799)
var skipped []string
went := asked // the model the last try asked for
// the Routing page lists it as it does a chat, each account, key or
// member asked a try of its one route (sideRoute)
var grp *GroupRef
if isGroup {
grp = groupRef(g, ms)
}
side := s.beginSide(r, start, asked, tries[0].p.ID, grp)
// unless every try is on this machine or the local network, set
// to go unmasked (provider.SkipsRedaction)
if slices.ContainsFunc(tries, func(c candidate) bool { return !c.p.SkipsRedaction() }) {
@@ -185,6 +193,7 @@ func (s *Server) serveRetrieval(w http.ResponseWriter, r *http.Request, path, op
defer done()
if err != nil { // fails closed
call.Status, call.Error = maskStatus(err), err.Error()
side.end(tries[0].p, tries[0].model, call.Status, err, Usage{})
writeError(w, provider.Chat, call.Status, err.Error())
s.record(call)
return
@@ -195,27 +204,33 @@ func (s *Server) serveRetrieval(w http.ResponseWriter, r *http.Request, path, op
}
// the record names the try that had it last, not the first
// planned (noteMaskedUntil)
_, noted := noteMaskedUntil(r, what, hits, sent, 0, tries[0].p.ID, asked)
masked, noted := noteMaskedUntil(r, what, hits, sent, side.id(), tries[0].p.ID, asked)
side.masked(masked)
defer func() { noted(call.Provider, went) }()
}
for i, c := range tries {
last := i == len(tries)-1
call.Provider, went = c.p.ID, c.model
base := strings.TrimRight(c.p.Base(provider.Chat), "/")
tried := side.try(c)
if base == "" {
msg := fmt.Sprintf("%s has no OpenAI-style API for %s", c.p.Name, path)
tried(400, errors.New(msg))
if !last {
skipped = append(skipped, c.label()+": "+msg)
continue
}
call.Status, call.Error, call.Millis = 400, msg, time.Since(start).Milliseconds()
call.Fallback = strings.Join(skipped, "; ")
side.end(c.p, c.model, 400, errors.New(msg), Usage{})
writeError(w, provider.Chat, 400, msg)
s.record(call)
return
}
out, ctype, err := req.forModel(c.model)
if err != nil {
tried(400, err)
side.end(c.p, c.model, 400, err, Usage{})
call.Status, call.Error, call.Millis = 400, err.Error(), time.Since(start).Milliseconds()
writeError(w, provider.Chat, 400, err.Error())
s.record(call)
@@ -224,6 +239,7 @@ func (s *Server) serveRetrieval(w http.ResponseWriter, r *http.Request, path, op
ctx, cancel := context.WithTimeout(r.Context(), retrieveTimeout)
b, got, code, err := s.retrieveAs(ctx, c.p, base+path, ctype, out)
cancel()
tried(code, err)
call.Millis = time.Since(start).Milliseconds()
if err != nil && !last && r.Context().Err() == nil {
skipped = append(skipped, c.label()+": "+err.Error())
@@ -237,7 +253,8 @@ func (s *Server) serveRetrieval(w http.ResponseWriter, r *http.Request, path, op
if c.p.Account == nil && c.p.Key != "" {
providerKeyID, providerKeyName = provider.KeyID(c.p.Key), c.p.KeyName
}
appendUsage(r, usage.Record{Operation: operation, Time: start, Agent: call.Agent, Via: call.Via, Provider: c.p.ID, Host: c.p.Where(), Model: c.model, Requested: asked, ProviderKeyID: providerKeyID, ProviderKeyName: providerKeyName, ProviderAccount: accountOf(c.p),
side.end(c.p, c.model, code, err, Usage{Input: in, Output: outTokens})
appendUsage(r, usage.Record{RouteID: side.id(), Operation: operation, Time: start, Agent: call.Agent, Via: call.Via, Provider: c.p.ID, Host: c.p.Where(), Model: c.model, Requested: asked, ProviderKeyID: providerKeyID, ProviderKeyName: providerKeyName, ProviderAccount: accountOf(c.p),
Input: in, Output: outTokens, Millis: call.Millis, Status: code, Session: sessionOf(r.Header)})
if err != nil {
call.Error = err.Error()
+145
View File
@@ -0,0 +1,145 @@
package gateway
import (
"context"
"net/http"
"slices"
"strings"
"time"
"github.com/yetone/magpie/internal/provider"
)
// sideRoute is the Routing page's route of a request the chat path doesn't
// carry: an image, a video's start, an embedding, a rerank or a
// transcription. Each wrote its usage row but began no route, so Usage
// listed it and Routing never did (zzzkl3994 on Discord: a video the
// magpie-image MCP made). One route stands for one request, its tries the
// accounts, keys or group members asked in turn; a video's polls and its
// download are the same generation and add none, as they add no usage row.
// A nil sideRoute does nothing, so a caller with none goes on as before.
type sideRoute struct {
s *Server
tr *Route
start time.Time
}
// beginSide begins r's side route: asked is the model as the caller named
// it, prov the provider it resolved to first, group the routing group it
// named (nil for none).
func (s *Server) beginSide(r *http.Request, start time.Time, asked, prov string, group *GroupRef) *sideRoute {
who := callerOf(r)
tr := s.trace.beginFor(r, Route{Time: start, Agent: who.agent, Session: sessionOf(r.Header), Model: asked, Provider: prov,
Group: group, Order: []Weighed{}})
return &sideRoute{s: s, tr: tr, start: start}
}
// id is the route's id, which its usage row names (RouteID); 0 for none.
func (sr *sideRoute) id() int64 {
if sr == nil {
return 0
}
return sr.tr.ID
}
// masked puts what masking swapped in the request on the route.
func (sr *sideRoute) masked(m *Masked) {
if sr == nil || m == nil {
return
}
sr.s.trace.update(sr.tr, func(t *Route) { t.Masked = m })
}
// try begins a try on c, put in the route's order too when it isn't yet,
// as the page finds a try's seat there; the func it answers ends it.
func (sr *sideRoute) try(c candidate) func(status int, err error) {
return sr.tryAt(c, time.Now())
}
// tryAt is try for one begun at at, told once it is known who had it
// (a video's start picks its key inside startVideo).
func (sr *sideRoute) tryAt(c candidate, at time.Time) func(status int, err error) {
if sr == nil {
return func(int, error) {}
}
if c.rest == "" {
c.rest = candidateOf(c.p, c.model).rest
}
sr.s.trace.update(sr.tr, func(t *Route) {
t.Provider = c.p.ID
if !slices.ContainsFunc(t.Order, func(w Weighed) bool { return w.ID == c.rest && w.Model == c.model }) {
t.Order = append(t.Order, weighed(c, c.p, weighing{}, false, provider.Chat))
}
t.Tries = append(t.Tries, Try{ID: c.rest, Model: c.model, Start: at})
})
i := -1
sr.s.trace.update(sr.tr, func(t *Route) { i = len(t.Tries) - 1 })
return func(status int, err error) {
ms := time.Since(at).Milliseconds()
sr.s.trace.update(sr.tr, func(t *Route) {
if i < 0 || i >= len(t.Tries) {
return
}
try := &t.Tries[i]
try.Done, try.Status, try.Millis = true, status, ms
if err != nil {
try.Error = err.Error()
}
})
}
}
// end ends the route as the request ended: p and model the ones that had
// it last, u what they counted. A route ends once; a second end is a no-op.
func (sr *sideRoute) end(p provider.Provider, model string, status int, err error, u Usage) {
if sr == nil {
return
}
ms := time.Since(sr.start).Milliseconds()
sr.s.trace.update(sr.tr, func(t *Route) {
if t.Done {
return
}
if p.ID != "" {
t.Provider = p.ID
}
t.Done, t.Status, t.Millis, t.Tokens, t.Output = true, status, ms, u.Input+u.Output, u.Output
if err != nil {
t.Error = err.Error()
}
t.Usage = routeUsage(t.Provider, model, u)
})
}
// candidateOf is the candidate p, the key or account a request went out
// on, stands for, named as perKeyBarred names it in rest: the account
// signed in to by the provider's id, another by its user after an "@",
// one of several keys by its key after a "#", else the provider alone.
func candidateOf(p provider.Provider, model string) candidate {
c := candidate{p: p, model: model, rest: p.ID}
switch {
case p.Account != nil:
if own, err := provider.Find(p.ID); err == nil && own.Account != nil && !strings.EqualFold(own.Account.User, p.Account.User) {
c.rest = p.ID + "@" + p.Account.User
}
case p.Key != "" && len(p.KeysOn()) > 1:
c.rest = p.ID + "#" + provider.KeyID(p.Key)
}
return c
}
type sideRouteKey struct{}
// withSide carries sr to the code that asks each account (drawOnAccounts).
func withSide(ctx context.Context, sr *sideRoute) context.Context {
if sr == nil {
return ctx
}
return context.WithValue(ctx, sideRouteKey{}, sr)
}
// sideOf is the side route ctx carries, nil for none.
func sideOf(ctx context.Context) *sideRoute {
sr, _ := ctx.Value(sideRouteKey{}).(*sideRoute)
return sr
}
+167
View File
@@ -0,0 +1,167 @@
package gateway
import (
"context"
"encoding/json"
"net/http/httptest"
"strings"
"testing"
"time"
"github.com/yetone/magpie/internal/usage"
)
// usageRows waits for n usage rows of op, and answers those there are.
func usageRows(t *testing.T, op string, n int) []usage.Record {
t.Helper()
var got []usage.Record
for deadline := time.Now().Add(5 * time.Second); time.Now().Before(deadline); time.Sleep(10 * time.Millisecond) {
got = got[:0]
for _, r := range usage.Load(time.Time{}) {
if r.Operation == op {
got = append(got, r)
}
}
if len(got) >= n {
break
}
}
return got
}
// oneSideRoute is the one route s has, done, which the one usage row of op
// names: what Routing lists of a request Usage lists.
func oneSideRoute(t *testing.T, s *Server, op string) (Route, usage.Record) {
t.Helper()
rows := usageRows(t, op, 1)
if len(rows) != 1 {
t.Fatalf("%d usage rows of %s, want 1: %+v", len(rows), op, rows)
}
routes := s.Trace(context.Background(), 0, 0).Routes
if len(routes) != 1 {
t.Fatalf("Routing lists %d routes, want the request's one: %+v", len(routes), routes)
}
tr := routes[0]
if !tr.Done || tr.ID == 0 || tr.ID != rows[0].RouteID {
t.Fatalf("route %d (done %v) isn't the one the usage row names (%d)", tr.ID, tr.Done, rows[0].RouteID)
}
if tr.Kind != "" {
t.Fatalf("route kind %q: the page would call it an unrecognized purpose", tr.Kind)
}
if tr.Agent == "" || tr.Agent != rows[0].Agent || tr.Session != rows[0].Session || tr.Status != rows[0].Status {
t.Fatalf("route %+v doesn't say what its usage row does: %+v", tr, rows[0])
}
// each try has its seat in the order, as the page finds it
for _, try := range tr.Tries {
found := false
for _, w := range tr.Order {
found = found || w.ID == try.ID && w.Model == try.Model
}
if !found || !try.Done {
t.Fatalf("try %+v (seated %v) in order %+v", try, found, tr.Order)
}
}
return tr, rows[0]
}
// zzzkl3994 on Discord: a video the magpie-image MCP made was in Usage's
// requests and not on Routing's. Every request magpie sends is listed on
// Routing: an image, a video's start (once, however often it is polled
// and fetched) and an embedding, as a chat is, with its one usage row.
func TestImageIsOnRouting(t *testing.T) {
s, _ := easeled(t)
rec := httptest.NewRecorder()
req := httptest.NewRequest("POST", "/v1/images/generations", strings.NewReader(`{"model":"art/gpt-image-1","prompt":"a magpie"}`))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("User-Agent", "claude-code/2.1.0 "+DrawAgent)
req.Header.Set("X-Magpie-Session", "draw-session")
s.Handler().ServeHTTP(rec, req)
if rec.Code != 200 {
t.Fatalf("%d %s", rec.Code, rec.Body)
}
tr, row := oneSideRoute(t, s, "generate_content")
if tr.Provider != "art" || tr.Model != "art/gpt-image-1" || tr.Status != 200 || tr.Session != "draw-session" || tr.Error != "" {
t.Fatalf("route %+v", tr)
}
if len(tr.Tries) != 1 || tr.Tries[0].ID != "art" || tr.Tries[0].Model != "gpt-image-1" || tr.Tries[0].Status != 200 {
t.Fatalf("tries %+v", tr.Tries)
}
if tr.Tokens != row.Input+row.Output || len(tr.Usage) == 0 {
t.Fatalf("route tokens %d usage %+v, row %+v", tr.Tokens, tr.Usage, row)
}
}
func TestFailedImageIsOnRouting(t *testing.T) {
grokSignedIn(t)
newGrokMedia(t)
s := New()
code, _, raw := postImages(t, s, "/v1/images/generations", "application/json", `{"model":"grok/grok-imagine-image","prompt":"REFUSED"}`)
if code != 400 {
t.Fatalf("%d %s", code, raw)
}
tr, _ := oneSideRoute(t, s, "generate_content")
if tr.Provider != "grok" || tr.Status != 400 || !strings.Contains(tr.Error, "moderation") || len(tr.Tries) != 1 || tr.Tries[0].ID != "grok" || tr.Tries[0].Status != 400 {
t.Fatalf("route %+v", tr)
}
}
func TestVideoIsOnRoutingOnce(t *testing.T) {
grokSignedIn(t)
newGrokMedia(t)
s := New()
code, obj, raw, _ := request(t, s, "POST", "/v1/videos", "application/json", `{"model":"grok/grok-imagine-video","prompt":"a kite sways"}`)
if code != 200 {
t.Fatalf("%d %s", code, raw)
}
id, _ := obj["id"].(string)
// generate_video's polls and its download are the same video
for range 3 {
if code, _, raw, _ = request(t, s, "GET", "/v1/videos/"+id, "", ""); code != 200 {
t.Fatalf("poll %d %s", code, raw)
}
}
if code, _, raw, _ = request(t, s, "GET", "/v1/videos/"+id+"/content", "", ""); code != 200 {
t.Fatalf("content %d %s", code, raw)
}
tr, _ := oneSideRoute(t, s, "generate_content")
if tr.Provider != "grok" || tr.Model != "grok/grok-imagine-video" || tr.Status != 200 || len(tr.Tries) != 1 || tr.Tries[0].ID != "grok" || tr.Tries[0].Model != "grok-imagine-video" {
t.Fatalf("route %+v", tr)
}
}
func TestRefusedVideoIsOnRouting(t *testing.T) {
grokSignedIn(t)
newGrokMedia(t)
s := New()
code, _, raw, _ := request(t, s, "POST", "/v1/videos", "application/json", `{"model":"grok/grok-imagine-video","prompt":"TOOLONG"}`)
if code != 400 {
t.Fatalf("%d %s", code, raw)
}
tr, _ := oneSideRoute(t, s, "generate_content")
if tr.Status != 400 || !strings.Contains(tr.Error, "Duration") || len(tr.Tries) != 1 || tr.Tries[0].Status != 400 {
t.Fatalf("route %+v", tr)
}
}
func TestEmbeddingAndRerankAreOnRouting(t *testing.T) {
for _, tc := range []struct{ path, op, body, model string }{
{"/v1/embeddings", "embeddings", `{"model":"lib/embed-1","input":["hello"]}`, "embed-1"},
{"/v1/rerank", "rerank", `{"model":"lib/rerank-1","query":"q","documents":["a","b"]}`, "rerank-1"},
} {
t.Run(tc.op, func(t *testing.T) {
s, _ := shelved(t)
if code, raw := postRetrieval(t, s, tc.path, tc.body); code != 200 {
t.Fatalf("%d %s", code, raw)
}
tr, row := oneSideRoute(t, s, tc.op)
var asked struct{ Model string }
json.Unmarshal([]byte(tc.body), &asked)
if tr.Provider != "lib" || tr.Model != asked.Model || tr.Status != 200 || len(tr.Tries) != 1 || tr.Tries[0].ID != "lib" || tr.Tries[0].Model != tc.model {
t.Fatalf("route %+v", tr)
}
if tr.Tokens == 0 || tr.Tokens != row.Input+row.Output {
t.Fatalf("route tokens %d, row %+v", tr.Tokens, row)
}
})
}
}
+15 -2
View File
@@ -802,7 +802,16 @@ func (s *Server) videosCreate(w http.ResponseWriter, r *http.Request) {
sent += " " + string(b)
}
// the record names the member that had it last (noteMaskedUntil)
_, noted := noteMaskedUntil(r, "video", hits, sent, 0, cmp.Or(call.Provider, p.ID), call.Model)
// the Routing page lists it as it does a chat, each member asked a
// try of its one route (sideRoute); its polls and download are the
// same video, and add none
var grp *GroupRef
if isGroup {
grp = groupRef(g, ms)
}
side := s.beginSide(r, start, call.Model, p.ID, grp)
masked, noted := noteMaskedUntil(r, "video", hits, sent, side.id(), cmp.Or(call.Provider, p.ID), call.Model)
side.masked(masked)
defer func() { noted(call.Provider, model) }()
if n > 0 && f.Prompt == prompt { // the prompt's mask wraps w already
var done func()
@@ -818,8 +827,10 @@ func (s *Server) videosCreate(w http.ResponseWriter, r *http.Request) {
)
for i, m := range tries {
model = m.Model
at := time.Now()
v, code, err = s.startVideo(ctx, r, m.Provider, m.Model, f)
p, call.Provider = v.p, v.p.ID
side.tryAt(candidateOf(v.p, m.Model), at)(code, err)
// a group's next member is asked as a chat's would be: while this
// one can't make videos, its vendor fails, is out of quota or
// doesn't serve the model; a refusal of the request is the request's
@@ -835,6 +846,7 @@ func (s *Server) videosCreate(w http.ResponseWriter, r *http.Request) {
if len(skipped) > 0 {
msg += " (tried first: " + call.Fallback + ")"
}
side.end(p, model, code, errors.New(msg), Usage{})
fail(code, msg)
return
}
@@ -849,7 +861,8 @@ func (s *Server) videosCreate(w http.ResponseWriter, r *http.Request) {
call.Status = code
}
}
appendUsage(r, usage.Record{Operation: "generate_content", Time: start, Agent: call.Agent, Via: call.Via, Provider: p.ID, Host: p.Where(), Model: model, Requested: call.Model, ProviderAccount: accountOf(p),
side.end(p, model, call.Status, err, Usage{})
appendUsage(r, usage.Record{RouteID: side.id(), Operation: "generate_content", Time: start, Agent: call.Agent, Via: call.Via, Provider: p.ID, Host: p.Where(), Model: model, Requested: call.Model, ProviderAccount: accountOf(p),
Millis: call.Millis, Status: call.Status, Session: sessionOf(r.Header)})
if err != nil {
call.Error = err.Error()