joeyutong opened a new pull request, #1264:
URL: https://github.com/apache/flink-agents/pull/1264

   Linked issue: #1243
   
   ### Purpose of change
   
   Add DecisionModel Resources so business Actions can evaluate 
application-supplied evidence against named questions and consume typed, 
probability-aware answers.
   
   #### Data models and providers
   
   - `DecisionRequest` carries text/JSON evidence and named Predicate, Choice, 
or Score questions. `DecisionResult` retains typed answers, probability 
distributions, explicit per-question refusals, and provider-reported 
model/token usage.
   - TypeSafe/Jev and OpenAI Decisions are integrated through their official 
Python SDKs. Alibaba Cloud DashScope / Model Studio is supported through its 
TypeSafe-compatible Decision endpoint, using the same TypeSafe adapter.
   - Resource registration follows the existing connection/setup model, with 
Java/Python APIs and Python decorator/YAML declarations.
   
   #### Invocation
   
   **For most applications, calling the Resource directly from a business 
Action should be sufficient:** obtain the configured model through 
`ctx.get_resource` / `ctx.getResource`, call `model.decide(request)`, and use 
the answers in the same Action. The application supplies the business facts and 
criteria, chooses thresholds, and controls subsequent processing.
   
   The PR also provides an **Event/Action invocation path**:
   
   `DecisionRequestEvent` → built-in `DecisionModelAction` → 
`DecisionResponseEvent` → downstream business Action.
   
   This allows workflows to trigger a decision and consume its response through 
the existing Event/Action model. Both Java and Python Actions can use these 
invocation styles.
   
   This PR covers the Decision data models, provider Resources, and these two 
invocation paths. The `context.decide(...)` convenience API remains a follow-up 
to the linked issue.
   
   ### Behavioral Semantics
   
   - Question identifiers are preserved. Choice answers distinguish boolean 
values from strings; Score answers retain the expected zero-based level index 
and the distribution over described levels.
   - Provider-native question content is preserved rather than translated 
between providers. Business thresholds and follow-up actions remain application 
decisions.
   - Explicit per-question refusals are represented as answers. Missing usage 
counts remain unknown.
   - Event/Action responses are correlated with their request Event ID.
   
   ### Tests
   
   Focused validation: **577 Python tests passed** (15 skipped, 6 deselected) 
and **250 Java tests passed** (17 skipped). Ruff, Spotless, and the Hugo 
documentation build passed.
   
   | Contract | Coverage |
   | --- | --- |
   | Request/answer types and provider payloads | Decision model API tests and 
TypeSafe/OpenAI adapter tests |
   | Resource registration and invocation | YAML/resource tests and Decision 
Action tests |
   | Java/Python Event and plan compatibility | Event snapshots and plan 
compatibility tests |
   | Application usage and SDK compatibility | Review-analysis Agent tests and 
existing OpenAI Chat tests |
   
   ### API
   
   Adds Decision Resource, request/result, and Event APIs in Java/Python; 
Python question/answer types and provider implementations; Python YAML resource 
declarations; and the `decision.async` execution option.
   
   Python dependency requirements become Pydantic `2.12.x`, OpenAI SDK 
`>=3.26.0,<4`, and TypeSafe SDK `>=0.7.4,<0.8`.
   
   ### Documentation
   
   - [ ] `doc-needed`
   - [ ] `doc-not-needed`
   - [x] `doc-included`
   
   Includes the Decision Models guide, provider/calling examples, YAML schema 
and reference updates, and execution configuration.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   - [x] Yes
   - [ ] No
   
   Generated-by: Codex CLI 0.162.0-alpha.17.2 (GPT-6)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to