fix(hackathon-llm): parse diagnostics and tolerant JSON extraction - #36
Merged
Merged
Conversation
… output
LlmExtractor now returns { value, meta } so the adapter can report the
finish reason, content length and a fixed parse-failure code per attempt
without ever exposing model content. The safe logger re-validates them.
…pped output When a direct parse fails, scan for the first balanced object (respecting strings and escapes) and use it, reporting parseFailure prose-around with recovered true. The value still goes through validateExtraction unchanged.
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.
Summary
This is the fourth production smoke-test follow-up for change 3,
hackathon-analysis. After #35,tokenized-stocksstill failed. The new diagnostics showed that both models' outputs failed to parse:Neither the validator nor snippet matching was involved. The same page parses fine locally, even through the real
createWorkersAiExtractorwith a REST-backedrun. So the cause only occurs in production, either in the Worker's page text or in the binding output, and it can't be seen because content is never logged.Changes
src/domain/ports.ts,src/adapters/llm/workers-ai-extractor.ts,src/domain/usecases/analyze-hackathon.ts,src/domain/errors.ts,src/adapters/log/safe-logger.ts):LlmExtractor.extractnow returns{ value, meta }.metaholds:finishReason: a short token, otherwiseother.contentLength.parseFailure: one ofno-content,unterminated,prose-around,not-json,non-object.recovered.metais added to each attempt in thehackathon-jobfailure log.src/adapters/llm/workers-ai-extractor.ts):{...}is extracted, respecting strings and escapes.prose-aroundwithrecovered: true.validateExtraction.Review
A bounded review ran at medium risk, with the reliability lens over all 11 changed paths. It found no severe findings.
Deferred warning (R3-001): recovery tries only the first balanced span. Prose such as
Here is {the result}: {...}yieldsnot-jsoninstead of recovering the later object, and no test covers it. If it happens in production, the new diagnostics will show it.Tests
🤖 Generated with Claude Code