Re: <https://github.com/OpenHands/OpenHands/pull/1...
# proj-sdk
c
Re: https://github.com/OpenHands/OpenHands/pull/11835 TL;DR: So I understand that AH has a staging litellm proxy (... are we up to 4 or 5 litellm proxy URLs? 😅 no wonder I get lost all the time) Then during testing on the staging deployment, folks wanted to use the staging litellm proxy. There are, it seems to me, two possibilities: • either this is a common need ◦ as noted in the last comment, I think this a very common need, many people and orgs use a custom LLM proxy ◦ so it has the same solutions that everyone else is using: a) set base url in UI, b) set base url in env, c) use the actual, real prefix rather than /openhands with base url ◦ Either way, I think this is and should be implemented in OpenHands for all users, not with AH hardcoded paths and
if
conditionals; special cases are tightly coupling OH to the Saas, they are very error-prone (aka Linus roasted! this kind of thing has broken OH codebase before), and complicating the code when maybe we don't need that at all • or, this is a special AH need, that is not supported/available for other users ◦ then folks can use a staging deployment script or similar, to set the values in env only for AH staging ◦ or, unlikely in this case, but possible in other cases, extend OH code with code in the Saas, implementing that special need. ◦ Either way, the code belongs in the Saas in this case, not in OpenHands really. WDYT? Cc: @millions-afternoon-47582 @straight-sundown-84319
m
If I understand correctly, we can use
LLM Advanced Settings
view to set up our custom API key, base URL. But the issue mentioned in the PR is related to the basic view only. Reproduction steps: 1. In the SaaS environment (feature branch and staging), navigate to the LLM Basic Settings view. When selecting OpenHands as the provider, it is no longer possible to input the base URL via the UI in this basic view if the current provider is already set to OpenHands. 2. After clicking the Save Settings button in the LLM Basic Settings view, creating a new V1 conversation, and sending a prompt, the following error occurs: 3. The root cause is that, within our Software Agent SDK, when the current provider is set to OpenHands, the base_url is hard-coded to https://llm-proxy.app.all-hands.dev/. Please refer to the code snippet below for further details.
Copy code
if model_val.startswith("openhands/"):
    model_name = model_val.removeprefix("openhands/")
    d["model"] = f"litellm_proxy/{model_name}"
    # Set base_url (default to the app proxy when base_url is unset)
    d["base_url"] = d.get("base_url", "https://llm-proxy.app.all-hands.dev/")
