Hayhooks V2: durable execution for pipelines and A2A agents - #253
Open
mpangrazzi wants to merge 12 commits into
Open
Hayhooks V2: durable execution for pipelines and A2A agents#253mpangrazzi wants to merge 12 commits into
mpangrazzi wants to merge 12 commits into
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
All alerts resolved. Learn more about Socket for GitHub. This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored. |
mpangrazzi
force-pushed
the
hayhooks_v2
branch
from
August 12, 2026 09:14
0485782 to
683423f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack
Merge in order: #253, then #258, then #259. PR #258 adds durable A2A trace correlation; PR #259 adds its dashboard classification and presentation.
Durable execution and managed A2A Agents
This PR adds durable execution for Haystack 3 Pipelines and Agents. It accepts typed work, persists it before returning, runs it outside the request, and recovers it from safe checkpoints after a worker or process disappears.
Highlights
durable_revisiongate prevents incompatible queued or waiting work from resuming against changed code.See Hayhooks durable engine and Temporal for the capability and tradeoff comparison.
Portability
The durable engine can now be embedded through
hayhooks.durablewithout depending on Hayhooks server startup. The public surface exportsDurableRuntime,ExecutionStore,ExecutionStoreProvider, and the built-in memory and Redis providers while keeping Redis optional at import time.Standalone runtimes own and start only their attached deployments; they do not inspect the process-global pipeline registry or require private server-loader method flags. Runtime, deployment, provider, and store use one settings snapshot, conflicting settings fail before deployment, and provider replacement is locked once a provider or deployment candidate exists. The runtime owns provider shutdown.
See Embedding the runtime for the public lifecycle and configuration example.
Diff breakdown for reviewers
The PR is broad because it ships the engine together with its recovery tests, runnable examples, operations documentation, and A2A integration. Of the 13,109 additions, 6,013 (about 46%) are tests, examples, or documentation.
a2a_utils.pyreplaced by focused A2A modulesSuggested review order:
src/hayhooks/durable/engine.py,backend.py,store.py,redis.py, andreference.pyfor lifecycle and storage correctness.manager.py,context.py,adapters.py,runtime.py, andserver/durable/routes.pyfor execution and Haystack boundaries.server/a2a/durable_executor.pyandredis_task_store.pyfor the A2A-specific projection and recovery layer.Supported features
Durable REST execution
BasePipelineWrapperimplementsrun_durable()orrun_durable_async(). Hayhooks invokes that method for each durable execution with aDurableContextand typed Pydantic request.context.run_pipeline()/context.run_pipeline_async()for checkpointed Pipeline work, orcontext.run_agent()/context.run_agent_async()for Agent work.POST /{pipeline}/run-durableGET /{pipeline}/executions/{id}POST /{pipeline}/executions/{id}/cancelPOST /{pipeline}/executions/{id}/resumeIdempotency-Keyreplays the same operation safely and rejects reuse with different input.durable_revision, allowing queued and waiting work to be checked against checkpoint-relevant deployment code.Pipeline checkpoints
Pipeline wrappers opt in through
context.run_pipeline(..., checkpoint_at=[...])orcontext.run_pipeline_async(..., checkpoint_at=[...]).For every named boundary, Hayhooks asks Haystack to stop at a public
Breakpointand immediately persists the returnedPipelineSnapshotbefore that component executes. If Haystack exposes a snapshot with aPipelineRuntimeError, Hayhooks persists that snapshot too.On recovery, Hayhooks rebuilds the
PipelineSnapshot, passes it back to the Pipeline, and starts from the saved scheduler state. Haystack skips the already-completed upstream component visits; work after the last checkpoint is replayed.Agent checkpoints
Managed Agents use the public Haystack hook surface. Hayhooks installs synchronous and asynchronous versions of these hooks for the active durable execution:
before_runStatewhile keeping fresh per-run tools and hook context.before_llmafter_toolon_exitcontinue_run.after_runThe serialized Agent checkpoint excludes live
toolsandhook_context; the current deployment recreates them for the recovered run. Checkpoints and progress are saved together as a durable execution transition.Redis recovery
runnablefor queued work andlease-expiryfor active claims.TIME, optimistic transactions, and fenced transitions keep ownership safe across replicas.nonterminal,runnable, andlease_expirycounts.Managed long-running A2A Agents
AgentinA2APipelineWrapperis exposed as a durable A2A Agent. Hayhooks supplies the durable worker, queue, execution record, checkpointing, progress projection, and Redis integration.GetTaskand list requests project the latest durable state directly.Execution model
The lifecycle is a pure reducer over a compact execution control record:
The store atomically persists each reducer plan and its derived Redis indexes. The durable manager owns worker polling, lease heartbeats, retries, and shutdown draining; Haystack adapters own the Pipeline snapshot and Agent hook integration.
See the durable operations guide.
Validation