- 
                Notifications
    You must be signed in to change notification settings 
- Fork 32
Rename metadata field to litellm_extra_body and add custom config support #837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: openhands <[email protected]>
Co-authored-by: openhands <[email protected]>
The mock LLM object in condenser tests was still using the old 'metadata' attribute name, causing test failures. Updated to use 'litellm_extra_body'. Co-authored-by: openhands <[email protected]>
| Coverage Report •
 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| llm.litellm_extra_body["session_id"] = "session-123" | ||
|  | ||
| assert llm.litellm_extra_body["custom_key"] == "custom_value" | ||
| assert llm.litellm_extra_body["session_id"] == "session-123" | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hah, Sonnet! 😅
This test may be useful if it tested what we actually send to litellm completion() here I guess
| "Additional metadata for the LLM instance. " | ||
| "Additional key-value pairs to pass to litellm's extra_body parameter. " | ||
| "This is useful for custom inference clusters that need additional " | ||
| "metadata for logging, tracking, or routing purposes. " | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to note, I'm pretty sure this is correct. It's not really for LLM itself, it's a field for additional logging / tracking, specially when these folks trace LLMs on the cloud
- Removed basic dictionary operation tests that provided no value - Added test that verifies litellm_extra_body is correctly passed to litellm.completion() - Test mocks litellm_completion and verifies the exact parameters passed - Validates that custom metadata reaches the actual litellm call Co-authored-by: openhands <[email protected]>
| [Automatic Post]: It has been a while since there was any activity on this PR. @li-boxuan, are you still working on it? If so, please go ahead, if not then please request review, close it, or request that someone else follow up. | 
| [Automatic Post]: I have assigned @enyst as a reviewer based on git blame information. Thanks in advance for the help! | 
Summary
This PR renames the
metadatafield tolitellm_extra_bodyand adds configuration support for custom key-value pairs to enable direct integration with litellm'sextra_bodyparameter.Changes Made
🔧 Core Changes
LLM.metadata→LLM.litellm_extra_bodyinopenhands/sdk/llm/llm.pyextra_bodyparameterextra_bodywithout unnecessary wrapping📝 Usage Sites Updated
openhands/sdk/agent/agent.py): Changed fromextra_body={"metadata": self.llm.metadata}toextra_body=self.llm.litellm_extra_bodyopenhands/sdk/context/condenser/llm_summarizing_condenser.py): Same direct mapping change⚙️ Options Handlers Enhanced
openhands/sdk/llm/options/chat_options.py): Added logic to pass throughlitellm_extra_bodywhen providedopenhands/sdk/llm/options/responses_options.py): Added same logic for responses API🧪 Tests Updated
test_llm_metadata.py→test_llm_litellm_extra_body.pyBenefits
dict[str, Any]Usage Example
Custom Inference Cluster Use Case
This change enables users with custom inference clusters to pass metadata for:
Testing
litellm_extra_bodyBreaking Changes
metadatatolitellm_extra_body. Users will need to update their code to use the new field name.However, the functionality remains the same - it's still a
dict[str, Any]that accepts custom key-value pairs.@li-boxuan can click here to continue refining the PR
Agent Server images for this PR
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
golang:1.21-bookwormeclipse-temurin:17-jdknikolaik/python-nodejs:python3.12-nodejs22Pull (multi-arch manifest)
Run
All tags pushed for this build
The
139e73btag is a multi-arch manifest (amd64/arm64); your client pulls the right arch automatically.