File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
src/a2a/server/request_handlers Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -112,6 +112,26 @@ async def on_get_task(
112112 task : Task | None = await self .task_store .get (params .id )
113113 if not task :
114114 raise ServerError (error = TaskNotFoundError ())
115+
116+ # Apply historyLength parameter if specified
117+ if params .history_length is not None and task .history :
118+ # Limit history to the most recent N messages
119+ limited_history = (
120+ task .history [- params .history_length :]
121+ if params .history_length > 0
122+ else []
123+ )
124+ # Create a new task instance with limited history
125+ task = Task (
126+ id = task .id ,
127+ context_id = task .context_id ,
128+ status = task .status ,
129+ artifacts = task .artifacts ,
130+ history = limited_history ,
131+ metadata = task .metadata ,
132+ kind = task .kind ,
133+ )
134+
115135 return task
116136
117137 async def on_cancel_task (
You can’t perform that action at this time.
0 commit comments