Skip to content

Commit 76cc03a

Browse files
authored
chore: add logging to TaskManager (#205)
# Description I noticed while reviewing #181 and looking at the Python implementation that we don't have logging in the TaskManager. We decided on the logging strategy after the initial code was written. This PR addresses this omission.
1 parent ea56419 commit 76cc03a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@
1616
import io.a2a.spec.TaskArtifactUpdateEvent;
1717
import io.a2a.spec.TaskStatus;
1818
import io.a2a.spec.TaskStatusUpdateEvent;
19+
import org.slf4j.Logger;
20+
import org.slf4j.LoggerFactory;
1921

2022
public class TaskManager {
23+
24+
private static final Logger LOGGER = LoggerFactory.getLogger(TaskManager.class);
25+
2126
private volatile String taskId;
2227
private volatile String contextId;
2328
private final TaskStore taskStore;
@@ -101,16 +106,18 @@ Task saveTaskEvent(TaskArtifactUpdateEvent event) throws A2AServerException {
101106
// This represents the first chunk for this artifact index
102107
if (existingArtifactIndex >= 0) {
103108
// Replace the existing artifact entirely with the new artifact
109+
LOGGER.debug("Replacing artifact at id {} for task {}", artifactId, taskId);
104110
artifacts.set(existingArtifactIndex, newArtifact);
105111
} else {
106112
// Append the new artifact since no artifact with this id/index exists yet
113+
LOGGER.debug("Adding artifact at id {} for task {}", artifactId, taskId);
107114
artifacts.add(newArtifact);
108115
}
109116

110117
} else if (existingArtifact != null) {
111118
// Append new parts to the existing artifact's parts list
112119
// Do this to a copy
113-
120+
LOGGER.debug("Appending parts to artifact id {} for task {}", artifactId, taskId);
114121
List<Part<?>> parts = new ArrayList<>(existingArtifact.parts());
115122
parts.addAll(newArtifact.parts());
116123
Artifact updated = new Artifact.Builder(existingArtifact)
@@ -120,6 +127,9 @@ Task saveTaskEvent(TaskArtifactUpdateEvent event) throws A2AServerException {
120127
} else {
121128
// We received a chunk to append, but we don't have an existing artifact.
122129
// We will ignore this chunk
130+
LOGGER.warn(
131+
"Received append=true for nonexistent artifact index for artifact {} in task {}. Ignoring chunk.",
132+
artifactId, taskId);
123133
}
124134

125135
task = new Task.Builder(task)

0 commit comments

Comments
 (0)