fix(anthropic): Use recommended assistant prompt for consistent json formatting#85
Merged
Merged
Conversation
e72e46d to
1f6b6d5
Compare
monkeypants
approved these changes
Feb 3, 2026
monkeypants
left a comment
Contributor
There was a problem hiding this comment.
hey, if it works ... :)
d3cc69f to
01ca2e4
Compare
Base automatically changed from
feat/anthropic-ks-structured-output-1
to
master
February 3, 2026 21:57
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.
Follows #83. Replaces #84. Ref #60
The initial aim here was to utilise the support for structured output available in the anthropic (and other) APIs. This turned out to be not so useful (or possible) due to the reasons outlined at #60 (comment) .
Instead, this PR uses the method identified by anthropic for increasing the consistency of return types (basically, starting the result in the assistant prompt with your code, then concatenating that to the result).
I also found that we were failing after only one try (failing fast) with our query - which surprised me (I don't remember why we had a fail fast that only executed once in temporal), so I've switched that to a default with a retry of 4.
With this change, I've run 5 of 5 DPP generations successfully (without any retries, though I suspect they will occasionally happen due to invalid json).