wenjin272 opened a new pull request, #1320: URL: https://github.com/apache/flink-agents/pull/1320
Fixes #1279. ### Purpose of change #### User-visible outcome Model-driven subagent await failures can be returned to the model as failed tool observations without subsequently failing action finalization for an unresolved handle. #### Runtime flow Deferred execution and async awaiting release their pending-call registrations in finally blocks in Java and Python. ToolCallAction continues to handle ordinary await exceptions; successful result caching and caller-driven exception propagation remain unchanged. #### Key decisions The future owns cleanup. No caller-facing fail hook, exception conversion, additional retry, or exception cache is introduced. ### Behavioral Semantics #### Interaction decisions | Await outcome | Handle cleanup | Caller behavior | |---|---|---| | Successful or error SubagentResult | Untracked | Receives result | | System-level exception | Untracked | Original exception propagates; ToolCallAction can report it | | Cancellation or interruption | Untracked | Original await exception propagates | | Handle neither awaited nor cancelled | Remains pending | Action finalization rejects it | #### Behavioral contracts 1. A model-handled failure during deferred preparation/execution or async status/fetch no longer causes an unresolved-handle finalization error. 2. Direct await retains original exception, cancellation and interruption propagation. 3. Normal error results, successful cached results, cancellation and dropped-handle checks continue to work. #### Failure behavior No fallback or automatic retry is added. Await implementations retain responsibility for any retry; callers should not retry an await that throws. This cleanup does not suppress exceptions or change ToolCallAction dispatch policies. ### Tests | Contract | Coverage | |---|---| | 1 | SubagentAwaitCleanupTest modelHandledFailureAllowsActionToFinish; Python test_model_handled_failure_allows_action_finalization; deferred prepare/call and async status/fetch with sequential/parallel tool-call dispatch | | 2 | Java/Python direct-await tests checking original exception identity and empty registry; existing caller-driven operator failure tests | | 3 | Error-result controls; existing deferred, async, base lifecycle and ToolCallAction tests | Not verified: full cluster jobs, live services, new failover/checkpoint injection, or cross-language E2E. Python tests invoke the lifecycle hook explicitly with an in-process durable-await fixture. Group pre-prepare failures and unawaited siblings are outside this change. <details> <summary>Validation</summary> Before the change, 8 Java operator scenarios failed at action finalization while 4 error-result controls passed; Python had 24 lifecycle failures and 8 passing controls. At commit `0a752a584` (based on `3320e5675`): 71 focused Java tests pass on each of JDK 17.0.2 and JDK 21.0.8; 102 Python tests pass. Spotless, Ruff and whitespace checks pass. </details> ### API No signature changes. Java and Python await documentation distinguishes error results from propagated exceptions and specifies that handled await failures need no additional handle cleanup. ### Documentation - [ ] doc-needed - [ ] doc-not-needed - [x] doc-included ### Was this patch authored or co-authored using generative AI tooling? - [x] Yes - [ ] No Generated-by: Codex 0.153.4 (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]
