Skip to content

Commit 0675fff

Browse files
committed
Persist session state before break and update E2E test
Add update_session_state call before break in both while loops when a composite returns a question directly, ensuring session position is persisted to DB before exiting. Without this, the next user reply could resolve against the wrong node/flow. Update E2E test script to walk through composite sub-flows (recommendation, jokes, spelling) and add Test 5 for the stale collection → composite chaining path.
1 parent 54f0cb8 commit 0675fff

File tree

2 files changed

+632
-0
lines changed

2 files changed

+632
-0
lines changed

app/services/chat_runtime.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,6 +1381,15 @@ async def process_interaction(
13811381
auto_result
13821382
)
13831383
chained_next_node = None
1384+
# Persist session position before exiting loop
1385+
session = await chat_repo.update_session_state(
1386+
db,
1387+
session_id=session.id,
1388+
state_updates={},
1389+
current_node_id=session_position,
1390+
current_flow_id=session_flow_id,
1391+
expected_revision=session.revision,
1392+
)
13841393
break
13851394

13861395
# Update position and continue
@@ -1582,6 +1591,15 @@ async def process_interaction(
15821591
auto_result
15831592
)
15841593
chained_next = None
1594+
# Persist session position before exiting loop
1595+
session = await chat_repo.update_session_state(
1596+
db,
1597+
session_id=session.id,
1598+
state_updates={},
1599+
current_node_id=session_position,
1600+
current_flow_id=session_flow_id,
1601+
expected_revision=session.revision,
1602+
)
15851603
break
15861604

15871605
session_position = chained_next.node_id

0 commit comments

Comments
 (0)