agentscope-extensions-judge, alongside JEV, and exposes OpenAIDecisionsClient independently of the chat model APIs. Applications can use its results to classify requests or choose their next action.
The official guide describes the API as public beta. The API reference lists gpt-6-luna; this is the client’s default model. Service access depends on your OpenAI account.
Dependency and first decision
This addition targets2.1.0-SNAPSHOT; use a build containing this extension. With the AgentScope BOM, omit the dependency version.
OPENAI_API_KEY before running. An explicit builder key takes precedence over the environment. Calling the following example sends the text and question to OpenAI and may incur charges.
DecisionRequest contains 1–400 uniquely named questions. The optional request model overrides the client model. Inputs and question collections are copied when constructed, so a request can be reused safely. The optional promptCacheKey() partitions cache reuse; this extension does not expose prompt_cache_options or explicit cache breakpoints, so OpenAI uses its default implicit caching. decide() returns a cold Mono: each subscription sends a request. Use it in reactive applications; decideBlocking() is a convenience for non-reactive threads.
Questions and answers
All public types are inio.agentscope.extensions.judge.openaidecisions.
Choice values may be strings or booleans;
"true" and true are distinct. An option’s description and a level’s description are optional. Confidence is preserved separately from the selected probability. Do not interpret either as an application-specific guarantee of correctness; choose thresholds using labeled examples.
Every question may instead return DecisionAnswer.Refusal. Check for this type before taking an action. Other valid answers and usage remain available in the same DecisionResult. Refusals are not converted into zero probabilities or guessed choices.
The client matches answers by name and distribution entries by value/index, so response ordering is not significant. Missing, duplicate, unknown, or mismatched answers are rejected. Every choice or level must appear exactly once, numeric fields must be present and finite, probabilities and confidence must be in [0, 1], and probabilities must sum to one within 1e-6 × option count. The chosen value must be one of the supplied options; the score must match the weighted indices within the same tolerance. Values are preserved without normalization. An invalid response fails the entire Mono with OpenAIDecisionsException.
DecisionResult.usage() contains input, output, and total token counts supplied by the provider. It also flattens the provider’s token-detail fields into cachedTokens, cacheWriteTokens, and reasoningTokens. Missing usage is null; missing individual counts and detail fields remain null. A real zero remains zero. Usage on failed calls is not exposed.
Images and mixed input
Pass image URLs toDecisionInput.image(url) for image-only input, or construct DecisionInput(text, imageUrls) to combine text and up to 128 images in one user message. pngBytes below represents PNG data loaded by your application.
Configuration and failures
The default API base ishttps://api.openai.com/v1. baseUrl() accepts a versioned API base, including any gateway path prefix, or a complete /decisions endpoint. Credentials, query strings, and fragments are rejected in the base URL. A custom base should retain the API version path.
The default timeout is 30 seconds and must be positive. Blocking SDK calls run on Reactor’s boundedElastic scheduler. The timeout is also passed to the SDK. Timeout and cancellation interrupt the executing task; the SDK transport determines when an in-flight network call stops. Close clients created by the wrapper with close() or try-with-resources to release SDK connections. Spring closes the auto-configured client when its context shuts down.
HTTP failures expose a status code through OpenAIDecisionsException.getStatusCode(). HTTP 429, 5xx, and client timeout errors carry a retry hint; isRetryable() does not trigger a retry. SDK I/O failures and errors explicitly marked retryable by the SDK also retain a retry hint. The wrapper disables automatic retries on SDK clients it creates. builder().client(openAIClient) borrows an existing official SDK client, whose credentials, base URL, retry configuration, and lifecycle remain controlled by its owner. The wrapper still applies its model and request timeout. Provider bodies and raw SDK causes are omitted from client-generated exceptions.
Spring Boot
Use the starter dependency instead of adding the extension directly, then injectOpenAIDecisionsClient.
agentscope.openai-decisions.enabled=false disables client creation. A user-defined client bean takes precedence. Implement OpenAIDecisionsClientBuilderCustomizer to supply an official SDK client or override properties; Spring applies ordered customizers after binding properties.
A complete three-question example and image-input helper are available in agentscope-examples/documentation/src/main/java/io/agentscope/examples/documentation2/judge/OpenAIDecisionsExample.java.