[Bug]: Error during parsing ollama return.
Is there an existing issue for the same bug?
- [X] I have checked the existing issues.
Describe the bug and reproduction steps
I'm tring local ollama qwen2.5coder 32b model. Agent tried to get content field which doesn't exist. The command I used to start openhands is
docker run -it \ --rm \ --pull=always \ -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.14-nikolaik \ -e SANDBOX_USER_ID=$(id -u) \ -e WORKSPACE_MOUNT_PATH=/home/papillon/eden/apple \ -e LLM_MODEL=ollama/qwen \ -e LLM_OLLAMA_BASE_URL=http://host.docker.internal:11435 \ -e LLM_BASE_URL=http://host.docker.internal:11435 \ -v /home/papillon/eden/apple:/workspace \ -v /var/run/docker.sock:/var/run/docker.sock \ --add-host host.docker.internal:host-gateway \ --name openhands-app-apple \ docker.all-hands.dev/all-hands-ai/openhands:0.14 \ python -m openhands.core.cli
and error I got is
Traceback (most recent call last):
File "/app/openhands/controller/agent_controller.py", line 202, in start_step_loop
await self._step()
File "/app/openhands/controller/agent_controller.py", line 483, in _step
action = self.agent.step(self.state)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/openhands/agenthub/codeact_agent/codeact_agent.py", line 334, in step
response = self.llm.completion(**params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/tenacity/init.py", line 336, in wrapped_f
return copy(f, *args, **kw)
^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/tenacity/init.py", line 475, in call
do = self.iter(retry_state=retry_state)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/tenacity/init.py", line 376, in iter
result = action(retry_state)
^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/tenacity/init.py", line 398, in
I also have a proxy to log transcript between agent and ollama. Here is the chat log.
Time: 2024-11-17 05:53:16 Endpoint: /api/generate Request: { "model": "qwen", "prompt": "--------------------- NEW TASK DESCRIPTION ---------------------\n/workspace目录下有哪些文件?--------------------- END OF NEW TASK DESCRIPTION ---------------------\n\nPLEASE follow the format strictly! PLEASE EMIT ONE AND ONLY ONE FUNCTION CALL PER MESSAGE.\n\n\n", "options": { "temperature": 0.0, "top_p": 1.0, "stop": [ "</function" ] }, "stream": false } Response: { "model": "qwen", "created_at": "2024-11-17T10:53:28.121734314Z", "response": "<function=execute_bash>\n<parameter=command>\nls /workspace\n\n", "done": true, "done_reason": "stop", "context": [ 151644, 8948, 198, ... ], "total_duration": 11151593064, "load_duration": 14279532, "prompt_eval_count": 4042, "prompt_eval_duration": 626000000, "eval_count": 21, "eval_duration": 10510000000 }
OpenHands Installation
Docker command in README
OpenHands Version
0.14
Operating System
Linux
Logs, Errors, Screenshots, and Additional Context
No response
I'm unfortunately not familiar with ollama at all. Just wondering if you run it the same way as this comment: https://github.com/All-Hands-AI/OpenHands/issues/3960#issuecomment-2474720099
Does it work? Set the model and base url through the UI.
convert_fncall_messages_to_non_fncall_messages role, content = message['role'], message['content'] KeyError: 'content'
This is a bug, solved in this PR.
convert_fncall_messages_to_non_fncall_messages role, content = message['role'], message['content'] KeyError: 'content'
This is a bug, solved in this PR.
Worked yesterday but now it throws this:
Traceback (most recent call last):
File "/app/openhands/controller/agent_controller.py", line 204, in start_step_loop
await self._step()
File "/app/openhands/controller/agent_controller.py", line 485, in _step
action = self.agent.step(self.state)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/openhands/agenthub/codeact_agent/codeact_agent.py", line 333, in step
response = self.llm.completion(**params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/tenacity/__init__.py", line 336, in wrapped_f
return copy(f, *args, **kw)
^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/tenacity/__init__.py", line 475, in __call__
do = self.iter(retry_state=retry_state)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/tenacity/__init__.py", line 376, in iter
result = action(retry_state)
^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/tenacity/__init__.py", line 398, in <lambda>
self._add_action_func(lambda rs: rs.outcome.result())
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 449, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/app/.venv/lib/python3.12/site-packages/tenacity/__init__.py", line 478, in __call__
result = fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/app/openhands/llm/llm.py", line 187, in wrapper
messages = Message.convert_messages_to_non_native(messages, kwargs['tools'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/openhands/core/message.py", line 350, in convert_messages_to_non_native
tool_call_id=message['tool_call_id'],
~~~~~~~^^^^^^^^^^^^^^^^
KeyError: 'tool_call_id'
@AidyTheWeird oh, on the PR branch? Sorry about that, yes, I thought it was working, but I needed to refactor the code and it might be broken right now.
Could you tell how you were running it? If via git, then git reset --hard 2d4f02cd56ca1a74f07930eb5e0ff3a0cf9a2ec6 should work.
I run through docker
docker run -it --rm -p 3000:3000 -v /var/run/docker.sock:/var/run/docker.sock --add-host host.docker.internal:host-gateway -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:07c3643-nikolaik --name openhands-app-07c3643 docker.all-hands.dev/all-hands-ai/openhands:07c3643
edit: trying docker run -it --rm -p 3000:3000 -v /var/run/docker.sock:/var/run/docker.sock --add-host host.docker.internal:host-gateway -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:ffca2b4-nikolaik --name openhands-app-ffca2b4 docker.all-hands.dev/all-hands-ai/openhands:ffca2b4
I think you're right, the second should work and/or it might take a bit to finish CI