Repository navigation
feat(effect-ai): AnthropicLanguageModel over /anthropic/v1/messages (phase 4) - #96
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 07c2a25896
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
07c2a25 to
af7dcb2
Compare
…orced JSON tool with thinking
…-tool prose, reject unsupported forced tool choices
af7dcb2 to
066b79d
Compare
Merge activity
|

Summary
Phase 4 of
packages/foundry-effect-ai/docs/PLAN.md:AnthropicLanguageModelover Foundry's/anthropic/v1/messages, withinternal/anthropic-messages/(schema, request, response, stream) andinternal/models/anthropic.ts.anthropic-version: 2023-06-01; fixtures pin it as a golden header.configtakesmax_tokensandthinkingunder their wire names.thinkingis sent as given (adaptive,enabledwith a budget, ordisabled). Thinking blocks keep their signature (redacted ones their data) underfoundry-anthropicand replay in order.rejectsForcedToolUsein the model list (Opus 5.5, Sonnet 5.5) sendoutput_config.format. All other models get an injected JSON tool, forced by name when it is the only tool, oranyalongside application tools, with parallel tool use disabled. The tool's input becomes the only text. In JSON-tool mode, prose beside any tool call is dropped, so an intermediate application tool turn still works withallowEmpty. With thinking on, the JSON tool is offered withauto, because thinking rejects forced tool use. An application tool whose name collides with the JSON tool fails withToolConfigurationError.required, a named tool,oneOfwithrequired) fail withToolConfigurationErrorbefore sending when thinking is on or the model rejects forced tool use (Opus and Sonnet 5.5).eager_input_streamingis never sent. Stream tool input is collected frominput_json_deltaand parsed atcontent_block_stop.Tool.Strict) get the Anthropic codec schema andstrict: true. Their input is normalized for Toolkit, and the raw input is kept in metadata so replay sends what the model produced. Tools are non-strict by default, as in the Foundry-tested AI SDK adapter.max_tokensdefaults to each catalog model's output limit, or 4096 for a raw target that isn't in the catalog.system. Foundry's support for system messages mid-conversation is unverified.error(SSE or an HTTP 200 body) fails with a typed reason:rate_limit_error→RateLimitError,billing_error→QuotaExhaustedError,invalid_request_error→InvalidRequestError, anything else →InternalProviderError. A stream that ends beforemessage_stopfails withInvalidResponseError, and reading stops atmessage_stop. A tool call cut off bymax_tokensis dropped and the finish reportslength, in both modes: the stream holds the last tool call until the next block starts or the stop reason is known.Matrix
The
AnthropicLanguageModelrow has no todos:text,stream,json,tools,stream-tools,json-tools,image,reasoning,stream-truncated,stream-error,json-native-claude-sonnet-5.5.claude-haiku-4.5; reasoning cells usethinking: { type: 'enabled', budget_tokens: 1024 }, since Haiku 4.5 predates adaptive thinking. The recordedtoolsandstream-toolsfirst turns carry signed thinking, and the second request replays it.json-native-claude-sonnet-5.5runs the sharedjsonprogram on Sonnet 5.5 withthinking: { type: 'adaptive' }, and checks offline that the request hasoutput_config.formatand notool_choice.stream-truncatedcuts the recorded stream aftermessage_delta(stop reason already known), so it must not finish.stream-errorreplays an in-bandoverloaded_error.Checks
pnpm run verifypasses.pnpm run test:live:effect: all 9 Anthropic live cells pass. In the full run, OpenAI'sreasoningcell failed once becausegpt-6-lunareturned no reasoning summary, and passed on an isolated rerun. This PR doesn't touch OpenAI code.generateObjectreturns the object through theautoJSON tool. A strict tool with a tuple and an optional field works through Foundry without ananthropic-betaheader, and the raw input is kept for replay. Offline probes confirmed themax_tokenscut-off behavior in both modes.Deferred
InvalidUserInputError; provider-defined tools fail withInvalidRequestError.output_config.effortand the adaptive thinkingdisplayoption aren't exposed; they can be added when a cell needs them.anthropic-betaheaders are sent.cache_controlmarkers aren't forwarded, and content prepopulated inmessage_startis ignored. Both are recorded in PLAN.md.