[examples] Quickstart process_chat_response fails fast on malformed JSON#811
Merged
Conversation
…pache#780) Replace the log-and-drop except block in the Python quickstart sample with fail-fast behavior so a malformed LLM response surfaces the dropped input instead of silently producing no output. Document production alternatives (error sentinel, error event, raise) and aligns with the Java samples. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Apply the same fail-fast fix to table_review_analysis_agent and product_suggestion_agent, which shared the log-and-drop pattern. Remove the now-unused logging imports. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ache#780) The Java samples already fail fast; add the same explanatory comment as the Python samples so the choice and production alternatives are documented in ReviewAnalysisAgent, TableReviewAnalysisAgent and ProductSuggestionAgent. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Linked issue: #780
Purpose of change
The quickstart
process_chat_responsesample caught every exception, logged it, and emitted noOutputEvent. A malformed LLM response then silently produced fewer outputs than inputs with no surface (DLQ event, error event, metric) for downstream operators to detect the missing record — a copy-paste anti-pattern for the recommended learning sample.try/except: log()with fail-fast in the Python quickstart agents (review_analysis_agent,table_review_analysis_agent,product_suggestion_agent); a parse error now propagates and fails the agent. Remove the unusedloggingimports.Tests
Existing ut & e2e; quickstart examples run unchanged on valid responses and now fail loudly on malformed JSON.
API
no
Documentation
doc-neededdoc-not-neededdoc-included