OpenHands / OpenHands/software-agent-sdk
[Bug]: Title generation prompt glues user message to instruction and breaks emoji list formatting
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 539
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 137
Description
Describe the bug
The LLM title-generation prompt built in generate_title_with_llm() (openhands-sdk/openhands/sdk/conversation/title_utils.py) concatenates adjacent f-string segments without proper separators, producing malformed input to the title model.
Steps to Reproduce
uv run python - <<'EOF'
from unittest.mock import patch
from pydantic import SecretStr
from openhands.sdk.llm import LLM
from openhands.sdk.conversation.title_utils import generate_title_with_llm
llm = LLM(model="gpt-4o-mini", api_key=SecretStr("k"), usage_id="t")
with patch("openhands.sdk.llm.llm.LLM.completion") as c:
generate_title_with_llm("test", llm)
print(c.call_args.args[0][1].content[0].text)
EOF
Actual Behavior
Running the repro (uv run python) on main, the user message is glued to the instruction with a stray period, and the emoji list is glued to its intro line with the first entry un-bulleted:
Generate a title (maximum 50 characters) for a conversation that starts with this message:
test.Also make sure to include ONE most relevant emoji at the start of the title. Choose the emoji from this list:💄 frontend: UI and style files
- 👔 backend: Business logic
...
♻️ refactor: Code refactoring
Specifically:
- A stray
.is appended directly after the user message (test.Also make sure...); truncated messages get double periods (...(truncated)..). - The emoji list has no newline after
Choose the emoji from this list:. - The first emoji entry lacks the
-bullet prefix its siblings have (the list is built with"\n- ".join(...), which only prefixes entries after the first). - The prompt ends with a trailing space instead of a newline.
This affects all auto-title paths since LocalConversation, RemoteConversation, and agent-server conversation_service all reuse this SDK helper.
Expected Behavior
The user message should be separated from the instruction by a blank line, and the emoji list should start on its own line with uniform - bullets for every entry, ending with a newline.
Acceptance Criteria
- Title-generation prompt separates the user message from the instruction with
\n\n(no stray period appended to the message). - Every emoji category entry renders as a uniform
-bullet starting on its own line afterChoose the emoji from this list:. - Prompt text ends with a newline.
- Regression test asserts the formatted prompt structure.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in openhands-sdk/openhands/sdk/conversation/title_utils.py at generate_title_with_llm(), then run the provided uv Python reproduction to inspect the generated prompt. Add the regression test described in the acceptance criteria and verify that the message separation, emoji bullets, and final newline are formatted correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- ai, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 86/100