[Feature][runtime] Support durable replay for same-key inputs from multiple upstream instances
Los mantenedores suelen responder en 2 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- java, kafka
- Área
- backend, distributed-systems
Línea de trabajo
Start with the issue’s referenced OperatorStateManager.initOrIncSequenceNumber and the Kafka/Fluss lookup paths, then read the consistency documentation’s conditions for reusing saved records. Reproduce recovery with two upstream instances sending the same key and reversed interleaving, measuring Action/tool invocations and stateful Memory effects. Done means a designed and tested replay contract covers repeated failures and recovery checkpoints for both Kafka and Fluss, with documentation of prerequisites and fallback behavior.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Search before asking
- I searched the existing issues. #1301 tracks incorrect divergence detection for normal multi-Action execution; #1084 tracks event-occurrence key collisions. Neither restores the original input ordering across upstream channels.
Description
ActionStateStore reuse currently depends on replaying each business key's inputs in the same order. The operator assigns seqNum from a checkpointed per-key counter when it starts a top-level InputEvent; seqNum is not a stable source-record identifier.
When the same business key arrives from multiple upstream parallel instances, keyBy routes those inputs to the same downstream instance but does not establish a replay-stable order across the incoming channels. A failure can therefore assign a different seqNum to the same logical input.
This is a practical limitation for agents consuming merged streams or records distributed across multiple source partitions/upstream instances under the same agent key. Correcting #1301 avoids false invalidation for normal multi-Action execution, but does not eliminate this limitation.
The current consistency documentation already requires stable per-key input order. This issue requests support for the broader topology and a precise user-facing recovery contract, rather than claiming that the existing documentation guarantees it.
Example and impact
Take checkpoint C0 after seqNum=9 for key K. Two upstream instances then emit distinct records for K:
upstream 1: A, C
upstream 2: B, D
original execution:
seq=10: A
seq=11: B
seq=12: C
seq=13: D
completed ActionStates are persisted; failure before the next checkpoint
restore C0, with a different channel interleaving:
seq=10: B
seq=11: A
seq=12: C
seq=13: D
Both deliveries preserve each upstream channel's order, yet the per-key merged sequence differs. The lookup for B at seq=10 cannot find B's completion saved at seq=11. Cache-miss/divergence handling can invalidate the remaining saved suffix, causing completed work to run again.
Even when C returns to its old sequence number, blindly reusing its result is unsafe if its output or Memory updates depended on the earlier processing order. For example, A and B can set the same Memory field to different values, which C then reads.
- Model/tool calls can repeat despite having saved completions.
- If order changes at the first replayed input, reuse for that key's affected replay window can be lost.
- Changes only in the interleaving of different keys do not cause this issue.
- Parallelism or keyBy alone is not sufficient to trigger it: a key with a replay-stable ordered input path can still reuse saved state.
- This is about ActionState reuse and repeated external work; it is not a claim that all Flink checkpointed state or transactional sinks lose their guarantees.
Flink's dataflow documentation explains that redistribution preserves ordering within each sending/receiving subtask pair, not across all senders.
Proposed investigation
Define how agents should recover when same-key inputs originate from multiple channels. Possible directions include durably recording the accepted per-key input order and restoring it, or introducing stable input identity together with the state-dependency semantics required for safe reuse.
A stable input ID alone is insufficient for stateful Actions: recovering a result by ID must not replay Memory changes or outputs computed against a different preceding history. Likewise, disabling divergence protection would mask the mismatch rather than solve it.
A substantial recovery-model change should receive a separate design discussion before implementation.
Acceptance criteria
- Add a controlled recovery test with at least two upstream instances emitting distinct inputs for the same agent key, deliberately reverse their interleaving after failure, and measure actual Action/tool invocations.
- Define and implement a supported replay contract that preserves safe reuse of saved completed work for that topology. If ordering restoration is selected, verify that the accepted history is restored before applying dependent Memory updates.
- Test stateful Actions whose results depend on preceding same-key inputs, not just stateless input-to-output functions.
- Cover repeated failures and checkpoints taken while recovery is progressing; validate both Kafka and Fluss backends.
- Keep different keys isolated and retain the existing ordered-input behavior.
- Document supported topologies, ordering prerequisites, and fallback/re-execution behavior for inputs outside the supported contract. Until broader support exists, explain concretely that keyBy alone does not satisfy the ordering prerequisite.
- Do not weaken the genuine divergence safeguards tracked in #1301.
Version and validation status
Flink Agents 0.4-SNAPSHOT; source analysis used audit baseline 47daff57b5c4189c80dd7037660f2a7832270879, including OperatorStateManager.initOrIncSequenceNumber and the Kafka/Fluss lookup paths.
The sequence-number dependency and invalidation paths were inspected. The separate #1301 prototype exercised controlled changed-input histories through real operator snapshot/restore with mocked broker transport. A live multi-upstream network-shuffle failover reproduction for this issue has not yet been run.
Are you willing to submit a PR?
- I'm willing to submit a PR!
- Lenguaje dominante
- Java
- Estrellas
- 497
- Forks
- 193
- Merge medio
- 2 d 21 h
- PR fusionados (30 d)
- 68
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de apache/flink-agents
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
apache/flink-agents#1480 ·
Los mantenedores suelen responder en 2 días
-
[Tech Debt] Python cross-language e2e tests hardcode 0.4-SNAPSHOT tests jar and silently skipAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
apache/flink-agents#1476 ·
Los mantenedores suelen responder en 2 días
-
[Bug][runtime] Trace Log loggers fail on a string trace-log.pretty-print valuePosiblemente ocupada @Zhuoxi2000 la tomó hace 3 días. AbiertoaffectVersion/0.4.0 bug fixVersion/0.4.1 fixVersion/1.0.0 priority/major
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
apache/flink-agents#1463 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 2 días
-
Dificultad 4/5 1-2 días Aptitud para principiantes 45/100
apache/flink-agents#1482 ·
Los mantenedores suelen responder en 2 días
-
[java][python][Azure OpenAI] Align token limit handling with max_completion_tokensPosiblemente ocupada @samarthputhraya la tomó hoy. AbiertoaffectVersion/0.4.0 bug priority/major
apache/flink-agents#1478 · 2 comentarios · 1 asignado ·
Los mantenedores suelen responder en 2 días
Todos los issues de apache/flink-agents
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
federicoiosue/Omni-Notes#1044 ·
-
Industrial Center Text TypoAbiertoBug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Terraform releases proxy leaves a temp folder behind on every cache refreshPosiblemente ocupada @dhananjay6561 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
terrakube-io/terrakube#4069 · 1 comentario ·
Los mantenedores suelen responder en 1 día