( ctx context.Context, chat database.Chat, debugSvc *chatdebug.Service, candidate shortTextCandidate, modelOpts modelBuildOptions, kind chatdebug.RunKind, triggerMessageID int64, historyTipMessageID int64, seedSummary map[string]any, logger slog.Logger, )
| 337 | } |
| 338 | |
| 339 | func (p *Server) prepareQuickgenDebugCandidate( |
| 340 | ctx context.Context, |
| 341 | chat database.Chat, |
| 342 | debugSvc *chatdebug.Service, |
| 343 | candidate shortTextCandidate, |
| 344 | modelOpts modelBuildOptions, |
| 345 | kind chatdebug.RunKind, |
| 346 | triggerMessageID int64, |
| 347 | historyTipMessageID int64, |
| 348 | seedSummary map[string]any, |
| 349 | logger slog.Logger, |
| 350 | ) (context.Context, fantasy.LanguageModel, func(error)) { |
| 351 | finishDebugRun := func(error) {} |
| 352 | if debugSvc == nil { |
| 353 | return ctx, candidate.lm, finishDebugRun |
| 354 | } |
| 355 | |
| 356 | debugModel, err := p.newQuickgenDebugModel( |
| 357 | ctx, |
| 358 | chat, |
| 359 | debugSvc, |
| 360 | candidate.provider, |
| 361 | candidate.model, |
| 362 | candidate.route, |
| 363 | modelOpts, |
| 364 | ) |
| 365 | if err != nil { |
| 366 | logger.Warn(ctx, "failed to build short-text debug model", |
| 367 | slog.F("chat_id", chat.ID), |
| 368 | slog.F("run_kind", kind), |
| 369 | slog.F("provider", candidate.provider), |
| 370 | slog.F("model", candidate.model), |
| 371 | slog.Error(err), |
| 372 | ) |
| 373 | return ctx, candidate.lm, finishDebugRun |
| 374 | } |
| 375 | |
| 376 | // Debug instrumentation must not eat into the quickgen budget |
| 377 | // (30s titleCtx / summaryCtx on the caller). Detach and bound |
| 378 | // the insert so a slow DB can't delay title generation or push |
| 379 | // summaries, matching prepareManualTitleDebugRun, |
| 380 | // prepareChatTurnDebugRun, and startCompactionDebugRun. |
| 381 | createRunCtx, createRunCancel := context.WithTimeout( |
| 382 | context.WithoutCancel(ctx), debugCreateRunTimeout, |
| 383 | ) |
| 384 | run, err := debugSvc.CreateRun(createRunCtx, chatdebug.CreateRunParams{ |
| 385 | ChatID: chat.ID, |
| 386 | TriggerMessageID: triggerMessageID, |
| 387 | HistoryTipMessageID: historyTipMessageID, |
| 388 | Kind: kind, |
| 389 | Status: chatdebug.StatusInProgress, |
| 390 | Provider: candidate.provider, |
| 391 | Model: candidate.model, |
| 392 | Summary: seedSummary, |
| 393 | }) |
| 394 | createRunCancel() |
| 395 | if err != nil { |
| 396 | logger.Warn(ctx, "failed to create short-text debug run", |
no test coverage detected