kaxil commented on code in PR #76201:
URL: https://github.com/apache/airflow/pull/76201#discussion_r4437526715
##########
providers/common/ai/src/airflow/providers/common/ai/durable/strands.py:
##########
@@ -132,15 +132,9 @@ def research(question: str) -> str:
)
storage = TaskStateStoreStorage(context["task_state_store"])
if session_id is None:
- ti = context["ti"]
# A hash: short (task state store keys are at most 512 characters) and
free of the
# characters Strands refuses in a session id, whatever the Dag, run
and task ids hold.
- session_id = compute_identity_key(
- dag_id=ti.dag_id,
- task_id=ti.task_id,
- run_id=ti.run_id,
- map_index=ti.map_index if ti.map_index is not None else -1,
- )
+ session_id = compute_identity_key_for_context(context)
Review Comment:
The `session_id` docs above (line 113) and in `strands.rst` still describe
the default as Dag id, run id, task id and map index. The advice for a custom
`session_id` with shared storage only says to vary it across Dag runs, so
someone following it inside a task loop gets the same collision this PR fixes
for the default. Can you add the loop iteration there (for example
`context["loop"].region_id` and `.index`), and the same to the "Retries
re-attach" section of `llm_batch.rst`, which also lists only the Dag, task, run
and map index?
##########
providers/common/ai/src/airflow/providers/common/ai/batch/state.py:
##########
@@ -65,11 +74,33 @@ def compute_identity_key(*, dag_id: str, task_id: str,
run_id: str, map_index: i
let one task instance read or overwrite another's batch state. Mirrors
``durable/storage.py``'s ``DurableStorage`` identity hash verbatim, for
Review Comment:
This now only mirrors `DurableStorage`'s hash outside a loop, since
`DurableStorage` still joins the four fields. Could you reword it to say that,
and note that `DurableStorage` doesn't need the loop fields because task loops
need Airflow 3.4, where the journal uses the task state store?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]