Skip to content

fix: generate conversation titles with session model (cherry-pick #3898 to develop) - #3919

Merged
YehongPan merged 2 commits into
developfrom
fix/session-title-by-session-model
Sep 15, 2026
Merged

YehongPan merged 2 commits into
developfrom
fix/session-title-by-session-model

Conversation

@JasonW404

Copy link
Copy Markdown
Member

Summary

Cherry-pick of #3898 (merged into hotfix/v2.5.1) onto develop. The fix was never propagated to develop, so title generation on develop still ignores the session-selected model.

  • pass the send-time session model_id from the chat UI to conversation title generation
  • resolve and validate the selected tenant-scoped LLM for both regular and Northbound title APIs
  • preserve the existing tenant-default LLM fallback when model_id is omitted
  • log successful title generation as title_generation: <model> -> <title>

Behavior

Explicit model selections must exist in the current tenant, be active, and have type llm. Invalid, deleted, cross-tenant, or non-LLM selections return HTTP 422 without generating or persisting a title. The frontend snapshots the model ID used for the Agent run (modelIdForRun), so a later selector change cannot alter the title model.

Provenance

Verification

Port fidelity — the change set is byte-identical to #3898:

  • git range-diff reports the commit as equivalent; the only delta is the added (cherry picked from commit ...) trailer
  • Extracted added/removed payload lines from both patches: 269 vs 269, diff empty

Backend focused suites, baseline origin/develop vs this branch (all green, no regressions):

test file baseline branch Δ
test/backend/test_model_consts.py 79 81 +2
test/backend/app/test_conversation_management_app.py 29 30 +1
test/backend/app/test_northbound_app.py 105 106 +1
test/backend/services/test_conversation_management_service.py 93 98 +5
test/backend/services/test_northbound_service.py 114 114 0
total 420 429 +9

The +9 matches exactly the test cases added by #3898, and the new except ValidationError handlers are covered by test_generate_title_validation_error in both app test files.

Frontend:

  • node --test tests/conversationTitle.test.ts: 2 passed
  • tsc --noEmit: error set identical to baseline (234 pre-existing errors, all from unrelated components/ui/* and e2e/* files); zero errors in chatInterface.tsx, conversationTitle.ts, or conversationService.ts

Symbol resolution after auto-merge (guards against silent drift on develop):

  • ValidationError resolves to consts.exceptions.ValidationError in both apps/northbound_app.py and apps/conversation_management_app.py
  • Field resolves in consts/model.py; logger, Optional, and get_model_by_model_id all resolve in services/conversation_management_service.py

Runtime/E2E validation (ARM64 Docker build, Multipass Docker E2E, tenant-admin E2E, observed title_generation log) was performed in #3898 and is not repeated here; this is a faithful port of that already-reviewed change.

Notes

Pre-existing, unrelated to this PR: running the five backend test files together in a single pytest invocation fails collection with AttributeError: module 'consts.model' has no attribute 'ManageTenantModelCreateRequest'. This reproduces identically on clean origin/develop and is caused by test/conftest.py exposing both backend.consts.model and consts.model as distinct module objects. Running each file individually passes. Not addressed here.

@codecov

codecov Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@YehongPan
YehongPan merged commit f05e59a into develop Sep 15, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants