Skip to content

easy-4-java/agent-invoker-java-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

agent-invoker-java-sdk

AI Agent Invoker abstraction SDK — Provider-agnostic AI agent invocation for Java.

Overview

Provides a unified abstraction for invoking AI agents across different providers (OpenClaw, Spring AI, Bedrock, etc.).

  • AiAgentInvoker — interface for submitting AI tasks, canceling, and handling callbacks
  • AiAgentInvokerRouter — routes to the correct provider based on providerCode and defaultProvider
  • CallbackRouter — routes callbacks to the correct provider adapter
  • OpenClawAiAgentInvoker — OpenClaw provider adapter (requires openclaw-java-sdk)
  • OpenClawInvokeRequestMapper — maps AgentInvokeCmd to OpenClaw InvokeAgentRequest

Usage

AiAgentInvokerRouter router = new AiAgentInvokerRouter();
router.setDefaultProvider("openclaw");
router.register(new OpenClawAiAgentInvoker(openClawClient, "http://localhost:7088"));

AgentInvokeCmd cmd = AgentInvokeCmd.builder()
    .taskId("task-001")
    .agentId("main")
    .providerCode("openclaw")
    .enhancedPrompt("Generate content...")
    .callbackUrl("http://localhost:7088/api/generation/save")  // optional; overrides callback base URL
    .tenantId("t1")
    .userId("u1")
    .channel("xiaohongshu")
    .variables(Collections.singletonMap("tone", "casual"))
    .build();

AiAgentInvoker invoker = router.route("openclaw");
SubmitResult result = invoker.submit(cmd);

OpenClaw callback URL

OpenClaw Gateway Hooks (POST /hooks/agent) has no dedicated callbackUrl field. The adapter:

  1. Resolves URL from AgentInvokeCmd.callbackUrl, else adapter callbackBaseUrl
  2. Embeds the URL and task_id / metadata in the agent message for OpenClaw to POST results back

Cancel

OpenClawAiAgentInvoker.cancel(taskId) tracks taskId → runId after successful submit. The HTTP SDK has no run-cancel API; cancel sends a best-effort wake signal when a runId is known.

Configuration (Spring Boot)

Use openclaw-spring-boot-starter for OpenClawClient (openclaw.*). Use agent-invoker-spring-boot-starter for routing (agents.provider.*):

Key Purpose
agents.provider.default-provider Router fallback when providerCode is empty
agents.provider.openclaw.enabled Enable OpenClaw adapter
agents.provider.openclaw.callback-base-url Adapter callback base (overrides openclaw.callback-base-url when set)
openclaw.gateway-base-url Gateway URL for OpenClawClient
openclaw.hooks-token Webhook auth for OpenClawClient
openclaw.callback-base-url Bridged to adapter when agent-invoker key is unset

Multi-Version Support

9 branches for different Spring Boot lines: 2.3.x, 2.7.x, 3.0.x–4.0.x. Each branch has its pom.xml generated by scripts/render-branch-pom.py.

About

Java SDK for Agent Invoker

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages