Skip to content

feat(anthropic-payload): add build_batches_request_params (v0.40.1 → v0.41.0) (L334)#85

Merged
cipher813 merged 1 commit into
mainfrom
feat/anthropic-batches-request-params
May 28, 2026
Merged

feat(anthropic-payload): add build_batches_request_params (v0.40.1 → v0.41.0) (L334)#85
cipher813 merged 1 commit into
mainfrom
feat/anthropic-batches-request-params

Conversation

@cipher813
Copy link
Copy Markdown
Owner

Summary

Adds build_batches_request_params — a Batches-API-shaped sibling of build_messages_payload. Returns {custom_id, params} ready to splat into messages.batches.create(requests=[...]). The embedded params dict runs through validate_payload, so the server-tool ⊥ assistant-prefill invariant covers Batches consumers too.

Differs from build_messages_payload

  1. Optional system prompt (judge batches inline rubric into user content)
  2. No cache_control by default (Batches discounts 50% — marginal cache value small)
  3. Explicit tool_choice (forced tool calls are dominant Batches use case)

Why

ROADMAP L334 — alpha-engine-research is the second consumer of anthropic_payload, but its actual raw-SDK call surface is Batches (messages.batches.create), not synchronous messages.create. Existing chokepoint didn't fit; this PR extends the substrate to cover both API shapes from one validated chokepoint.

Part 1 of 2. Part 2 = ae-research PR migrating evals/judge.py::build_judge_batch_request + lib pin bump.

Test plan

  • Suite green: 899 passed
  • 6 new batches-specific tests including the server-tool ⊥ prefill invariant via batches path
  • ae-research migration PR validates the chokepoint shape end-to-end

🤖 Generated with Claude Code

…v0.41.0) (L334)

Adds `build_batches_request_params` — a Batches-API-shaped sibling of
`build_messages_payload`. Returns `{custom_id, params}` ready to splat
into `messages.batches.create(requests=[...])`. The embedded `params`
dict runs through `validate_payload`, so the server-tool ⊥ assistant-
prefill invariant covers Batches consumers too — a future judge call
that mixes `web_search` with a prefill won't reach HTTP 400.

Differs from `build_messages_payload` along three axes the judge-batch
path requires:

1. **Optional system prompt.** Synchronous callers nearly always have a
   static system; judge batches inline the rubric into user content and
   have no system block. `system_prompt=None` default emits no system.
2. **No cache_control by default.** Batches API discounts 50% before
   prompt caching applies — marginal cache value is small enough that
   the existing judge path opts out. `cache_system=False` default;
   opt-in for large repeated system prompts.
3. **Explicit tool_choice.** Forced tool calls (`{"type": "tool",
   "name": ...}`) are the dominant Batches use case (structured output
   via a known schema). Pass `tool_choice` directly rather than
   smuggling through `extra`.

Lib version: v0.40.1 → v0.41.0 (minor bump — additive new function).

Tests: 6 new in `test_anthropic_payload.py`:
- `test_build_batches_request_params_judge_shape` (replicates ae-research
  evals/judge.py::build_judge_batch_request shape)
- `test_build_batches_request_params_with_system_prompt_no_cache_default`
- `test_build_batches_request_params_with_system_prompt_cache_opt_in`
- `test_build_batches_request_params_validates_server_tool_prefill_invariant`
- `test_build_batches_request_params_no_system_no_tools_minimal`
- `test_build_batches_request_params_extra_merges_into_params`

ROADMAP: **L334** part 1/2 — lib substrate. Part 2 = alpha-engine-research
PR migrating `evals/judge.py::build_judge_batch_request` to use the new
helper + bumping the lib pin.

Suite: 899 passed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@cipher813 cipher813 merged commit 97a1c2a into main May 28, 2026
6 checks passed
@cipher813 cipher813 deleted the feat/anthropic-batches-request-params branch May 28, 2026 16:32
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.

1 participant