gopidesupavan commented on code in PR #68926:
URL: https://github.com/apache/airflow/pull/68926#discussion_r3542203944


##########
providers/common/ai/src/airflow/providers/common/ai/durable/task_state_store.py:
##########
@@ -0,0 +1,185 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""
+Task-state-store-backed durable storage for pydantic-ai agent step caching.
+
+Available on Airflow >= 3.3, where the AIP-103 task state store provides a
+per-task-instance key/value store that survives retries within a run and is
+cleared when the run is removed. Each cached step is written under its own key
+(``model_step_{N}`` / ``tool_step_{N}``, each prefixed with the reserved
+``DURABLE_KEY_PREFIX`` so it cannot collide with user keys in the shared
+key namespace); the store handles persistence and,
+when ``[workers] state_store_backend`` is configured, transparently offloads
+large values to external storage. No ``[common.ai] durable_cache_path`` is
+needed.
+
+This module is imported only on Airflow >= 3.3 (see
+``AgentOperator._build_durable_storage``); ``NEVER_EXPIRE`` does not exist on
+older airflow versions.
+"""
+
+from __future__ import annotations
+
+import json
+from typing import TYPE_CHECKING, Any
+
+import structlog
+from pydantic_ai.messages import ModelMessagesTypeAdapter
+
+from airflow.providers.common.ai.durable.base import TOOL_RESULT_SENTINEL
+from airflow.sdk.execution_time.context import NEVER_EXPIRE

Review Comment:
   this one is available on Airflow >= 3.3 ? can we gate this safely



-- 
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]

Reply via email to