YAshhh29 commented on code in PR #71575:
URL: https://github.com/apache/airflow/pull/71575#discussion_r4105722838


##########
providers/common/ai/src/airflow/providers/common/ai/durable/fingerprint.py:
##########
@@ -99,10 +114,18 @@ def _strip_volatile(messages_dump: list[dict[str, Any]]) 
-> list[dict[str, Any]]
 
 
 def _digest(payload: Any) -> str:

Review Comment:
   My last push turned a fail-open into silent data corruption, which is the 
worse of the two.
   
   I reproduced it first: `TypeAdapter(Iterable[int]).validate_python([1, 2, 
3])` gives a `ValidatorIterator`, `to_jsonable_python` drains it, and `sum()` 
afterwards is `0`. On the merge-base, `json.dumps` raised `TypeError` without 
advancing it, so the tool still got `6`. End to end with a real `Agent` + 
`FunctionModel` + `FunctionToolset` and `def total(values: Iterable[int])`, the 
tool saw `[]`, the agent answered `total=0`, and that `0` was cached under the 
fingerprint of `[1, 2, 3]`.
   
   I went with refusing it rather than normalizing a deep copy. A copy only 
helps if copying a lazy iterator gives you an independent one, and that's 
exactly what you can't count on — whereas refusing lands on the not-cached 
path, where the step just re-runs live. `_canonical` raises `TypeError` for any 
`Iterator`, so a plain generator behaves the same way. I also checked the 
nested cases: an `Iterable[int]` field on a `BaseModel` or dataclass argument 
is refused too, with the values left intact for the tool.
   
   Tests: `TestLazilyValidatedIterable` covers the refusal and checks the 
iterator is still readable afterwards, and 
`TestLazilyValidatedIterableArgument` in `test_replay_verification.py` is the 
real-agent regression test you asked for — the tool gets `[1, 2, 3]`, the 
answer is `total=6`, and nothing is written for that step.
   



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