anthropic client + interleaved thinking support #788
Closed
mikasenghaas wants to merge 24 commits intooverhaul-results-savingfrom
Closed
anthropic client + interleaved thinking support #788mikasenghaas wants to merge 24 commits intooverhaul-results-savingfrom
mikasenghaas wants to merge 24 commits intooverhaul-results-savingfrom
Conversation
21 tasks
Member
Author
|
merged in #897 |
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.
Description
This PR adds support for Anthropic clients and interleaved thinking
AsyncOpenAI | AsyncAnthropicin public-facing environment methodsvf.Clientwhich maps between a normalized message, response, and tool types and the client-native typesEnvironment.set_interleaved_thinkingwhich passes the thinking flag to the client (e.g. OAI clients do a best-effort parsing of reasoning content)Tested Features
uv run vf-eval alphabet-sort -n1 -r1 -v -d -m Qwen/Qwen3-4B-Instruct-2507 -b http://localhost:8000/v1 -x '{"interleaved_rollouts": true}'Client Interface
The
vf.Clientwraps a native client and asks it to implement normalizers to enable a standard way to obtain aResponse. In particular, the following four methods have to be implementedvf.Messagesprompt to a client-native prompts (to_native_prompt)get_native_response)raise_from_native_response)vf.Response(from_native_response)In principle, we could continue to use the OAI-types as our normalizing type system (this would be less breaking), however there are some features from other clients that are difficult/ impossible to bake into the OAI types, and so it seems natural to define a custom type which supports the union of all features.
So far, we implement the following clients:
OpenAICompletionClientOpenAIChatCompletionClientOpenAIChatCompletionTokenClientAnthropicCompletionClientAnthropicMessagesClientThis list should be easily extensible to more client and API types in the future, such as OAI responses.
Backwards compatibility
oai_toolsis converted totool_defswherever possibleCustomBaseModelwhich allows dict-like access as to not break environments which return messages (e.g. BFCL v3)Brealing:
oai_toolsis deprecated. Environments whichoai_toolsinsetup_statebreak silently becaus the environment doesn't read fromoai_toolsanymore.Type of Change
Testing
uv run pytestlocally.Checklist
Additional Notes