66import java .util .ArrayList ;
77import java .util .List ;
88
9+ import io .a2a .server .events .EventQueue ;
910import io .a2a .spec .A2AServerException ;
1011import io .a2a .spec .Artifact ;
1112import io .a2a .spec .Event ;
1617import io .a2a .spec .TaskArtifactUpdateEvent ;
1718import io .a2a .spec .TaskStatus ;
1819import io .a2a .spec .TaskStatusUpdateEvent ;
20+ import org .slf4j .Logger ;
21+ import org .slf4j .LoggerFactory ;
1922
2023public class TaskManager {
24+
25+ private static final Logger LOGGER = LoggerFactory .getLogger (TaskManager .class );
26+
2127 private volatile String taskId ;
2228 private volatile String contextId ;
2329 private final TaskStore taskStore ;
@@ -101,16 +107,18 @@ Task saveTaskEvent(TaskArtifactUpdateEvent event) throws A2AServerException {
101107 // This represents the first chunk for this artifact index
102108 if (existingArtifactIndex >= 0 ) {
103109 // Replace the existing artifact entirely with the new artifact
110+ LOGGER .debug ("Replacing artifact at id {} for task {}" , artifactId , taskId );
104111 artifacts .set (existingArtifactIndex , newArtifact );
105112 } else {
106113 // Append the new artifact since no artifact with this id/index exists yet
114+ LOGGER .debug ("Adding artifact at id {} for task {}" , artifactId , taskId );
107115 artifacts .add (newArtifact );
108116 }
109117
110118 } else if (existingArtifact != null ) {
111119 // Append new parts to the existing artifact's parts list
112120 // Do this to a copy
113-
121+ LOGGER . debug ( "Appending parts to artifact id {} for task {}" , artifactId , taskId );
114122 List <Part <?>> parts = new ArrayList <>(existingArtifact .parts ());
115123 parts .addAll (newArtifact .parts ());
116124 Artifact updated = new Artifact .Builder (existingArtifact )
@@ -120,6 +128,9 @@ Task saveTaskEvent(TaskArtifactUpdateEvent event) throws A2AServerException {
120128 } else {
121129 // We received a chunk to append, but we don't have an existing artifact.
122130 // We will ignore this chunk
131+ LOGGER .warn (
132+ "Received append=true for nonexistent artifact indes {} in task {}. Ignoring chunk." ,
133+ artifactId , taskId );
123134 }
124135
125136 task = new Task .Builder (task )
0 commit comments