feat: Enhance agent snapshot serialization with error handling for non-serializable inputs#11108
Merged
bogdankostic merged 2 commits intomainfrom Apr 16, 2026
Merged
feat: Enhance agent snapshot serialization with error handling for non-serializable inputs#11108bogdankostic merged 2 commits intomainfrom
bogdankostic merged 2 commits intomainfrom
Conversation
…n-serializable inputs
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Collaborator
Coverage Report for CI Build 24448007183Coverage increased (+0.02%) to 92.856%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
1 task
shaun0927
added a commit
to shaun0927/haystack
that referenced
this pull request
Apr 16, 2026
…ialized The fallback added for agent snapshot serialization errors preserved the original runtime failure, but it could also replace the entire chat_generator or tool_invoker payload with an empty dict. That made the saved snapshot impossible to resume even when only a runtime-only field such as a streaming callback was non-serializable. This change narrows the fallback behavior: Haystack now retries those component inputs field-by-field and omits only the fields that cannot be serialized, preserving resumable fields like messages, state, and tools. A regression test covers resuming from a tool-invoker snapshot created with a non-serializable runtime callback. Constraint: Must preserve the original deepset-ai#11108 goal of not masking the real runtime error Rejected: Keep saving `{}` and document snapshots as non-resumable | breaks the existing resume contract more than necessary Confidence: high Scope-risk: narrow Reversibility: clean Directive: If agent snapshot fallback behavior changes again, verify both error preservation and snapshot resumability Tested: hatch -e test run pytest test/components/agents/test_agent_breakpoints.py -k 'resume_from_tool_invoker' -q Tested: hatch -e test run pytest test/core/pipeline/test_breakpoint.py -k 'create_agent_snapshot' -q Tested: hatch run fmt-check haystack/core/pipeline/breakpoint.py test/components/agents/test_agent_breakpoints.py Not-tested: Full unit suite and integration suite Related: deepset-ai#11126
7 tasks
shaun0927
pushed a commit
to shaun0927/haystack
that referenced
this pull request
Apr 21, 2026
…puts fail to serialize Address the Copilot review on deepset-ai#11127: when every field of a chat_generator or tool_invoker input fails to serialize, _serialize_agent_component_inputs previously returned a bare `{}`. The downstream `_deserialize_value_with_schema` rejects `{}` with DeserializationError, which would silently re-introduce the exact non-resumable snapshot behavior the fix was meant to prevent (e.g. when resuming from a ToolBreakpoint where the sub-component's inputs are not strictly required). The helper now always returns a structurally valid `{"serialization_schema", "serialized_data"}` pair. When all fields are omitted the payload degrades to the schema-valid empty object (`{"type": "object", "properties": {}}` + `{}`), which deserializes back to `{}` without raising. Existing unit tests in TestCreateAgentSnapshot are updated to assert the new empty-but-valid payload shape, and a new test verifies that the all-fields-fail payload round-trips through `_deserialize_value_with_schema` without raising. The release note is extended to describe the empty-payload edge case. Constraint: Must preserve the original deepset-ai#11108 goal of not masking the real runtime error Constraint: Must keep the narrower field-by-field fallback from the previous commit intact Rejected: Keep returning bare `{}` and document snapshots as non-resumable in this edge case | regresses the snapshot resume contract in the very scenario the previous commit promised to preserve Rejected: Fall back to a different marker payload (e.g. string sentinel) | breaks downstream deserializer's object/properties contract and would require changes outside the fallback helper Confidence: high Scope-risk: narrow Reversibility: clean Directive: If agent snapshot fallback behavior changes again, verify both DeserializationError is not raised on the empty-fields case and that the helper never returns a bare `{}` Tested: hatch -e test run pytest test/core/pipeline/test_breakpoint.py -k 'create_agent_snapshot' -q Tested: hatch -e test run pytest test/components/agents/test_agent_breakpoints.py -k 'non_serializable_runtime_callback' -q Tested: hatch -e test run pytest test/components/agents/test_agent_breakpoints.py -k 'resume_from_tool_invoker and not new_breakpoint' -q Tested: hatch run fmt-check haystack/core/pipeline/breakpoint.py test/core/pipeline/test_breakpoint.py test/components/agents/test_agent_breakpoints.py Tested: hatch run test:types haystack/core/pipeline/breakpoint.py Not-tested: Full unit suite and integration suite Related: deepset-ai#11126
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.
Related Issues
_create_agent_snapshotto be more robust towards errors just like_create_pipeline_snapshot#10642Proposed Changes:
_create_agent_snapshotcalled_serialize_value_with_schema()without error handling. If serialization failed (e.g. due to non-serializable objects), the resultingSerializationErrorwould mask the real pipeline runtime error (e.g.PipelineRuntimeError).This PR wraps each
_serialize_value_with_schema()call forchat_generatorandtool_invokerinputs in try-except blocks. On failure, a warning is logged and an empty dictionary is used as a fallback, matching the existing pattern in_create_pipeline_snapshot.How did you test it?
Added three unit tests.
Notes for the reviewer
Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.