Skip to content

Commit ce6e64b

Browse files
committed
More changes to for the TCK
1 parent 6fd1ff9 commit ce6e64b

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

server-common/src/main/java/io/a2a/server/tasks/InMemoryTaskStore.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
import jakarta.enterprise.context.ApplicationScoped;
1212

13+
import org.slf4j.Logger;
14+
import org.slf4j.LoggerFactory;
15+
1316
import io.a2a.spec.Artifact;
1417
import io.a2a.spec.ListTasksParams;
1518
import io.a2a.spec.ListTasksResult;
@@ -19,10 +22,12 @@
1922
@ApplicationScoped
2023
public class InMemoryTaskStore implements TaskStore, TaskStateProvider {
2124

25+
private static final Logger LOGGER = LoggerFactory.getLogger(InMemoryTaskStore.class);
2226
private final ConcurrentMap<String, Task> tasks = new ConcurrentHashMap<>();
2327

2428
@Override
2529
public void save(Task task) {
30+
LOGGER.debug("=== InMemoryTaskStore.save() === taskId=" + task.getId() + ", contextId=" + task.getContextId());
2631
tasks.put(task.getId(), task);
2732
}
2833

@@ -38,6 +43,13 @@ public void delete(String taskId) {
3843

3944
@Override
4045
public ListTasksResult list(ListTasksParams params) {
46+
// DEBUG: Log store contents for totalSize investigation
47+
LOGGER.debug("=== InMemoryTaskStore.list() DEBUG ===");
48+
LOGGER.debug("Total tasks in store: {}", tasks.size());
49+
LOGGER.debug("Filter contextId: {}", params.contextId());
50+
LOGGER.debug("Filter status: {}", params.status());
51+
tasks.values().forEach(t -> LOGGER.debug(" Task: id={}, contextId={}", t.getId(), t.getContextId()));
52+
4153
// Filter and sort tasks in a single stream pipeline
4254
List<Task> allFilteredTasks = tasks.values().stream()
4355
.filter(task -> params.contextId() == null || params.contextId().equals(task.getContextId()))
@@ -57,6 +69,8 @@ public ListTasksResult list(ListTasksParams params) {
5769
.toList();
5870

5971
int totalSize = allFilteredTasks.size();
72+
LOGGER.debug("Filtered tasks count: {}", totalSize);
73+
LOGGER.debug("=== END DEBUG ===");
6074

6175
// Apply pagination
6276
int pageSize = params.getEffectivePageSize();

spec-grpc/src/main/java/io/a2a/grpc/utils/ProtoUtils.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
import java.util.Map;
1111
import java.util.stream.Collectors;
1212

13+
import org.slf4j.Logger;
14+
import org.slf4j.LoggerFactory;
15+
1316
import com.google.protobuf.ByteString;
1417
import com.google.protobuf.Struct;
1518
import com.google.protobuf.Value;
@@ -70,6 +73,7 @@
7073
public class ProtoUtils {
7174

7275
public static class ToProto {
76+
private static final Logger LOGGER = LoggerFactory.getLogger(ToProto.class);
7377

7478
public static io.a2a.grpc.AgentCard agentCard(AgentCard agentCard) {
7579
io.a2a.grpc.AgentCard.Builder builder = io.a2a.grpc.AgentCard.newBuilder();
@@ -155,6 +159,11 @@ public static io.a2a.grpc.Task task(Task task) {
155159
}
156160

157161
public static io.a2a.grpc.ListTasksResponse listTasksResult(io.a2a.spec.ListTasksResult result) {
162+
LOGGER.debug("=== ProtoUtils.ToProto.listTasksResult() DEBUG ===");
163+
LOGGER.debug("Input result.totalSize(): {}", result.totalSize());
164+
LOGGER.debug("Input result.pageSize(): {}", result.pageSize());
165+
LOGGER.debug("Input result.tasks().size(): {}", result.tasks().size());
166+
158167
io.a2a.grpc.ListTasksResponse.Builder builder = io.a2a.grpc.ListTasksResponse.newBuilder();
159168
if (result.tasks() != null) {
160169
builder.addAllTasks(result.tasks().stream().map(ToProto::task).collect(Collectors.toList()));
@@ -164,7 +173,14 @@ public static io.a2a.grpc.ListTasksResponse listTasksResult(io.a2a.spec.ListTask
164173
}
165174
builder.setTotalSize(result.totalSize());
166175
builder.setPageSize(result.pageSize());
167-
return builder.build();
176+
177+
io.a2a.grpc.ListTasksResponse response = builder.build();
178+
LOGGER.debug("Output response.getTotalSize(): {}", response.getTotalSize());
179+
LOGGER.debug("Output response.getPageSize(): {}", response.getPageSize());
180+
LOGGER.debug("Output response.getTasksCount(): {}", response.getTasksCount());
181+
LOGGER.debug("=== END ProtoUtils DEBUG ===");
182+
183+
return response;
168184
}
169185

170186
public static io.a2a.grpc.Message message(Message message) {

tck/src/main/resources/application.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ a2a.executor.keep-alive-seconds=60
1212
quarkus.log.category."io.a2a.server.requesthandlers".level=DEBUG
1313
quarkus.log.category."io.a2a.server.events".level=DEBUG
1414
quarkus.log.category."io.a2a.server.tasks".level=DEBUG
15+
quarkus.log.category."io.a2a.grpc.utils".level=DEBUG
1516

1617
# Log to file for analysis
1718
quarkus.log.file.enable=true

transport/rest/src/main/java/io/a2a/transport/rest/handler/RestHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ private void validate(String json) {
300300

301301
private HTTPRestResponse createSuccessResponse(int statusCode, com.google.protobuf.Message.Builder builder) {
302302
try {
303-
String jsonBody = JsonFormat.printer().print(builder);
303+
String jsonBody = JsonFormat.printer().includingDefaultValueFields().print(builder);
304304
return new HTTPRestResponse(statusCode, "application/json", jsonBody);
305305
} catch (InvalidProtocolBufferException e) {
306306
return createErrorResponse(new InternalError("Failed to serialize response: " + e.getMessage()));

0 commit comments

Comments
 (0)