@@ -91,6 +91,7 @@ def _get_bundle_url() -> str:
9191 if AIRFLOW_V_3_4_PLUS :
9292 from airflow .api_fastapi .core_api .services .public .task_coordinates import resolve_task_scope
9393 from airflow .models .dagbag import DBDagBag
94+ from airflow .models .task_coordinates import TaskCoordinateResolver
9495
9596 def _get_session ():
9697 with create_session (scoped = False ) as session :
@@ -105,11 +106,11 @@ def _read_xcom(
105106 run_id : str ,
106107 task_id : str ,
107108 map_index : int = - 1 ,
108- region_id : UUID | None = None ,
109+ region_id : UUID | None ,
109110 key : str ,
110111 ):
111112 """Read a single XCom value from the database."""
112- scope = {"region_id" : region_id } if AIRFLOW_V_3_4_PLUS else {}
113+ scope = {"region_id" : region_id , "include_node_regions" : False } if AIRFLOW_V_3_4_PLUS else {}
113114 read = XComModel .get_many (
114115 run_id = run_id ,
115116 key = key ,
@@ -131,7 +132,7 @@ def _read_xcom_by_prefix(
131132 run_id : str ,
132133 task_id : str ,
133134 map_index : int = - 1 ,
134- region_id : UUID | None = None ,
135+ region_id : UUID | None ,
135136 prefix : str ,
136137 ) -> dict [int , Any ]:
137138 """Read all iteration-keyed XCom entries matching *prefix* (e.g. ``airflow_hitl_review_agent_output_``)."""
@@ -142,6 +143,7 @@ def _read_xcom_by_prefix(
142143 task_ids = task_id ,
143144 map_indexes = map_index ,
144145 region_id = region_id ,
146+ include_node_regions = False ,
145147 )
146148 entity = read .column_descriptions [0 ]["entity" ]
147149 query = read .with_only_columns (entity .key , entity .value ).where (entity .key .like (f"{ prefix } %" ))
@@ -167,7 +169,7 @@ def _write_xcom(
167169 run_id : str ,
168170 task_id : str ,
169171 map_index : int = - 1 ,
170- region_id : UUID | None = None ,
172+ region_id : UUID | None ,
171173 key : str ,
172174 value ,
173175 ):
@@ -180,7 +182,7 @@ def _write_xcom(
180182 TI .run_id == run_id ,
181183 TI .task_id == task_id ,
182184 TI .region_index == map_index ,
183- TI .region_id == ( region_id or UUID ( int = 0 )) ,
185+ TI .region_id == region_id ,
184186 )
185187 )
186188 if owner is None :
@@ -237,7 +239,7 @@ def _is_task_completed(
237239 run_id : str ,
238240 task_id : str ,
239241 map_index : int = - 1 ,
240- region_id : UUID | None = None ,
242+ region_id : UUID | None ,
241243 ) -> bool :
242244 """Return True if the task instance is no longer running."""
243245 query = select (TI .state ).where (
@@ -249,7 +251,7 @@ def _is_task_completed(
249251 query = query .where (
250252 TI .working_set .is_ (True ),
251253 TI .region_index == map_index ,
252- TI .region_id == ( region_id or UUID ( int = 0 )) ,
254+ TI .region_id == region_id ,
253255 )
254256 else :
255257 query = query .where (TI .map_index == map_index )
@@ -265,7 +267,7 @@ def _build_session_response(
265267 run_id : str ,
266268 task_id : str ,
267269 map_index : int = - 1 ,
268- region_id : UUID | None = None ,
270+ region_id : UUID | None ,
269271 ) -> HITLReviewResponse | None :
270272 """Build `HITLReviewResponse` from XCom entries."""
271273 raw = _read_xcom (
@@ -339,8 +341,7 @@ def _get_task_scope(
339341 dag_id = dag_id ,
340342 run_id = run_id ,
341343 task_id = task_id ,
342- session = db ,
343- dag_bag = DBDagBag (),
344+ resolver = TaskCoordinateResolver (DBDagBag (), db ),
344345 map_index = map_index ,
345346 region_id = region_id ,
346347 region_index = region_index ,
0 commit comments