Class AgentProtocolTaskClient
java.lang.Object
io.agentscope.harness.agent.subagent.task.AgentProtocolTaskClient
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidPOST /tasks/{taskId}/cancel.GET /tasks/{taskId}.openEventStream(String baseUrl, Map<String, String> headers, String taskId, long fromSeq, Consumer<RemoteAgentEvent> consumer) OpensGET /tasks/{taskId}/eventsas an SSE stream and delivers parsed events toconsumer.voidresumeTask(String baseUrl, Map<String, String> headers, String taskId, List<RemoteConfirmDecision> decisions) POST /tasks/{taskId}/resumewith body{decisions: [...]}.voidPOST /taskswith body{task_id, agent_id, input}(+ optional context).voidsubmitTask(String baseUrl, Map<String, String> headers, String taskId, String agentId, String input, RemoteSubmitContext context) POST /taskswith body{task_id, agent_id, input, context?}.GET /tasks/{taskId}/wait?timeout_seconds=<n>— blocks until the server completes the task.
-
Constructor Details
-
AgentProtocolTaskClient
public AgentProtocolTaskClient() -
AgentProtocolTaskClient
-
-
Method Details
-
submitTask
public void submitTask(String baseUrl, Map<String, String> headers, String taskId, String agentId, String input) throws IOException, InterruptedExceptionPOST /taskswith body{task_id, agent_id, input}(+ optional context).- Throws:
IOExceptionInterruptedException
-
submitTask
public void submitTask(String baseUrl, Map<String, String> headers, String taskId, String agentId, String input, RemoteSubmitContext context) throws IOException, InterruptedExceptionPOST /taskswith body{task_id, agent_id, input, context?}.Legacy servers ignore unknown
contextfield.- Throws:
IOExceptionInterruptedException
-
getStatus
public RemoteTaskStatus getStatus(String baseUrl, Map<String, String> headers, String taskId) throws IOException, InterruptedExceptionGET /tasks/{taskId}.- Throws:
IOExceptionInterruptedException
-
waitForResult
public String waitForResult(String baseUrl, Map<String, String> headers, String taskId, long timeoutSeconds) throws IOException, InterruptedExceptionGET /tasks/{taskId}/wait?timeout_seconds=<n>— blocks until the server completes the task. The HTTP read timeout is set totimeoutSeconds + 60seconds to give the server time to respond.- Throws:
IOExceptionInterruptedException
-
cancelTask
public void cancelTask(String baseUrl, Map<String, String> headers, String taskId) throws IOException, InterruptedExceptionPOST /tasks/{taskId}/cancel.- Throws:
IOExceptionInterruptedException
-
resumeTask
public void resumeTask(String baseUrl, Map<String, String> headers, String taskId, List<RemoteConfirmDecision> decisions) throws IOException, InterruptedExceptionPOST /tasks/{taskId}/resumewith body{decisions: [...]}.- Throws:
IOException- on HTTP error (including 404 when the server lacks HITL support)InterruptedException
-
openEventStream
public Closeable openEventStream(String baseUrl, Map<String, String> headers, String taskId, long fromSeq, Consumer<RemoteAgentEvent> consumer) throws IOException, InterruptedExceptionOpensGET /tasks/{taskId}/eventsas an SSE stream and delivers parsed events toconsumer. Silently no-ops (returns a closed handle) when the server returns 404.- Throws:
IOExceptionInterruptedException
-