You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "wenjin272 (via GitHub)" <gi...@apache.org> on 2026/10/08 08:57:47 UTC
[PR] [api][runtime][java][python] Add non-durable async execution [flink-agents]
wenjin272 opened a new pull request, #1208:
URL: https://github.com/apache/flink-agents/pull/1208
Linked issue: #1191
### Purpose of change
Add deferred `ctx.execute_async` (Python) / `ctx.executeAsync` (Java) for work whose results do not need recovery persistence. Ordinary and durable calls can be combined with `ctx.gather`. Java batches also execute concurrently on JDKs below 21.
#### Runtime flow
Creating a handle does not execute its callback. Await resolves it through the runtime; gather validates its children, reserves durable slots, schedules uncached calls, and returns input-ordered outcomes. Only durable results enter recovery state.
On JDK < 21, a parallel Action worker releases the execution lock while running a single callback inline or waiting for gather's separate batch pool, then restores its context under the lock. Without the parallel Action engine, the caller blocks while batch workers still run concurrently. JDK 21 uses the continuation scheduler and its async executor. Python uses its existing shared executor and runtime-aware waiting.
#### Key decisions
Both deferred future types share one waiting interface. A separate old-JDK batch pool avoids starvation when all Action workers await children. Both pools receive shutdown signals before either is joined, preventing Python interpreter cleanup from waiting on a callback that has not been interrupted.
### Behavioral Semantics
#### Interaction decisions
| Calls / condition | Behavior |
|---|---|
| Ordinary, first await | Execute without serialization or durable slots |
| Durable, recovery | Reuse persisted outcomes or follow existing pending-call reconciliation |
| Mixed gather, recovery | Re-execute ordinary calls; reserve/replay only durable children |
| Cached child in gather | Reuse local outcome without dispatch |
| Java JDK < 21 / JDK 21+ | Separate batch pool / continuation async pool |
| Python, any JDK | Existing Python worker pool |
#### Behavioral contracts
1. Handles are cold; repeated awaits reuse their local result or business exception.
2. Ordinary results need not be serializable and are recomputed after Action replay.
3. Mixed batches preserve durable replay identity and existing reconciliation semantics.
4. Gather returns one outcome per input in input order, with concurrency bounded by `async.batch.parallelism` and available executor workers.
5. Gather rejects foreign, duplicate and nested batch handles before dispatch.
6. The batch deadline includes queue waiting. Completed outcomes survive timeout; unstarted durable calls remain pending for recovery.
7. Operator shutdown signals both Java pools before joining them and closes resources after worker cleanup.
#### Failure behavior
Single await raises callback errors; gather records ordinary callback errors per outcome. Interruption/cancellation propagates without caching a terminal business failure; Java fatal `Error`s propagate. Invalid batch inputs raise. Parallelism is normalized to at least one; a nonpositive timeout disables the deadline.
Timeout fails unfinished outcomes and prevents queued/unsubmitted callbacks from starting. Already-running callbacks may continue and produce side effects; they need their own I/O timeouts. Started durable calls retain timeout failures. Shutdown interrupts workers and aggregates cleanup failures while attempting remaining cleanup; uninterruptible callbacks can still delay shutdown.
Callbacks must not mutate context, memory or events; obtain resources first and use thread-safe clients. No public cancellation API is added.
### Tests
Passed: **334 focused Java tests on JDK 11**, **113 Python tests**, **3 real JDK 21 continuation tests**, and **4 Flink batch E2E tests on JDK 17**. Spotless, Ruff and changed-file license checks pass. Coverage targets scheduling, replay, timeouts and shutdown.
| Contract | Tests |
|---|---|
| 1. Deferred execution and local caching | Java ordinary single/batch tests; Python deferred and cached-failure tests |
| 2. No ordinary persistence; recompute on replay | Java `testOrdinaryAsyncIsDeferredAndDoesNotSerializeOrPersist`; Java/Python mixed recovery tests |
| 3. Durable identity and reconciliation | Java `testMixedBatchMapsCachedResultPendingReconcilerAndFailureToDurableSlots`; Python mixed recovery test |
| 4. Ordering, concurrency and cap | `AsyncBatchExecutorTest`; Java runtime scheduler tests on JDK 11/21; Python ordinary/mixed concurrency tests; batch E2E |
| 5. Reject invalid handles before execution | Java/Python invalid-handle tests |
| 6. Completed/started/unstarted timeout handling | Java/Python timeout recovery tests; executor queued/unsubmitted test; batch E2E |
| 7. Shutdown ordering and cleanup failures | Operator Python-batch shutdown regression, cleanup-failure test, executor close test |
Not verified: full repository/external-service suites; live checkpoint/failover E2E for mixed calls; full Flink E2E on JDK 21. The shutdown regression mocks the interpreter, retaining the real lifecycle manager. Context restrictions and client thread safety are caller obligations.
<details>
<summary>Implementation invariants and validation details</summary>
- Durable indices are reserved in relative durable-input order before dispatch. Ordinary children consume no indices. State finalization occurs after restoring the Action lock/context.
- Old-JDK batches use a sliding window, completion queue and synchronized start gate. The shared pool is per operator subtask; `num-async-threads` sizes it independently of the Action worker pool.
- Java: focused Maven reactor tests across plan/runtime (98 + 236). JDK 21 regression explicitly compiled and loaded `src/main/java21` ahead of base classes and asserted continuation support.
- Python: core option, runtime context and tool-action pytest suites with the virtual environment's purelib on `PYTHONPATH`.
- E2E: JDK 17 targeted `clean install -DskipTests` through the integration-test module, then `AsyncExecutionTest#testToolCallBatch*`, avoiding stale shaded artifacts.
- Shutdown regression timed out before the fix and passed afterward. Changed-file RAT reports zero unknown licenses.
</details>
### API
Adds `AsyncFuture` and ordinary execution methods in both languages; `DurableFuture` extends `AsyncFuture`. Java gather now accepts `AsyncFuture` children and returns `AsyncFuture<List<Outcome<T>>>`; callers expecting a durable batch return type and custom RunnerContext implementations need updating.
Renames `tool-call.parallelism` / `tool-call.batch.timeout.ms` to `async.batch.parallelism` / `async.batch.timeout.ms`, and constants to `ASYNC_BATCH_PARALLELISM` / `ASYNC_BATCH_TIMEOUT_MS`, without aliases. Defaults and `tool-call.async` are unchanged. Older JDKs add a bounded batch pool. Existing durable single-call persistence semantics remain unchanged.
### Documentation
- [ ] `doc-needed`
- [ ] `doc-not-needed`
- [x] `doc-included`
Workflow, tool-use and configuration docs cover both APIs and renamed options.
### Was this patch authored or co-authored using generative AI tooling?
- [x] Yes
- [ ] No
Generated-by: Codex CLI 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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [api][runtime][java][python] Add non-durable async execution [flink-agents]
Posted by "sangkyoonnam (via GitHub)" <gi...@apache.org>.
sangkyoonnam commented on PR #1208:
URL: https://github.com/apache/flink-agents/pull/1208#issuecomment-6073396898
One interaction with #1182, which touches the same `__await__`. #1182 adds an `_is_cancellation` hook to `DurableFuture.__await__`, so an error it accepts leaves the handle unresolved instead of caching it. `_SingleDurableFuture` and `_GatherDurableFuture` return `is_java_interruption(error)` from it, and `_finalize_batch_execution` re-raises an interrupted durable child instead of recording it. This PR moves `__await__` into `AsyncFuture`, so the two conflict there: a trial merge of e2e37c4e with #1182's head dfa36e96 conflicts only in `python/flink_agents/api/runner_context.py`, at that line.
Whichever lands second, I think the ordinary side needs the same treatment to meet "Interruption/cancellation propagates without caching a terminal business failure". In Python, a callback interrupted from Java surfaces as a regular `Exception`, so today an ordinary handle caches it and `_BatchAsyncExecutionResult` records it as a per-item failure. Java already does: `AsyncFutureImpl` rethrows `InterruptedException` without caching, and `executeAllWithoutDurableState` rethrows an interrupted ordinary child. The Python counterpart would keep the hook in `AsyncFuture.__await__`, return `is_java_interruption` from `_SingleAsyncFuture` and `_GatherAsyncFuture`, and re-raise an interrupted ordinary child in `_BatchAsyncExecutionResult` before filling `outcomes`.
If #1182 goes in first, I can send those three changes as a follow-up against this PR's API, unless you'd rather fold them in here.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [api][runtime][java][python] Add non-durable async execution [flink-agents]
Posted by "wenjin272 (via GitHub)" <gi...@apache.org>.
wenjin272 commented on PR #1208:
URL: https://github.com/apache/flink-agents/pull/1208#issuecomment-6073648907
Thanks for catching this @sangkyoonnam. I’d missed the connection with #1182. Now that it’s merged, I’ll rebase this PR onto the latest main, preserve its interruption handling, and extend it to the ordinary async paths here.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [api][runtime][java][python] Add non-durable async execution [flink-agents]
Posted by "wenjin272 (via GitHub)" <gi...@apache.org>.
wenjin272 commented on code in PR #1208:
URL: https://github.com/apache/flink-agents/pull/1208#discussion_r4236800356
##########
runtime/src/main/java/org/apache/flink/agents/runtime/context/JavaRunnerContextImpl.java:
##########
@@ -222,25 +277,22 @@ private BatchExecutionPlan(int size) {
}
}
- private <T> List<Outcome<T>> executeAllWithoutDurableState(List<DurableCallable<T>> callables)
+ private <T> List<Outcome<T>> executeAllWithoutDurableState(List<Callable<T>> suppliers)
throws Exception {
- List<Callable<T>> suppliers = new ArrayList<>();
- for (DurableCallable<T> callable : callables) {
- suppliers.add(callable::call);
- }
List<Outcome<T>> outcomes = executeOutcomeSuppliers(suppliers).getOutcomes();
for (Outcome<T> outcome : outcomes) {
- if (outcome.isFailure() && outcome.getError() instanceof InterruptedException) {
- // Without a durable store there is nothing to leave pending, but a cancellation
- // signal folded into a failed Outcome must still propagate as an interruption
- // instead of being handed to the caller as an ordinary tool failure.
- Thread.currentThread().interrupt();
- throw (InterruptedException) outcome.getError();
- }
+ rethrowInterruption(outcome);
}
return outcomes;
}
+ private static void rethrowInterruption(Outcome<?> outcome) throws InterruptedException {
Review Comment:
Thanks, agreed. Fixed in [df726bde8](https://github.com/apache/flink-agents/commit/df726bde848d5d4068f774b4cecd77bbb7e83923) with a shared CancellationUtils classifier used by async handles, batch/durable finalization, routing and tool paths. It follows the cause chain for InterruptedException, ClosedByInterruptException and CancellationException, while excluding bare InterruptedIOException and network timeouts. Cancellation propagates without terminal caching or persistence as a business failure; only actual interruption restores the interrupt flag. Added direct, NIO and wrapped-signal regressions, including durable-state checks and packaged executor tests on JDK 17 and 21.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [api][runtime][java][python] Add non-durable async execution [flink-agents]
Posted by "eemario (via GitHub)" <gi...@apache.org>.
eemario commented on code in PR #1208:
URL: https://github.com/apache/flink-agents/pull/1208#discussion_r4228037899
##########
docs/content/docs/operations/configuration.md:
##########
@@ -134,10 +134,10 @@ Here is the list of all built-in core configuration options.
| `retry-wait-interval` | 1 | int | Base wait interval in seconds between retries. Uses exponential backoff: the actual wait time for the Nth retry is `retry-wait-interval * 2^(N-1)` seconds. For example, with default 1s, waits are 1s, 2s, 4s, etc. Retry count and total wait time are reported in `ChatResponseEvent` and recorded as metrics (`retryCount`, `retryWaitSec`) under the configured ChatModel resource name. |
| `chat.async` | true | boolean | Whether chat asynchronously for built-in chat action. |
| `tool-call.async` | true | boolean | Whether the built-in tool-call action runs each tool via durable async execution. |
-| `tool-call.parallelism` | os cpu count | int | In-flight concurrency for tool calls from one `ToolRequestEvent` batch when `tool-call.async` is enabled. `1` runs tools serially; values greater than `1` run a parallel durable batch with a sliding window of at most that many concurrent tool calls. On **Java**, concurrent in-batch execution requires **JDK 21+** (Continuation API); below JDK 21 the batch still runs but tool calls execute serially. **Python** uses the shared async `ThreadPoolExecutor` and runs batches concurrently regardless of JDK version. Increases in-flight external calls; after failover, unfinished tools may be submitted again — side-effecting tools should be idempotent or provide a reconciler. {{< hint warning >}}**Default is parallel** (`os cpu count`). Chat, RAG, and tool batches share one `num-async-threads` pool **per operator subtask** (all keys on that subtask). Built-in actions for a single key run one at a time, so chat
and a tool batch on the **same key** do not overlap in the usual chat → tool path; delay shows up mainly **across keys** on the same subtask. With defaults (`num-async-threads = 2× cores`, `tool-call.parallelism = cores`), one batch can use up to half the pool; several busy keys can still saturate it. Lower this value or increase `num-async-threads` on hot subtasks. {{< /hint >}} |
-| `tool-call.batch.timeout.ms` | -1 (disabled) | long (milliseconds) | Overall timeout for one parallel tool-call batch. Non-positive disables it. On timeout, completed slots keep their outcome; slots that started but did not finish are recorded as failures; slots that never started executing (for example, queued in a saturated pool) stay pending, so they are re-executed after recovery instead of recording a false failure. Timeout cancellation is best-effort; external side effects from unfinished tool calls may still complete, so side-effecting tools should be idempotent or provide a reconciler. On **Java**, only enforced on **JDK 21+**; on JDK 11 the batch fallback ignores this setting and runs to completion serially. **Python** enforces the deadline in the batch await loop. {{< hint warning >}}**Thread reclamation:** a timeout unblocks the batch but cannot interrupt a tool that is still running; its worker thread stays in the shared `num-async-threads` pool until th
e tool returns on its own, so a tool that never returns permanently reduces pool capacity. Bound blocking work inside the tool (for example an HTTP client read timeout) rather than relying on this timeout to free the thread.{{< /hint >}} |
+| `async.batch.parallelism` | os cpu count | int | Maximum concurrent calls in one `ctx.gather(...)` batch, including ordinary calls, durable calls, and built-in async tool calls. `1` runs calls sequentially. Actual concurrency is also limited by `num-async-threads`; lower this per-batch limit to leave capacity for other calls on the same subtask. Java and Python support batch concurrency on all supported JDK versions. |
Review Comment:
Question on the API contract: config keys are part of the public API surface — is a rename with no migration note the intended behavior here?
##########
runtime/src/main/java/org/apache/flink/agents/runtime/context/JavaRunnerContextImpl.java:
##########
@@ -75,35 +76,89 @@ protected <T> T resolveDurableAsync(DurableCallable<T> callable) throws Exceptio
return durableExecuteAsyncWithReconcile(callable, reconcileCallable);
}
}
- return durableExecuteCompletionOnly(callable, () -> executeAsyncCallable(callable));
+ return durableExecuteCompletionOnly(callable, () -> resolveAsync(callable::call));
}
private <T> T durableExecuteAsyncWithReconcile(
DurableCallable<T> callable, Callable<T> reconcileCallable) throws Exception {
return durableExecuteWithReconcile(
- callable, reconcileCallable, () -> executeAsyncCallable(callable));
+ callable, reconcileCallable, () -> resolveAsync(callable::call));
}
@Override
- protected <T> List<Outcome<T>> resolveDurableBatch(List<DurableCallable<T>> callables)
+ protected <T> List<Outcome<T>> resolveAsyncBatch(List<SingleAsyncFuture<T>> futures)
throws Exception {
- if (callables.isEmpty()) {
- return List.of();
+ List<DurableCallable<T>> durableCalls = new ArrayList<>();
+ for (SingleAsyncFuture<T> future : futures) {
+ if (future.getDurableCallable() != null) {
+ durableCalls.add(future.getDurableCallable());
+ }
}
- if (durableExecutionContext == null) {
- return executeAllWithoutDurableState(callables);
+ if (durableExecutionContext == null || durableCalls.isEmpty()) {
+ List<Callable<T>> suppliers = new ArrayList<>();
+ for (SingleAsyncFuture<T> future : futures) {
+ suppliers.add(future.getCallable());
+ }
+ return executeAllWithoutDurableState(suppliers);
Review Comment:
This new ordinary path exposes an existing JDK 21 batch-executor bug.
When a callback throws Error, CompletableFuture.join() wraps it in
CompletionException. AsyncFutureImpl.await() then treats that wrapper as an
ordinary Exception, marks the handle done, and caches it.
Reproducer:
var batch = ctx.gather(List.of(ctx.executeAsync(() -> {
throw new AssertionError("fatal");
})));
batch.await();
On the real multi-release JDK 21 path, the first await throws
CompletionException(cause=AssertionError), and the second await rethrows the same
cached wrapper. JDK < 21 instead propagates the original AssertionError without
caching it.
This contradicts the PR's "Java fatal Errors propagate" contract and lets
catch (Exception) accidentally swallow a fatal Error. Could the JDK 21 normal
and timeout outcome collectors unwrap CompletionException and rethrow Error
directly, with a packaged multi-release JDK 21 regression test?
##########
runtime/src/main/java/org/apache/flink/agents/runtime/context/JavaRunnerContextImpl.java:
##########
@@ -222,25 +277,22 @@ private BatchExecutionPlan(int size) {
}
}
- private <T> List<Outcome<T>> executeAllWithoutDurableState(List<DurableCallable<T>> callables)
+ private <T> List<Outcome<T>> executeAllWithoutDurableState(List<Callable<T>> suppliers)
throws Exception {
- List<Callable<T>> suppliers = new ArrayList<>();
- for (DurableCallable<T> callable : callables) {
- suppliers.add(callable::call);
- }
List<Outcome<T>> outcomes = executeOutcomeSuppliers(suppliers).getOutcomes();
for (Outcome<T> outcome : outcomes) {
- if (outcome.isFailure() && outcome.getError() instanceof InterruptedException) {
- // Without a durable store there is nothing to leave pending, but a cancellation
- // signal folded into a failed Outcome must still propagate as an interruption
- // instead of being handed to the caller as an ordinary tool failure.
- Thread.currentThread().interrupt();
- throw (InterruptedException) outcome.getError();
- }
+ rethrowInterruption(outcome);
}
return outcomes;
}
+ private static void rethrowInterruption(Outcome<?> outcome) throws InterruptedException {
Review Comment:
This only recognizes a top-level InterruptedException. The Python runtime
and ModelRoutingResolver also classify ClosedByInterruptException and a nested
InterruptedException as cancellation, while excluding bare
InterruptedIOException network timeouts.
With the new ordinary gather path, a callback that throws
ClosedByInterruptException is returned as Outcome.failure and cached on the
child handle; a later await rethrows the same cached exception instead of
retrying. The durable path can similarly persist it as a business failure.
Could AsyncFutureImpl.await(), this helper, and durable finalization share a
cause-chain interruption classifier, with direct, NIO, and wrapped-interruption
tests?
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [api][runtime][java][python] Add non-durable async execution [flink-agents]
Posted by "wenjin272 (via GitHub)" <gi...@apache.org>.
wenjin272 commented on code in PR #1208:
URL: https://github.com/apache/flink-agents/pull/1208#discussion_r4236799523
##########
runtime/src/main/java/org/apache/flink/agents/runtime/context/JavaRunnerContextImpl.java:
##########
@@ -75,35 +76,89 @@ protected <T> T resolveDurableAsync(DurableCallable<T> callable) throws Exceptio
return durableExecuteAsyncWithReconcile(callable, reconcileCallable);
}
}
- return durableExecuteCompletionOnly(callable, () -> executeAsyncCallable(callable));
+ return durableExecuteCompletionOnly(callable, () -> resolveAsync(callable::call));
}
private <T> T durableExecuteAsyncWithReconcile(
DurableCallable<T> callable, Callable<T> reconcileCallable) throws Exception {
return durableExecuteWithReconcile(
- callable, reconcileCallable, () -> executeAsyncCallable(callable));
+ callable, reconcileCallable, () -> resolveAsync(callable::call));
}
@Override
- protected <T> List<Outcome<T>> resolveDurableBatch(List<DurableCallable<T>> callables)
+ protected <T> List<Outcome<T>> resolveAsyncBatch(List<SingleAsyncFuture<T>> futures)
throws Exception {
- if (callables.isEmpty()) {
- return List.of();
+ List<DurableCallable<T>> durableCalls = new ArrayList<>();
+ for (SingleAsyncFuture<T> future : futures) {
+ if (future.getDurableCallable() != null) {
+ durableCalls.add(future.getDurableCallable());
+ }
}
- if (durableExecutionContext == null) {
- return executeAllWithoutDurableState(callables);
+ if (durableExecutionContext == null || durableCalls.isEmpty()) {
+ List<Callable<T>> suppliers = new ArrayList<>();
+ for (SingleAsyncFuture<T> future : futures) {
+ suppliers.add(future.getCallable());
+ }
+ return executeAllWithoutDurableState(suppliers);
Review Comment:
Thanks for catching this. Fixed in [df726bde8](https://github.com/apache/flink-agents/commit/df726bde848d5d4068f774b4cecd77bbb7e83923): both JDK 21 batch collectors now unwrap the CompletionException and rethrow the original Error, so it cannot be swallowed by catch (Exception) or cached as a business exception. Added packaged multi-release JDK 21 regressions for normal and timeout collection, with ordinary-exception controls; all four pass.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [api][runtime][java][python] Add non-durable async execution [flink-agents]
Posted by "wenjin272 (via GitHub)" <gi...@apache.org>.
wenjin272 commented on code in PR #1208:
URL: https://github.com/apache/flink-agents/pull/1208#discussion_r4236799047
##########
docs/content/docs/operations/configuration.md:
##########
@@ -134,10 +134,10 @@ Here is the list of all built-in core configuration options.
| `retry-wait-interval` | 1 | int | Base wait interval in seconds between retries. Uses exponential backoff: the actual wait time for the Nth retry is `retry-wait-interval * 2^(N-1)` seconds. For example, with default 1s, waits are 1s, 2s, 4s, etc. Retry count and total wait time are reported in `ChatResponseEvent` and recorded as metrics (`retryCount`, `retryWaitSec`) under the configured ChatModel resource name. |
| `chat.async` | true | boolean | Whether chat asynchronously for built-in chat action. |
| `tool-call.async` | true | boolean | Whether the built-in tool-call action runs each tool via durable async execution. |
-| `tool-call.parallelism` | os cpu count | int | In-flight concurrency for tool calls from one `ToolRequestEvent` batch when `tool-call.async` is enabled. `1` runs tools serially; values greater than `1` run a parallel durable batch with a sliding window of at most that many concurrent tool calls. On **Java**, concurrent in-batch execution requires **JDK 21+** (Continuation API); below JDK 21 the batch still runs but tool calls execute serially. **Python** uses the shared async `ThreadPoolExecutor` and runs batches concurrently regardless of JDK version. Increases in-flight external calls; after failover, unfinished tools may be submitted again — side-effecting tools should be idempotent or provide a reconciler. {{< hint warning >}}**Default is parallel** (`os cpu count`). Chat, RAG, and tool batches share one `num-async-threads` pool **per operator subtask** (all keys on that subtask). Built-in actions for a single key run one at a time, so chat
and a tool batch on the **same key** do not overlap in the usual chat → tool path; delay shows up mainly **across keys** on the same subtask. With defaults (`num-async-threads = 2× cores`, `tool-call.parallelism = cores`), one batch can use up to half the pool; several busy keys can still saturate it. Lower this value or increase `num-async-threads` on hot subtasks. {{< /hint >}} |
-| `tool-call.batch.timeout.ms` | -1 (disabled) | long (milliseconds) | Overall timeout for one parallel tool-call batch. Non-positive disables it. On timeout, completed slots keep their outcome; slots that started but did not finish are recorded as failures; slots that never started executing (for example, queued in a saturated pool) stay pending, so they are re-executed after recovery instead of recording a false failure. Timeout cancellation is best-effort; external side effects from unfinished tool calls may still complete, so side-effecting tools should be idempotent or provide a reconciler. On **Java**, only enforced on **JDK 21+**; on JDK 11 the batch fallback ignores this setting and runs to completion serially. **Python** enforces the deadline in the batch await loop. {{< hint warning >}}**Thread reclamation:** a timeout unblocks the batch but cannot interrupt a tool that is still running; its worker thread stays in the shared `num-async-threads` pool until th
e tool returns on its own, so a tool that never returns permanently reduces pool capacity. Bound blocking work inside the tool (for example an HTTP client read timeout) rather than relying on this timeout to free the thread.{{< /hint >}} |
+| `async.batch.parallelism` | os cpu count | int | Maximum concurrent calls in one `ctx.gather(...)` batch, including ordinary calls, durable calls, and built-in async tool calls. `1` runs calls sequentially. Actual concurrency is also limited by `num-async-threads`; lower this per-batch limit to leave capacity for other calls on the same subtask. Java and Python support batch concurrency on all supported JDK versions. |
Review Comment:
Thanks for raising this. The rename is intentional: we do not guarantee backward compatibility across 0.x releases, and these two options were only recently added and have not appeared in a release yet. I think we can rename them directly without deprecated aliases or a migration note.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [api][runtime][java][python] Add non-durable async execution [flink-agents]
Posted by "wenjin272 (via GitHub)" <gi...@apache.org>.
wenjin272 merged PR #1208:
URL: https://github.com/apache/flink-agents/pull/1208
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org