Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: "-t TASK" doesn't work with CLI mode #5719

Open
1 task done
scosenza opened this issue Dec 20, 2024 · 6 comments · Fixed by #5990 · May be fixed by #6187
Open
1 task done

[Bug]: "-t TASK" doesn't work with CLI mode #5719

scosenza opened this issue Dec 20, 2024 · 6 comments · Fixed by #5990 · May be fixed by #6187
Assignees
Labels
bug Something isn't working severity:medium Affecting multiple users

Comments

@scosenza
Copy link

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Describe the bug and reproduction steps

I'm writing some tooling around Openhands to make it work well in our monorepo, and I would like to start the CLI session with some company specific prompts. I tried using "-t TASK" but this appears to be ignored, even though it's printed in the usage. Is this a bug, or is there another way to start openhands w/ a prompt but then have it fall back into interactive CLI mode?

cli.py usage says:

usage: cli.py ...
Run an agent with a specific task

options:
  -t TASK, --task TASK  The task for the agent to perform
  ...

Thanks for your help!

OpenHands Installation

Docker command in README

OpenHands Version

0.16.1

Operating System

MacOS

Logs, Errors, Screenshots, and Additional Context

No response

@scosenza scosenza added the bug Something isn't working label Dec 20, 2024
@mamoodi
Copy link
Collaborator

mamoodi commented Dec 20, 2024

@enyst sorry for the ping. Do you know the answer to this?

@enyst
Copy link
Collaborator

enyst commented Dec 20, 2024

Ah, I'm not sure cli.py ever had the command line args, maybe it should!

Indeed there's another way, personally I use it via main.py. This is a bit of documentation on it: https://docs.all-hands.dev/modules/usage/how-to/headless-mode

I think there was another bit somewhere (about IDE configurations) which covers more parameters... aha, it's for openhands development, but in case it helps, found it: https://docs.all-hands.dev/modules/usage/how-to/debugging

Please note that main.py needs --no-auto-continue too so that it acts interactively. It accepts -t, along with many other parameters:

Significant differences:

  • via main.py, it stops on a Finish action
  • you can restart it, and if you want, you can restart where it was, if you enable session save to reload sessions
  • you may want to use e.g. -n work-test to set session names.

@enyst
Copy link
Collaborator

enyst commented Dec 20, 2024

I just posted and realized what happened: cli.py probably did have the command line args, several months ago, it must have lost them in a large refactoring (the args parser used to be executed on import).

@enyst enyst self-assigned this Dec 20, 2024
@mamoodi mamoodi added the severity:medium Affecting multiple users label Dec 27, 2024
@enyst enyst mentioned this issue Jan 3, 2025
1 task
@scosenza
Copy link
Author

Hi @enyst. Using 0.19.0 (which appears to have this fix), I'm still seeing the same prior behavior where "-t" doesn't appear to take effect:

steve_cosenza@Steves-MacBook-Pro treehouse % docker run -it --pull=always -e SANDBOX_RUNTIME_CONTAINER_IMAGE=openhands-airbnb-mac_0.19.0 -e SANDBOX_USER_ID=501 -e SANDBOX_TIMEOUT=5000 -e LLM_API_KEY=<redacted> -e LLM_BASE_URL=https://redacted -e LLM_MODEL=litellm_proxy/bedrock/us.anthropic.claude-3-5-sonnet-20241022-v2:0 -e WORKSPACE_MOUNT_PATH=/Users/steve_cosenza/airlab/repos/treehouse -e SANDBOX_KEEP_RUNTIME_ALIVE=true -p 3000:3000 -v /Users/steve_cosenza/airlab/repos/treehouse:/opt/workspace_base -v /var/run/docker.sock:/var/run/docker.sock -v /Users/steve_cosenza/.openhands-state:/.openhands-state --add-host host.docker.internal:host-gateway --name o
penhands-app-20250109181152 docker.all-hands.dev/all-hands-ai/openhands:0.19.0 python -m openhands.core.cli -t "Create a foo.txt file in the root of the workspace"

0.19.0: Pulling from all-hands-ai/openhands
Digest: sha256:e7313135d272f6857ad0c889a331b5a4774d583a278fdb12056fbf91333e0374
Status: Image is up to date for docker.all-hands.dev/all-hands-ai/openhands:0.19.0
Starting OpenHands...
Setting up enduser with id 501
Docker socket group id: 0
root:x:0:
Group with id 0 already exists
Running as enduser
/app/.venv/lib/python3.12/site-packages/pydantic/_internal/_config.py:341: UserWarning: Valid config keys have changed in V2:
* 'fields' has been removed
  warnings.warn(message, UserWarning)
>> 

I'm left with an empty prompt, and the foo.txt file was never created.

The behavior that I'm expecting is that "-t" sets the first message to the agent, and then I get the interactive prompt for a followup conversation.

@enyst enyst reopened this Jan 10, 2025
@enyst enyst linked a pull request Jan 10, 2025 that will close this issue
1 task
@enyst
Copy link
Collaborator

enyst commented Jan 10, 2025

Oops, I did intend to catch this last time! I think, I keep using main.py and think of it as cli.py, so when it worked with main.py I was happy enough. 😢

@scosenza
Copy link
Author

No worries and thanks for re-opening the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working severity:medium Affecting multiple users
Projects
None yet
3 participants