[STG-2515] feat(evals): anthropic_sdk bare-loop harness adapter#2339
Open
shrey150 wants to merge 3 commits into
Open
[STG-2515] feat(evals): anthropic_sdk bare-loop harness adapter#2339shrey150 wants to merge 3 commits into
shrey150 wants to merge 3 commits into
Conversation
c946bcf to
6295a5d
Compare
a7e0668 to
e48ccaa
Compare
|
6295a5d to
225e69a
Compare
e48ccaa to
e3cab93
Compare
225e69a to
1fabf2b
Compare
e3cab93 to
f41f73f
Compare
1fabf2b to
ef383c4
Compare
f41f73f to
ecb6e11
Compare
ef383c4 to
c02cd46
Compare
ecb6e11 to
ad0a3c3
Compare
c02cd46 to
baf8b91
Compare
ad0a3c3 to
b87d6b6
Compare
Registers --harness anthropic_sdk: a hand-rolled tool_use loop via @anthropic-ai/sdk — the TS twin of the Python 'while stop_reason == "tool_use"' loop that dominates real-world Anthropic usage (and of the Modal sandbox template's agent.mjs). No retries, no planning, no memory — deliberately; the bareness is the instrument. Anthropic models only (prefix stripped, mismatches rejected). Step cap defaults to the shared 40 (EVAL_ANTHROPIC_SDK_MAX_STEPS override), with the cap surfaced as the stop reason when it binds. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…tive abort option anthropicSdkRunner only checked `signal?.aborted` between loop iterations, so an abort during an in-flight messages.create() left that request running to completion instead of cancelling it. Pass the signal through as the SDK's own RequestOptions.signal (fetch-style abort), which the raw @anthropic-ai/sdk client supports as messages.create(body, opts). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Drops dated-event references from the module docblock and rephrases the abort-wiring comment as a present-tense statement of the constraint. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
baf8b91 to
1fe1fb5
Compare
b87d6b6 to
7d73972
Compare
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.
What
Part 3 of 5 — stacked on #2338 (
vercel_ai_sdk) (base:shrey/evals-harness-vercel-ai-sdk; GitHub shows only this PR's delta). When the parent merges, retarget this PR's base and rebase.Registers
--harness anthropic_sdk: a hand-rolledtool_useloop via@anthropic-ai/sdk— the TS twin of the Pythonwhile stop_reason == "tool_use"loop that dominates real-world Anthropic usage (37.5M PyPI dl/wk) and of the Modal sandbox template'sagent.mjs. No retries, no planning, no memory — deliberately: the bareness is the instrument.anthropic/prefix stripped; other providers rejected loudly).EVAL_ANTHROPIC_SDK_MAX_STEPSoverride; when the cap binds it's surfaced as the stop reason.reasoning; usage summed across turns.@anthropic-ai/sdkdependency (pinned 0.39.0, matching packages/core) — this PR carries its own lockfile delta.clientinjection seam (messages.createmock).External harnesses design + usage:
packages/evals/README.md#external-harnesses(in #2337). Linear: STG-2515.Comparability fix (2026-07-09 audit)
Wired the caller's
AbortSignalinto@anthropic-ai/sdk's native abort option (messages.create(body, { signal })) instead of only pollingsignal?.abortedbetween loop iterations — previously an abort mid-loop left an already-in-flightmessages.create()call running to completion instead of cancelling the HTTP request. One new test asserts the signal is forwarded as-is to the client.(anthropic_sdk's
step cap reached (N)stop-reason shape was already correct here — it's the reference shape vercel_ai_sdk (#2338) and openai_agents_sdk (#2340) were fixed to match, per the same audit.)E2E Test Matrix
Live smoke ran on the pre-split combined branch (content identical to this stack's tip — verified by diff); results transplanted, not rerun.
evals run b:webtailbench --harness anthropic_sdk -m anthropic/claude-haiku-4-5-20251001 -l 1 -t 1 -c 1(local build, real ANTHROPIC + GEMINI keys, local Chrome via browse CLI)step cap reached (40)). 40browsetool calls recorded; trajectory persisted; verifier graded:outcomeSuccess=false,processScore=0.29, 5 rubric criteria, no verifierError. Usage: 172k in / 2.6k out tokenspnpm exec vitest run(this branch)Test Files 51 passed, Tests 376 passed— addsanthropicSdkRunner.test.ts(multi-turn loop threading assistant/tool_result messages, tool_use → browse execution, step-cap stop reason, usage summing, model-prefix validation, SDK-error folding)tsc --noEmit+ prettier + eslintpnpm exec vitest run(this branch, post-fix)Test Files 51 passed, Tests 379 passed— adds the AbortSignal-forwarding testmessages.create's options arg unchangedpnpm -w exec tsc --noEmit+ prettier + eslint (post-fix)No changeset:
packages/evalsis private.🤖 Generated with Claude Code