This is an automated email from the ASF dual-hosted git repository.

Lee-W pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new de856e4aa44 Fix the common.ai message_history trimming example and 
link the memory page (#74706)
de856e4aa44 is described below

commit de856e4aa449fd3e13db117c54ad0a395f95385c
Author: Wei Lee <[email protected]>
AuthorDate: Wed Oct 14 19:05:27 2026 +0900

    Fix the common.ai message_history trimming example and link the memory page 
(#74706)
---
 providers/common/ai/docs/message_history.rst | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/providers/common/ai/docs/message_history.rst 
b/providers/common/ai/docs/message_history.rst
index af76b8b76de..453b4d7a7c3 100644
--- a/providers/common/ai/docs/message_history.rst
+++ b/providers/common/ai/docs/message_history.rst
@@ -66,16 +66,16 @@ capability from pydantic-ai's documentation works on 
``AgentOperator`` as is:
 .. code-block:: python
 
     from pydantic_ai.capabilities import ProcessHistory
-    from pydantic_ai.messages import ModelMessage, ModelRequest, ToolReturnPart
+    from pydantic_ai.messages import ModelMessage, ModelRequest, 
RetryPromptPart, ToolReturnPart
 
 
     def keep_recent(messages: list[ModelMessage]) -> list[ModelMessage]:
         tail = messages[-10:]
-        # Start at a request without tool returns, so no tool return is left
-        # without its tool call.
+        # Start at a user turn. A tail that begins at a request holding only 
tool
+        # returns or retries (mid-run) loses the user's question.
         for i, message in enumerate(tail):
             if isinstance(message, ModelRequest) and not any(
-                isinstance(part, ToolReturnPart) for part in message.parts
+                isinstance(part, (ToolReturnPart, RetryPromptPart)) for part 
in message.parts
             ):
                 return tail[i:]
         return messages
@@ -98,7 +98,8 @@ object-storage XCom backend for long sessions.
 The operator has no built-in cross-session memory. To let an agent use facts
 from earlier sessions, store them yourself, load them in an upstream task (the
 same load, run, store pattern as above), and put them in the prompt or the
-instructions.
+instructions. To let the agent keep its own notes across Dag runs instead, see
+:doc:`memory`.
 
 Related pydantic-ai documentation
 ---------------------------------

Reply via email to