Hi everyone, thank you for this amazing project. I...
# questions
f
Hi everyone, thank you for this amazing project. I’m trying to use the OpenHands SDK to build an agent. I’m using a custom router provider for the OpenAI model service. When I run the example code in examples/01_standalone_sdk/01_hello_world.py with model gpt-4o, everything works fine. But when I switch to a reasoning model (such as gpt-5), I get the following error:
Copy code
openhands.sdk.conversation.exceptions.ConversationRunError: Conversation run failed for id=6c6a788f-774f-4707-b5b0-ae5a5c1130c0: litellm.BadRequestError: OpenAIException - {"error":{"message":"Item 'rs_050b49b7dd9179190069240b99932c8194aed3d1e6e05f32d7' of type 'reasoning' was provided without its required following item.","type":"invalid_request_error","param":"input","code":null}}
openhands.sdk.conversation.exceptions.ConversationRunError: Conversation run failed for id=6c6a788f-774f-4707-b5b0-ae5a5c1130c0: litellm.BadRequestError: OpenAIException - {"error":{"message":"Item 'rs_050b49b7dd9179190069240b99932c8194aed3d1e6e05f32d7' of type 'reasoning' was provided without its required following item.","type":"invalid_request_error","param":"input","code":null}} Can someone please help me what is the problem and how to fix it?
c
Does that happen immediately, or is there any successful response from the LLM?
f
This does not happen immediately, i.e. it does not happen on the first response. But it does happen after the models calls the tool.
c
Ah, so there is no successful tool call?
f
There is a successful tool, I can see that the file_editor tool is successfully called and I can see its output. But after the tool call, the response errored.
c
🤔 It's still hello world, right, and with no other changes to LLM or agent? I'm trying to replicate, I ran it twice with gpt-5-codex and it finished successfully. But I think I know what the problem might be, fix incoming
f
Yes it is the hello world example. Thank you so much for the looking into this. I'm using a custom router, don't know if it's part of the problem.
c
Could you perhaps try this PR branch, I'd love to know if it makes a difference! https://github.com/OpenHands/software-agent-sdk/pull/1238
f
Thank you so much, I'll try this now
Hi Engel, I'm still see this error. I'm not quite familiar with how uv works, so I just installed your pr branch using make build which uses uv to install from source. Then I ran uv run python test_example.py, but I'm still seeing this error.
c
thinky spin
what is the content of test_example.py? (of course remove anything private)
f
Copy code
import os

import litellm
from openhands.sdk import LLM, Agent, Conversation, Tool
from openhands.tools.file_editor import FileEditorTool
from openhands.tools.task_tracker import TaskTrackerTool
from openhands.tools.terminal import TerminalTool

os.environ["OPENAI_API_KEY"] = "sk-xxx"
os.environ["LITELLM_PROXY_API_KEY"] = "sk-xxx"  # "sk-1234" your litellm proxy api key
os.environ["LITELLM_PROXY_API_BASE"] = (
    "<https://www.dmxapi.com/v1>"  # "<http://localhost:4000>" your litellm proxy api base
)

litellm.use_litellm_proxy = True


# print(api_key)
# print(base_url)

llm = LLM(
    model="litellm_proxy/gpt-5-mini",
    # api_key=api_key,
    # base_url=base_url,
)

agent = Agent(
    llm=llm,
    tools=[
        Tool(name=TerminalTool.name),
        Tool(name=FileEditorTool.name),
        Tool(name=TaskTrackerTool.name),
    ],
)

cwd = os.getcwd()
conversation = Conversation(agent=agent, workspace=cwd)

conversation.send_message("Write 3 facts about the current project into FACTS.txt.")
conversation.run()
print("All done!")
this is what i'm currently testing with.
I just ran the testing example a few times. I found that it worked some times, but it has the same error like before most of the time, don't know if this helps
c
It does, thank you! So it is possible... but sometimes it sends apparently a different order. I just ran it twice again with your llm, gpt-5-mini, and it's still successful
I am using a litellm proxy too
I don't know if it could possibly be a matter of proxy configuration
f
Thank you so much for the insight, could you tell me how can I look into the actual request that the agent framework is sending to the service provider, so I can locate the problem on my machine and ask my provider about how they can approach the problem.
c
I'm not sure it isn't the SDK still... Investigating more. To enable logs, could you pass
log_completions=True,
to LLM constructor?
Also you may want to set
log_completions_folder="/path/to/logs",
f
oh yes I can see the logs file now. Thank you so much for your time, I'll look into this after dinner, and post my findings. If there is any issue with the SDK, i'm happy to contribute.
🙌 1
apologize for earlier, I was being careless. After switching to the pr branch, my errors look like this
Copy code
litellm.BadRequestError: Litellm_proxyException - {"error":{"message":"The encrypted content for item rs_0d1b7b195a1e4a9801692427e59a108190ae5eec412b37fafd could not be verified.","type":"invalid_request_error","param":"","code":null}}
c
Ahh
Is it really so often?
I made the OpenHands run the same script 30x times, and it seems it did not get it even once…
So far, until now, we have only seen rare reports of it. And I never saw it myself (and I use GPT-5 a lot) My best guess was… that it’s a fluke from OpenAI servers, for whatever reason. But if you get it a lot, and I don’t… I’m not sure what to think
f
Thank you Engel, I'll try looking into it more, maybe it's the problem on my provider's side. Thank you for your time and wonderful suggestions.
The problem is solved. There seems to be a problem with the service provider, their model api are from azure. After the provider gave me the model api from openai, the problem is gone.
c
Awesome, that's great to hear! Thanks for the heads-up!