Skip to content

Commit 91ef04f

Browse files
committed
chore: add logging to TaskManager
1 parent 65f4c93 commit 91ef04f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

sdk-server-common/src/main/java/io/a2a/server/tasks/TaskManager.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.util.ArrayList;
77
import java.util.List;
88

9+
import io.a2a.server.events.EventQueue;
910
import io.a2a.spec.A2AServerException;
1011
import io.a2a.spec.Artifact;
1112
import io.a2a.spec.Event;
@@ -16,8 +17,13 @@
1617
import io.a2a.spec.TaskArtifactUpdateEvent;
1718
import io.a2a.spec.TaskStatus;
1819
import io.a2a.spec.TaskStatusUpdateEvent;
20+
import org.slf4j.Logger;
21+
import org.slf4j.LoggerFactory;
1922

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

Comments
 (0)