Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import io.a2a.client.ClientEvent;
import io.a2a.util.Utils;
import io.agentscope.core.agent.Event;
import io.agentscope.core.message.Msg;
import io.agentscope.core.message.TextBlock;
import java.util.List;
Expand All @@ -28,6 +29,19 @@
*/
public class LoggerUtil {

/**
* Logs detail information of AgentScope events output from Agent.
*
* @param logger The Logger instance used for logging
* @param event The event object to be logged from AgentScope Agent.
*/
public static void logAgentEventDetail(Logger logger, Event event) {
if (logger.isDebugEnabled()) {
debug(logger, "Event: {}", event);
logTextMsgDetail(logger, List.of(event.getMessage()));
}
}

/**
* Logs detailed information of A2A client events to the log
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import io.agentscope.core.ReActAgent;
import io.agentscope.core.a2a.server.card.AgentScopeAgentCardConverter;
import io.agentscope.core.a2a.server.card.ConfigurableAgentCard;
import io.agentscope.core.a2a.server.executor.AgentExecuteProperties;
import io.agentscope.core.a2a.server.executor.AgentScopeAgentExecutor;
import io.agentscope.core.a2a.server.executor.runner.AgentRunner;
import io.agentscope.core.a2a.server.executor.runner.ReActAgentWithBuilderRunner;
Expand Down Expand Up @@ -206,6 +207,8 @@ public static class Builder {

private DeploymentProperties deploymentProperties;

private AgentExecuteProperties agentExecuteProperties;

private Builder(AgentRunner agentRunner) {
this.agentRunner = agentRunner;
this.supportedTransports = new HashSet<>();
Expand Down Expand Up @@ -299,6 +302,17 @@ public Builder executor(Executor executor) {
return this;
}

/**
* Set deployment port to generate default transport interface information in agentCard.
*
* @param port deployment port
* @return builder instance of {@link AgentScopeA2aServer}
*/
public Builder deploymentProperties(Integer port) {
this.deploymentProperties = new DeploymentProperties.Builder().port(port).build();
return this;
}

/**
* Set deployment properties to generate default transport interface information in agentCard.
*
Expand All @@ -321,6 +335,17 @@ public Builder withAgentRegistry(AgentRegistry agentRegistry) {
return this;
}

/**
* Set agent execute properties.
*
* @param agentExecuteProperties agent execute properties
* @return builder instance of {@link AgentScopeA2aServer}
*/
public Builder agentExecuteProperties(AgentExecuteProperties agentExecuteProperties) {
this.agentExecuteProperties = agentExecuteProperties;
return this;
}

/**
* Build a new instance of {@link AgentScopeA2aServer}.
*
Expand All @@ -339,7 +364,11 @@ public AgentScopeA2aServer build() {
if (null == agentRunner) {
throw new IllegalArgumentException("AgentRunner is required.");
}
AgentScopeAgentExecutor agentExecutor = new AgentScopeAgentExecutor(agentRunner);
if (null == agentExecuteProperties) {
agentExecuteProperties = AgentExecuteProperties.builder().build();
}
AgentScopeAgentExecutor agentExecutor =
new AgentScopeAgentExecutor(agentRunner, agentExecuteProperties);
AgentScopeA2aRequestHandler requestHandler =
AgentScopeA2aRequestHandler.builder()
.agentExecutor(agentExecutor)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Copyright 2024-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.agentscope.core.a2a.server.executor;

/**
* Properties about agent execution.
*
* <p>Some of these properties are used to configure the agent execution in {@link AgentScopeAgentExecutor}.
*/
public class AgentExecuteProperties {

/**
* Whether the agent task execution should complete with a message.
*
* <p>Only for Non-blocking agent task request. The Blocking agent task request always complete with a message.
* <p>If is {@code true}, the task will complete with a message which include whole result of the agent task.
*/
private final boolean completeWithMessage;

/**
* Whether the agent task execution should require an inner message such as tool_call result.
*
* <p>If is {@code true}, the agent execution will handle {@link io.agentscope.core.agent.Event} with
* {@link io.agentscope.core.agent.EventType#TOOL_RESULT} and {@link io.agentscope.core.agent.EventType#HINT}.
*/
private final boolean requireInnerMessage;

private AgentExecuteProperties(boolean completeWithMessage, boolean requireInnerMessage) {
this.completeWithMessage = completeWithMessage;
this.requireInnerMessage = requireInnerMessage;
}

public boolean isCompleteWithMessage() {
return completeWithMessage;
}

public boolean isRequireInnerMessage() {
return requireInnerMessage;
}

public static Builder builder() {
return new Builder();
}

public static class Builder {
private boolean completeWithMessage;
private boolean requireInnerMessage;

public Builder completeWithMessage(boolean completeWithMessage) {
this.completeWithMessage = completeWithMessage;
return this;
}

public Builder requireInnerMessage(boolean requireInnerMessage) {
this.requireInnerMessage = requireInnerMessage;
return this;
}

public AgentExecuteProperties build() {
return new AgentExecuteProperties(completeWithMessage, requireInnerMessage);
}
}
}
Loading
Loading