fix(auth): auto-generate unique usage_id in create_llm() (#1964)#1975
fix(auth): auto-generate unique usage_id in create_llm() (#1964)#1975timon0305 wants to merge 6 commits intoOpenHands:mainfrom
Conversation
) When using OpenAISubscriptionAuth.create_llm() multiple times without explicit usage_id, the LLMRegistry raises ValueError because both LLMs get the default usage_id of "default". Changes: - create_llm() now auto-generates unique usage_id if not provided (format: chatgpt-subscription-{8_hex_chars}) - Added generate_usage_id() utility function in llm.py for consistent unique ID generation across the codebase - Added has() and get_or_none() methods to LLMRegistry for safer registry operations - Exported generate_usage_id from openhands.sdk.llm package
all-hands-bot
left a comment
There was a problem hiding this comment.
🟡 Acceptable - Solves a real problem pragmatically, but the implementation has "code smell" issues that violate good taste.
VERDICT: ✅ Worth merging after addressing the inconsistency
KEY INSIGHT: You built a proper utility function for ID generation but then ignored it in the actual fix—this is like bringing a hammer to a job site and using your fist instead.
|
[Automatic Post]: It has been a while since there was any activity on this PR. @timon0305, 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. |
enyst
left a comment
There was a problem hiding this comment.
Thank you for this PR, timon! I apologize for the delay, I’ve been thinking about this and I’m not sure it’s the right fix. Does it happen for subscription?
I would love to know if @VascoSch92 has thoughts, because I think maybe we will meet this problem with various profiles switches too…
Summary
When using OpenAISubscriptionAuth.create_llm() multiple times without explicit usage_id, the LLMRegistry raises ValueError because both LLMs get the default usage_id of "default".
Changes:
Checklist