Lee-W commented on code in PR #76864:
URL: https://github.com/apache/airflow/pull/76864#discussion_r4534549616


##########
providers/common/ai/src/airflow/providers/common/ai/durable/capability.py:
##########
@@ -99,8 +101,33 @@
 # types have changed since, so replaying it would fail on every retry.
 _UNLOADABLE = "the recorded result no longer loads, so it was written by 
another version"
 
-_NO_CONFIG: RoleBasedOperationConfig[None] = RoleBasedOperationConfig(
-    model=None, event=None, capability=None, tool=None
+# How an operation's step is run: looked up in the journal and recorded, or 
always run live.
+_StepMode: TypeAlias = Literal["journal", "live"]
+
+
+def _journals_tool(tool_def: ToolDefinition) -> bool:
+    """Whether calls of a tool are journaled; ``metadata={"airflow": False}`` 
runs them live on every attempt."""
+    setting = (tool_def.metadata or {}).get(TOOL_CONFIG_KEY)
+    if setting is None:
+        return True
+    if isinstance(setting, bool):
+        return setting
+    raise UserError(
+        f"Tool {tool_def.name!r} has invalid {TOOL_CONFIG_KEY!r} metadata: 
expected True or False, "
+        f"got {type(setting).__name__}."
+    )
+
+
+def _tool_step_mode(operation_id: DurableOperationId, tool: object | None, 
tool_name: str) -> _StepMode:

Review Comment:
   ```suggestion
   def _resolve_tool_step_mode(operation_id: DurableOperationId, tool: object | 
None, tool_name: str) -> _StepMode:
   ```



##########
providers/common/ai/src/airflow/providers/common/ai/durable/capability.py:
##########
@@ -99,8 +101,33 @@
 # types have changed since, so replaying it would fail on every retry.
 _UNLOADABLE = "the recorded result no longer loads, so it was written by 
another version"
 
-_NO_CONFIG: RoleBasedOperationConfig[None] = RoleBasedOperationConfig(
-    model=None, event=None, capability=None, tool=None
+# How an operation's step is run: looked up in the journal and recorded, or 
always run live.
+_StepMode: TypeAlias = Literal["journal", "live"]
+
+
+def _journals_tool(tool_def: ToolDefinition) -> bool:

Review Comment:
   ```suggestion
   def is_tool_journaled(tool_def: ToolDefinition) -> bool:
   ```



##########
providers/common/ai/docs/decision_models.rst:
##########
@@ -55,8 +54,8 @@ model, so a model id is the whole integration.
        it. `pydantic-ai's System One page 
<https://pydantic.dev/docs/ai/models/system-one/>`__
        lists more.
 
-Both prefixes need a newer ``pydantic-ai-slim`` than the floor the provider's 
other extras
-set, so check the release you have installed.
+``system-one:`` needs a newer ``pydantic-ai-slim`` than the provider's 
minimum, so check the

Review Comment:
   should we mention which version?



##########
providers/common/ai/tests/unit/common/ai/durable/test_capability.py:
##########
@@ -460,6 +460,15 @@ def query(sql: str) -> Any:
     return toolset
 
 
+def _dynamic_toolset(calls: Calls, result: Any) -> DynamicToolset[None]:

Review Comment:
   ```suggestion
   def _build_dynamic_toolset(calls: Calls, result: Any) -> 
DynamicToolset[None]:
   ```



##########
providers/common/ai/tests/unit/common/ai/durable/test_capability.py:
##########
@@ -870,6 +879,175 @@ def build() -> Agent[None, str]:
         assert calls["model"] == 3
 
 
+def _ops_toolset(calls: Calls, *, clock_metadata: dict[str, Any] | None = 
None, clock_changes: bool = False):

Review Comment:
   ```suggestion
   def _build_ops_toolset(calls: Calls, *, clock_metadata: dict[str, Any] | 
None = None, clock_changes: bool = False):
   ```



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