From 9a4e4336ad4d32912d8f6d1c97272a309838bd61 Mon Sep 17 00:00:00 2001 From: Rodrigo Gomes da Silva Date: Fri, 14 Aug 2026 19:30:56 -0300 Subject: [PATCH] fix(sessions): keep the lineage project id when the root is the freshest segment compression_tip() resolves a project assignment across the whole lineage, so it can find one recorded on a newer EMPTY continuation. When the root is still the freshest *importable* segment, the `tip is row` early return appended the root without applying that resolved id and the assignment was silently dropped. Copy the root and apply lineage_project_id before appending, matching what the merged-tip path below already does. --- api/agent_sessions.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/api/agent_sessions.py b/api/agent_sessions.py index 85548b39..66eb47c1 100644 --- a/api/agent_sessions.py +++ b/api/agent_sessions.py @@ -614,7 +614,14 @@ def _project_agent_session_rows(rows: list[dict]) -> list[dict]: continue if tip is row: - projected.append(dict(row)) + # The root can still be the freshest *importable* segment while a + # newer EMPTY continuation carries the project assignment. Applying + # the resolved lineage id here too keeps that assignment instead of + # silently dropping it on the early-return path (#6659). + root_only = dict(row) + if lineage_project_id: + root_only['project_id'] = lineage_project_id + projected.append(root_only) continue merged = dict(row)