Skip to content

fix(auth): auto-generate unique usage_id in create_llm() (#1964)#1975

Open
timon0305 wants to merge 6 commits intoOpenHands:mainfrom
timon0305:fix/create-llm-usage-id-1964
Open

fix(auth): auto-generate unique usage_id in create_llm() (#1964)#1975
timon0305 wants to merge 6 commits intoOpenHands:mainfrom
timon0305:fix/create-llm-usage-id-1964

Conversation

@timon0305
Copy link

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:

  • 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

Checklist

  • If the PR is changing/adding functionality, are there tests to reflect this?
  • If there is an example, have you run the example to make sure that it works?
  • If there are instructions on how to run the code, have you followed the instructions and made sure that it works?
  • If the feature is significant enough to require documentation, is there a PR open on the OpenHands/docs repository with the same branch name?
  • Is the github CI passing?

timon0305 and others added 2 commits February 9, 2026 15:15
)

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
@timon0305 timon0305 marked this pull request as ready for review February 10, 2026 23:14
Copy link
Collaborator

@all-hands-bot all-hands-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

@enyst enyst self-requested a review February 11, 2026 04:42
@enyst enyst added behavior-initiative This is related to the system prompt sections and LLM steering. and removed behavior-initiative This is related to the system prompt sections and LLM steering. labels Feb 14, 2026
@all-hands-bot
Copy link
Collaborator

[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.

Copy link
Collaborator

@enyst enyst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments