Commit `b0b82bdac`changed hello world example to u...
# proj-sdk
c
Commit `b0b82bdac`changed hello world example to use anthropic instead of our proxy pattern in other examples. Was that intentional? https://github.com/OpenHands/software-agent-sdk/commit/b0b82bdac
OpenHands LLM key works for other examples but not for hello world as a result. This means you have to change LLM_API_KEY depending on which example you want to run.
c
yep, i think that one was made by @wooden-umbrella-84098
c
Hmm. I think its going to be confusing for first time users, especially since we get a big stack trace instead of clean error when there is a problem with an API key. It's going to look like a bug. Seems to me a user should be able to setup their environment and run all examples.
c
@wooden-umbrella-84098 do you have any strong opinion here on switching it back to
openhands/claude-sonnet-xx
?
c
When I do demos to customers I will want to run hello world first and then move on to other examples of interest without fiddling with environment settings....
c
that seems like a legit use case nod at least we should make the example read from env var when you've set that up?
c
Since hello world is where people start I would add a comment that tells where they can get API key from us and then has instructions for switching to another model if they want to use the anthropic or open.ai key already configured. I'll open a PR for it and we can discuss (or shoot it down) there : ) https://github.com/OpenHands/software-agent-sdk/pull/1065
w
So I'm 10x more concerned with "hello world" looking like a good example, rather than it running out of the box. I also think it's 10x more likely that the average user is going to have an Anthropic API key than an OpenHands SaaS API key My suggestion would be to default to
anthropic/claude
but we can include the env var as well, to make it easier for John-Mason to demo 🙂 does that work?
👍 1
I also think we should remove the comment. We can add something in the prose (with a real hyperlink) about how to get an API key and how to set the model name, base URL, etc
nod 1
(tbh we should have a whole docs page on configuring your preferred LLM)
c
If I were learning to use a new SDK, the first thing I would do is go straight to the examples and run them. If hello world isn't intended to run, perhaps we should use a different folder or convention for it. If we think that runners of the scripts have anthropic already configured and so we want to use anthropic to make first use experience great, then lets do that for ALL the scripts.
c
a lot of the scripts does requires more than anthropic model (eg reasoning example); so i'd say it is better to load those values from env var in the first hello world example
c
So one idea would be to have new folder 00_getting_started where we have hello world, and perhaps show different examples for constructing agent w/ different settings. Another would be to update all of the examples to default to anthropic if we think that is the experience we prefer for first time users.
c
To be fair, Xingyao, you're right there are several, though probably not a lot. thinky spin If the example is on
anthropic/
, the user will understand it immediately and be able to run it For the record, I believe that the openhands/{model_name} uses a standard model_name. That likely means that in later scripts, multi-LLM or reasoning, people can probably transfer that knowledge to
openhands/
, switching just the key. But I agree that the ability to run directly is nice and much more people will have an Anthropic key of course
nod 1
c
I suppose another thing we could do is switch environment variable in the examples so that when we use anthropic directly we check
ANTHROPIC_API_KEY
and when we use
openhands/
in the examples we check
LLM_API_KEY
environment variable. No change to SDK but just to the examples. This would be a strong signal and allow one to have same shell environment to run all examples.
🤔 1
Okay scrap that. 😆 I've added a new commit to the PR that: 1. Removes comment from
01_hello_world.py
2. Updates all examples from
openhands/claude-sonnet-4-5-20250929
to
anthropic/claude-sonnet-4-5-20250929
3. Allows
LLM_MODEL
and
LLM_API_KEY
environment variables to override settings in
01_hello_world.py
as elsewhere
Hopefully that better reflects consensus here.
w
minor nit--can we remove the
assert
and do API_KEY in-line like we do for LLM_MODEL?
at least for hello world
c
IMHO the error message should be cleaned up in the SDK so all of the asserts in the examples can go away...
c
You mean it should print a pretty error, a one liner? 🤔
c
No stack trace. Clear messages when 1. values for api key, model, etc are missing or 2. when we there a model connectivity problem because the key is bad, can't reach the hosts, etc. Proactive error handling, clear messages, no stack trace.
We won't always be able to pin-point what is wrong as that is in LiteLLM layer I assume, but we should check for things we reasonably can and present an error message that gives the user a clear set of things to check for when root cause is unknown.
I haven't looked at the code for it but speculating that we may be not throwing specific enough exceptions, the exceptions don't carry needed message detail, and we don't have an option or standard error guard / pretty printing error printer class that developers using sdk could use to catch and display exceptions nicely.
@nutritious-balloon-65098 tell us about error handling in the sdk when it comes to missing parameters, llm connectivity or authentication issues, etc. What exceptions do we have? What proactive checking do we do? Do exceptions carry user consumable suggestions as well as error messages. What do we have for options related to whether errors are caught or thrown or generic error guard, error pretty printing, etc.
n
I'm on it! John-Mason Shackelford can track my progress here.
c
We tried to do the first 2/3 in this PR What I wonder is, we are trying to expose the right exception to clients. The examples are… well, client code. If they don’t catch it, they don’t catch it - it spills out. Should we do anything to pretty print for them? Catching and pretty printing feels more like a client issue
n
Summary: OpenHands SDK Error Handling Analysis I conducted a comprehensive analysis of error handling in the OpenHands SDK and found the following: Current Error Handling Capabilities ✅ Strong Foundation: • Comprehensive exception hierarchy with 15+ specific error types (LLMAuthenticationError, LLMRateLimitError, LLMContextWindowExceedError, etc.) • Smart exception mapping from provider errors (LiteLLM) to SDK-typed exceptions with pattern-based classification • Robust retry logic with exponential backoff, configurable parameters, and selective retrying on connection/rate limit errors • Exception chaining that preserves original errors for debugging • Some helpful error messages with actionable suggestions (e.g., context window errors suggest using condensers) ❌ Missing User Experience Features: • No error pretty printing utility - All examples use raw
assert
statements that show full stack traces • No error guard/wrapper - No optional mechanism to catch and display errors cleanly • Limited proactive checking - Only basic validation (model required, streaming not supported) • Inconsistent error suggestions - Most errors lack actionable guidance for users • No error handling configuration - No options to control whether errors are caught/thrown or how they're displayed Key Findings: 1. Exception Structure: Well-organized with base classes (
LLMError
,
GitError
,
SkillError
) and specific subtypes 2. Provider Integration: Excellent mapping from LiteLLM exceptions to SDK exceptions with intelligent classification 3. Retry Resilience: Sophisticated retry mechanism that handles transient failures gracefully 4. Missing UX Layer: The technical foundation is solid, but lacks user-friendly error presentation Recommendations: The SDK would significantly benefit from adding: • Error display utilities for clean, stack-trace-free error messages • Error guard decorators/context managers for optional graceful error handling • Enhanced proactive parameter validation (API keys, model availability) • Expanded error suggestions with actionable guidance • Configuration options for error handling behavior The current error handling is technically robust but needs a user experience layer to make errors more consumable for developers using the SDK. <sub>View full conversation</sub>
c
Thanks for PR link! Will read. I see these aspects: a. Having clear specific exceptions with meaningful advice -- probably not controversial b. option that to control what happens on error or or basic functions for prettying the exceptions raised by the library not uncommon feature of an sdk (as opposed to a library) Sure some clients will be CLIs and others will be embedded in other kinds of experiences, but seems like every client should have primitives in the framework to do basics w/ low effort and our examples would show how to use.
c
You know more about the visualizer - and maybe you could ask the agent in this same conversation? since it knows things now 😅 - could we have this kind of prettifying / some handling in the default visualizer? As opposed to elsewhere, as opposed to yet-another-env-var
or is that dumb for some reason
c
I think what I have in mind is probably simpler than it sounds. I'll try to look at the PR you referenced and the code and make a concrete proposal or admit my assumptions were bad. Likely this evening.
thanks on a stick 1
🙏 1
c
I updated the PR a bit • simplified hello world without assert • fix two multi-LLM examples
test-examples
works, 3 failures • one was fixed above The other 2 are not LLM: ◦ delegation example has a problem ◦ probably some code relying on side-effect or related affects remote workspace example