Skip to content

fix(anthropic): Use recommended assistant prompt for consistent json formatting#85

Merged
absoludity merged 3 commits into
masterfrom
feat/anthropic-ks-structured-output-2b
Feb 3, 2026
Merged

fix(anthropic): Use recommended assistant prompt for consistent json formatting#85
absoludity merged 3 commits into
masterfrom
feat/anthropic-ks-structured-output-2b

Conversation

@absoludity

@absoludity absoludity commented Feb 2, 2026

Copy link
Copy Markdown
Collaborator

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).

@absoludity absoludity force-pushed the feat/anthropic-ks-structured-output-2b branch from e72e46d to 1f6b6d5 Compare February 2, 2026 02:39
@absoludity absoludity marked this pull request as ready for review February 2, 2026 03:33
@absoludity absoludity changed the title Concatenate assistant prompt when it's a brace. fix(anthropic): Use recommended assistant prompt for consistent json formatting Feb 3, 2026

@monkeypants monkeypants left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey, if it works ... :)

@absoludity absoludity force-pushed the feat/anthropic-ks-structured-output-2b branch from d3cc69f to 01ca2e4 Compare February 3, 2026 21:57
Base automatically changed from feat/anthropic-ks-structured-output-1 to master February 3, 2026 21:57
@absoludity absoludity merged commit 16fcae2 into master Feb 3, 2026
@absoludity absoludity deleted the feat/anthropic-ks-structured-output-2b branch February 3, 2026 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants