hir-123: swap fetch() to @anthropic-ai/sdk in triageReplyLLM#17
Open
jaredzwick wants to merge 1 commit intopypesdev:hir-120/warm-reply-triagefrom
Open
hir-123: swap fetch() to @anthropic-ai/sdk in triageReplyLLM#17jaredzwick wants to merge 1 commit intopypesdev:hir-120/warm-reply-triagefrom
jaredzwick wants to merge 1 commit intopypesdev:hir-120/warm-reply-triagefrom
Conversation
Replaces the direct fetch() call to api.anthropic.com with the official @anthropic-ai/sdk client. Same input/output contract, same model + prompt + heuristic fallback, same never-throws guarantee. Tests now mock the SDK module instead of overriding globalThis.fetch. Follow-up from CTO review on HIR-122 / PR pypesdev#14, founder pre-approved.
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.
Follow-up from CTO review on HIR-122 for #14. Founder pre-approved deferring the SDK swap out of the original PR.
Summary
fetch()againsthttps://api.anthropic.com/v1/messageswithnew Anthropic({ apiKey }).messages.create({...})from@anthropic-ai/sdk.triageReplyLLM: still returnsTriageResult | null, still validates intent against the enum, still clamps confidence, still wrapped in the same try/catch so it never throws.ANTHROPIC_MODELenv /claude-haiku-4-5-20251001default), sameTRIAGE_PROMPT, same heuristic fallback path — none of those move.@anthropic-ai/sdkmodule directly viavi.mock+vi.hoistedinstead of overridingglobalThis.fetch. All 14replyTriagecases keep their original assertions.Stacked on #14 — base branch is
hir-120/warm-reply-triage. Will rebase tomainafter #14 merges.Out of scope (per HIR-123)
parseLLMJson.Test plan
pnpm test:int— 109 passed, 1 skipped. The unrelatedapi.int.spec.tsPayload-secret env failure exists on the base branch too.npx tsc --noEmit— clean.