For this reason, when testing on the feature branch or staging environment, the feature/staging LiteLLM key is sent to the production URL, which results in the error described above. I agree that there may be a more appropriate solution—such as updating the environment variable, adjusting the deployment scripts, or restoring the base URL input field in the Basic view. However, asking the users to switch to the Advanced view will not resolve the root cause of the issue, based on the provided reproduction steps - the users are using the basic view. cc @chilly-france-44439
c
Is it possible to input base URL in Basic View for other providers?
m
Yes, that is possible. However, if the current provider is OpenHands, users will not be able to enter a base URL in the Basic view. When OpenHands is selected as the provider, an OpenHands-generated LiteLLM key is used, and any prompts created by the user will be routed through the OpenHands LiteLLM proxy.
I believe this is also the reason Xingyao preferred removing the base URL input field when the current provider is OpenHands.
c
OK. So we have some "OpenHands Provider specific" code in the Web UI, I take it?
m
In the open-source version, the base_url input field is still visible when the current provider is set to OpenHands. We removed this field only in the SaaS version.
c
However, asking the users to switch to the Advanced view will not resolve the root cause of the issue, based on the provided reproduction steps - the users are using the basic view.
Are the users using the AH staging deployment? This seems like it's only AH folks, not users in general.
m
Are the users using the AH staging deployment? This seems like it's only AH folks, not users in general.
No, they are not using the OpenHands staging deployment. This is for internal testing. When Mahmoud uses the staging deployment and follows the reproduction steps above, he encounters the issue. The root cause is that we are hard-coding https://llm-proxy.app.all-hands.dev/ in our software-agent-sdk. As a result, the LiteLLM key generated in the staging environment does not work. Although he can switch to the Advanced view to work around the issue—and therefore is not fully blocked—the underlying problem remains. The purpose of the pull request was to resolve the issue observed when following the reproduction steps and to ensure that the Basic view functions correctly across all OpenHands environments. However, since my current solution does not align with our best practices, I will look for an alternative approach. Thank you! thankyou
c
🤔 would it be possible to include a
OPENHANDS_PROVIDER_BASE_URL
and default it to llm-proxy.app.all-hands.dev/
and then we just add this env var in deployment, so it should introduce minimal changes to our codebase
c
@chilly-france-44439 Hiep Le already fixed the override in the SDK, we accept base_url and fallback to app.all-hands if base URL is not set : https://github.com/OpenHands/software-agent-sdk/pull/1273
So we can use BASE_URL, right?
m
I made that change because I expected my OpenHands pull request to be approved. In that case, I would only need to detect the current environment and pass the LiteLLM proxy URL to the software-agent-sdk when creating the LLM object. However, since my OpenHands pull request was not accepted, the change in the SDK pull request may not be particularly helpful in this situation.
c
OK, I suppose we also have alternatives like • the staging special case could be in the Saas code, like when the user LLM settings are saved • in the worst case we could mess with the UI when the user sets stuff and the OH URL is on staging... send to OH backend the correct staging litellm proxy. None of these looks particularly good to me... IMHO probably better for the AH folks to just click on Advanced view. With the SDK fix, we won't override your base URL when you enter staging proxy, right?
m
Yes, that is correct. With the SDK fix, if we access the staging environment and use the Basic view, the LiteLLM proxy URL will still point to the production environment. The current workaround is to switch to the Advanced view and provide a custom base URL, such as the staging LiteLLM proxy URL.
c
Just to clarify, I believe the SDK fix was good regardless of this issue. It's possible, at least in theory, that users set a proxy which proxies the request to
/openhands
, the SDK shouldn't completely make that impossible - that was a bug IMHO. Basically, as you said Hiep Le, in the open source version you can enter base URL for
/openhands
, but the SDK without the fix was overriding user choice
@chilly-france-44439 Folks continue the work on
/openhands
proxy, and it is available for everyone. As far as I can tell, it is possible to use it even without OH? Not sure that's intended, now that I think of it... but it seems possible. What do you think about asking LiteLLM to do the re-routing to the AH app proxy in liteLLM? Then we wouldn't need any special case even for prod, in the SDK. 🤔
c
What do you think about asking LiteLLM to do the re-routing to the AH app proxy in liteLLM? Then we wouldn't need any special case even for prod, in the SDK
Do you mean automatically route to staging proxy on app url? i don't think that is possible w/o modify litellm itself 🤔
With the SDK fix, if we access the staging environment and use the Basic view
Actually i wonder if we can do this in the frontend? I vaguely remember we already sent a request to the backend to get OH API Key everytime user switches to "OpenHands" provider?
Can we do the same thing to override the base_url, or are we worried about overriding user's custom settings?
c
Do you mean automatically route to staging proxy on app url? i don't think that is possible w/o modify litellm itself
No, sorry. I mean: • get LiteLLM project to register
openhands/
provider, just it has 100+ providers, like `/openrouter`` and so on • for the app URL • yes, it is a litellm addition, is there a reason why not?
c
make sense 🤔 though i'm not sure if that's necessary if we only want ppl to use oh provider via oh
c
I guess being in litellm natively would give it some additional visibility. 🤔 Do you have strong feelings about people to not use
/openhands
in other ways? I mean... they already can...
c
Do you have strong feelings about people to not use
/openhands
in other ways
Yeah I mean technically, we encourage ppl to use OH provider only on OpenHands application, and they are supposed not to use it for other stuff, though we don't technically have a way to prevent that from happening like you said.
c
🤔 I'd suggest to maybe reconsider this, or at least give it some thought. The litellm addition would give it some extra visibility, and when people want to recharge, they'd be back logging in on the Cloud to do it. For a loss leader, that doesn't seem like a bad scenario. Anyway that was just a tangential thought. (It would help a little bit, to remove the
app
case from the SDK, but that case is not too bad. 😅) Back to the alternatives for staging, I think FE-only is an alternative solution, if it's possible. Additionally, I suggest to consider that maybe you could just let it be routed to
app
in Basic view. Is that very bad? It does literally test that it's routed where it should. 😅 Is there really a need to re-route to a different litellm proxy?