AgentProtocolTaskClient
public final class AgentProtocolTaskClient
io/agentscope/harness/agent/subagent/task/AgentProtocolTaskClient.java:53–408智能体协议任务客户端,封装与远端服务的连接和调用。位于 io.agentscope.harness.agent.subagent.task 包。核心成员包括 submitTask、getStatus、waitForResult、cancelTask、resumeTask、openEventStream。
Minimal HTTP client for the internal AgentScope task protocol (POST/GET /tasks/...).
The client-supplied taskId is used as the remote task identifier (no separate run id).
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public AgentProtocolTaskClient() | 初始化 `AgentProtocolTaskClient` 实例。 Creates a new instance. |
public AgentProtocolTaskClient(HttpClient http) | 初始化 `AgentProtocolTaskClient` 实例。 Creates a new instance. |
方法摘要Method Summary
构造器详情Constructor Detail
AgentProtocolTaskClient
public AgentProtocolTaskClient()
初始化 AgentProtocolTaskClient 实例。
Creates a new instance.
io/agentscope/harness/agent/subagent/task/AgentProtocolTaskClient.java:68–74AgentProtocolTaskClient
public AgentProtocolTaskClient(HttpClient http)
初始化 AgentProtocolTaskClient 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
http | HttpClient | HTTP(类型 `HttpClient`)。The http. |
io/agentscope/harness/agent/subagent/task/AgentProtocolTaskClient.java:76–78方法详情Method Detail
submitTask
public void submitTask(String baseUrl, Map<String, String> headers, String taskId, String agentId, String input) throws IOException, InterruptedException
执行提交任务相关操作。
POST /tasks with body {task_id, agent_id, input} (+ optional context).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
baseUrl | String | 基类 URL(类型 `String`)。The base url. |
headers | Map<String, String> | 请求头(类型 `Map`)。The headers. |
taskId | String | 任务标识(类型 `String`)。The task id. |
agentId | String | 智能体标识(类型 `String`)。The agent id. |
input | String | 输入消息(类型 `String`)。The input. |
IOException可能抛出 `IOException`。Thrown when the operation cannot be completed.InterruptedException可能抛出 `InterruptedException`。Thrown when the operation cannot be completed.
io/agentscope/harness/agent/subagent/task/AgentProtocolTaskClient.java:81–89submitTask
public void submitTask(String baseUrl, Map<String, String> headers, String taskId, String agentId, String input, RemoteSubmitContext context) throws IOException, InterruptedException
执行提交任务相关操作。
POST /tasks with body {task_id, agent_id, input, context?}.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
baseUrl | String | 基类 URL(类型 `String`)。The base url. |
headers | Map<String, String> | 请求头(类型 `Map`)。The headers. |
taskId | String | 任务标识(类型 `String`)。The task id. |
agentId | String | 智能体标识(类型 `String`)。The agent id. |
input | String | 输入消息(类型 `String`)。The input. |
context | RemoteSubmitContext | 上下文(类型 `RemoteSubmitContext`)。The context. |
IOException可能抛出 `IOException`。Thrown when the operation cannot be completed.InterruptedException可能抛出 `InterruptedException`。Thrown when the operation cannot be completed.
io/agentscope/harness/agent/subagent/task/AgentProtocolTaskClient.java:96–124getStatus
public RemoteTaskStatus getStatus(String baseUrl, Map<String, String> headers, String taskId) throws IOException, InterruptedException
获取状态。
GET /tasks/{taskId}.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
baseUrl | String | 基类 URL(类型 `String`)。The base url. |
headers | Map<String, String> | 请求头(类型 `Map`)。The headers. |
taskId | String | 任务标识(类型 `String`)。The task id. |
RemoteTaskStatusIOException可能抛出 `IOException`。Thrown when the operation cannot be completed.InterruptedException可能抛出 `InterruptedException`。Thrown when the operation cannot be completed.
io/agentscope/harness/agent/subagent/task/AgentProtocolTaskClient.java:127–147waitForResult
public String waitForResult(String baseUrl, Map<String, String> headers, String taskId, long timeoutSeconds) throws IOException, InterruptedException
等待用于结果。
GET /tasks/{taskId}/wait?timeout_seconds= — blocks until the server completes the task.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
baseUrl | String | 基类 URL(类型 `String`)。The base url. |
headers | Map<String, String> | 请求头(类型 `Map`)。The headers. |
taskId | String | 任务标识(类型 `String`)。The task id. |
timeoutSeconds | long | 超时秒(类型 `long`)。The timeout seconds. |
StringIOException可能抛出 `IOException`。Thrown when the operation cannot be completed.InterruptedException可能抛出 `InterruptedException`。Thrown when the operation cannot be completed.
io/agentscope/harness/agent/subagent/task/AgentProtocolTaskClient.java:154–175cancelTask
public void cancelTask(String baseUrl, Map<String, String> headers, String taskId) throws IOException, InterruptedException
执行取消任务相关操作。
POST /tasks/{taskId}/cancel.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
baseUrl | String | 基类 URL(类型 `String`)。The base url. |
headers | Map<String, String> | 请求头(类型 `Map`)。The headers. |
taskId | String | 任务标识(类型 `String`)。The task id. |
IOException可能抛出 `IOException`。Thrown when the operation cannot be completed.InterruptedException可能抛出 `InterruptedException`。Thrown when the operation cannot be completed.
io/agentscope/harness/agent/subagent/task/AgentProtocolTaskClient.java:178–191resumeTask
public void resumeTask(String baseUrl, Map<String, String> headers, String taskId, List<RemoteConfirmDecision> decisions) throws IOException, InterruptedException
执行恢复任务相关操作。
POST /tasks/{taskId}/resume with body {decisions: [...]}.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
baseUrl | String | 基类 URL(类型 `String`)。The base url. |
headers | Map<String, String> | 请求头(类型 `Map`)。The headers. |
taskId | String | 任务标识(类型 `String`)。The task id. |
decisions | List<RemoteConfirmDecision> | decisions(类型 `List`)。The decisions. |
IOException可能抛出 `IOException`。Thrown when the operation cannot be completed.InterruptedException可能抛出 `InterruptedException`。Thrown when the operation cannot be completed.
io/agentscope/harness/agent/subagent/task/AgentProtocolTaskClient.java:198–226openEventStream
public Closeable openEventStream(String baseUrl, Map<String, String> headers, String taskId, long fromSeq, Consumer<RemoteAgentEvent> consumer) throws IOException, InterruptedException
打开事件流。
Opens GET /tasks/{taskId}/events as an SSE stream and delivers parsed events to consumer.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
baseUrl | String | 基类 URL(类型 `String`)。The base url. |
headers | Map<String, String> | 请求头(类型 `Map`)。The headers. |
taskId | String | 任务标识(类型 `String`)。The task id. |
fromSeq | long | 来自 Seq(类型 `long`)。The from seq. |
consumer | Consumer<RemoteAgentEvent> | 消费者(类型 `Consumer`)。The consumer. |
CloseableIOException可能抛出 `IOException`。Thrown when the operation cannot be completed.InterruptedException可能抛出 `InterruptedException`。Thrown when the operation cannot be completed.
io/agentscope/harness/agent/subagent/task/AgentProtocolTaskClient.java:232–298