feat: implement OpenAICompatibleModel with native list tool return - #116
Merged
Conversation
Subclass OpenAIChatModel to emit native list tool return content instead of JSON strings for OpenAI-compatible models (GLM-5, vLLM). - OpenAICompatibleModel(OpenAIChatModel) with _map_user_message override - Profile flag openai_chat_tool_return_as_list (default False) - openai_* kwarg passthrough with string→bool coercion - ImportModelConfig support with base_url, api_key, tool_return_as_list - 25 tests covering all spec scenarios Implements: openspec/changes/openai-compatible-native-tool-return/
|
Warning Gemini encountered an error creating the review. You can try again by commenting |
Move profile override validation before OpenAIProvider init so invalid kwargs raise TypeError without requiring OPENAI_API_KEY credentials. Fixes CI failure in test_import_model_config_non_openai_kwarg_raises.
Million-mo
merged commit Jul 6, 2026
6be1507
into
wolf1069b:feat/openai-compatible-native-tool-return
8 checks passed
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.
Summary
Implements the code for the OpenAI-Compatible Native Tool Return spec defined in PR #115.
Changes
src/agentpool/models/openai_compatible.py—OpenAICompatibleModel(OpenAIChatModel)subclass:_map_user_message()to emitlist[ChatCompletionContentPartTextParam]for tool returns with list content (when flag enabled)openai_chat_tool_return_as_listprofile flag (defaultFalsefor backward compat)openai_*kwarg passthrough with string→bool coercion for known boolean keysImportModelConfigsupport withbase_url,api_key,tool_return_as_listconstructor params_coerce_profile_value()helper and_OPENAI_BOOL_PROFILE_KEYS/_OPENAI_PROFILE_FIELDSconstantssrc/agentpool/models/__init__.py— ExportOpenAICompatibleModelandOpenAICompatibleModelProfiletests/models/test_openai_compatible.py— 25 tests covering all spec scenarios:_coerce_profile_valuehelper_map_user_messagefull coverage (flag disabled delegation, list string/non-string items, string content, empty list, SystemPromptPart, RetryPromptPart, mixed messages)ImportModelConfigintegration (YAML resolution, profile overrides, TypeError)Verification
ruff check: All checks passed ✓ruff format --check: Formatted correctly ✓mypy: Success, no issues found ✓pytest: 25 passed, 0 failed ✓Spec Reference
Implements:
openspec/changes/openai-compatible-native-tool-return/tasks.mdCloses #112