Skip to content

fix(sdk): keep truncated titles within a max_length below 3 - #6583

Merged
VascoSch92 merged 1 commit into
mainfrom
vasco/title-tiny-max-length
Nov 7, 2026
Merged

VascoSch92 merged 1 commit into
mainfrom
vasco/title-tiny-max-length

Conversation

@VascoSch92

@VascoSch92 VascoSch92 commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

HUMAN:

just fixing a bug


AGENT:

Why

Both title truncations do title[: max_length - 3] + "...". For max_length below 3 that slice is negative, so it keeps almost the whole title and the result is longer than the limit: generate_fallback_title("hello world", 2) returns "hello worl..." (13 characters).

Summary

Issue Number

Part of #6348 (item: "max_length < 3 makes title[: max_length - 3] a negative slice, so the 'truncated' title is longer than max_length").

How to Test

uv run pytest tests/sdk/conversation/test_generate_title.py

The new test_fallback_title_never_exceeds_tiny_max_length fails on main for 0, 1 and 2 and passes here; the whole file passes (29). For "hello world" with max_length 0, 1, 2, 3, 5 the fallback now returns '', 'h', 'he', 'hel', 'he...' (at exactly 3 it used to return '...'; both fit the limit).

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

🐳 Agent Server images for this PR — GHCR package, pull/run commands, and all pushed tags (click to expand)

• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server

Variants & Base Images

Variant Architectures Base Image Docs / Tags
java amd64, arm64 eclipse-temurin:17-jdk Link
python-slim amd64, arm64 python-node-runtime Link
python-minimal amd64, arm64 python-node-runtime Link
python amd64, arm64 python-node-runtime Link
golang amd64, arm64 golang:1.21-bookworm Link

Pull (multi-arch manifest)

# Each variant is a multi-arch manifest supporting both amd64 and arm64
docker pull ghcr.io/openhands/agent-server:9e9d9f0-python

Run

docker run -it --rm \
  -p 8000:8000 \
  --name agent-server-9e9d9f0-python \
  ghcr.io/openhands/agent-server:9e9d9f0-python

All tags pushed for this build

ghcr.io/openhands/agent-server:9e9d9f0-golang-amd64
ghcr.io/openhands/agent-server:9e9d9f0f4a20c32e1c6101a741201c8c95617089-golang-amd64
ghcr.io/openhands/agent-server:vasco-title-tiny-max-length-golang-amd64
ghcr.io/openhands/agent-server:9e9d9f0-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:9e9d9f0-golang-arm64
ghcr.io/openhands/agent-server:9e9d9f0f4a20c32e1c6101a741201c8c95617089-golang-arm64
ghcr.io/openhands/agent-server:vasco-title-tiny-max-length-golang-arm64
ghcr.io/openhands/agent-server:9e9d9f0-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:9e9d9f0-java-amd64
ghcr.io/openhands/agent-server:9e9d9f0f4a20c32e1c6101a741201c8c95617089-java-amd64
ghcr.io/openhands/agent-server:vasco-title-tiny-max-length-java-amd64
ghcr.io/openhands/agent-server:9e9d9f0-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:9e9d9f0-java-arm64
ghcr.io/openhands/agent-server:9e9d9f0f4a20c32e1c6101a741201c8c95617089-java-arm64
ghcr.io/openhands/agent-server:vasco-title-tiny-max-length-java-arm64
ghcr.io/openhands/agent-server:9e9d9f0-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:9e9d9f0-python-amd64
ghcr.io/openhands/agent-server:9e9d9f0f4a20c32e1c6101a741201c8c95617089-python-amd64
ghcr.io/openhands/agent-server:vasco-title-tiny-max-length-python-amd64
ghcr.io/openhands/agent-server:9e9d9f0-python-node-runtime-amd64
ghcr.io/openhands/agent-server:9e9d9f0-python-arm64
ghcr.io/openhands/agent-server:9e9d9f0f4a20c32e1c6101a741201c8c95617089-python-arm64
ghcr.io/openhands/agent-server:vasco-title-tiny-max-length-python-arm64
ghcr.io/openhands/agent-server:9e9d9f0-python-node-runtime-arm64
ghcr.io/openhands/agent-server:9e9d9f0-python-minimal-amd64
ghcr.io/openhands/agent-server:9e9d9f0f4a20c32e1c6101a741201c8c95617089-python-minimal-amd64
ghcr.io/openhands/agent-server:vasco-title-tiny-max-length-python-minimal-amd64
ghcr.io/openhands/agent-server:9e9d9f0-python-node-runtime-minimal-amd64
ghcr.io/openhands/agent-server:9e9d9f0-python-minimal-arm64
ghcr.io/openhands/agent-server:9e9d9f0f4a20c32e1c6101a741201c8c95617089-python-minimal-arm64
ghcr.io/openhands/agent-server:vasco-title-tiny-max-length-python-minimal-arm64
ghcr.io/openhands/agent-server:9e9d9f0-python-node-runtime-minimal-arm64
ghcr.io/openhands/agent-server:9e9d9f0-python-slim-amd64
ghcr.io/openhands/agent-server:9e9d9f0f4a20c32e1c6101a741201c8c95617089-python-slim-amd64
ghcr.io/openhands/agent-server:vasco-title-tiny-max-length-python-slim-amd64
ghcr.io/openhands/agent-server:9e9d9f0-python-node-runtime-slim-amd64
ghcr.io/openhands/agent-server:9e9d9f0-python-slim-arm64
ghcr.io/openhands/agent-server:9e9d9f0f4a20c32e1c6101a741201c8c95617089-python-slim-arm64
ghcr.io/openhands/agent-server:vasco-title-tiny-max-length-python-slim-arm64
ghcr.io/openhands/agent-server:9e9d9f0-python-node-runtime-slim-arm64
ghcr.io/openhands/agent-server:9e9d9f0-golang
ghcr.io/openhands/agent-server:9e9d9f0f4a20c32e1c6101a741201c8c95617089-golang
ghcr.io/openhands/agent-server:vasco-title-tiny-max-length-golang
ghcr.io/openhands/agent-server:9e9d9f0-golang_tag_1.21-bookworm
ghcr.io/openhands/agent-server:9e9d9f0-java
ghcr.io/openhands/agent-server:9e9d9f0f4a20c32e1c6101a741201c8c95617089-java
ghcr.io/openhands/agent-server:vasco-title-tiny-max-length-java
ghcr.io/openhands/agent-server:9e9d9f0-eclipse-temurin_tag_17-jdk
ghcr.io/openhands/agent-server:9e9d9f0-python-minimal
ghcr.io/openhands/agent-server:9e9d9f0f4a20c32e1c6101a741201c8c95617089-python-minimal
ghcr.io/openhands/agent-server:vasco-title-tiny-max-length-python-minimal
ghcr.io/openhands/agent-server:9e9d9f0-python-node-runtime-minimal
ghcr.io/openhands/agent-server:9e9d9f0-python-slim
ghcr.io/openhands/agent-server:9e9d9f0f4a20c32e1c6101a741201c8c95617089-python-slim
ghcr.io/openhands/agent-server:vasco-title-tiny-max-length-python-slim
ghcr.io/openhands/agent-server:9e9d9f0-python-node-runtime-slim
ghcr.io/openhands/agent-server:9e9d9f0-python
ghcr.io/openhands/agent-server:9e9d9f0f4a20c32e1c6101a741201c8c95617089-python
ghcr.io/openhands/agent-server:vasco-title-tiny-max-length-python
ghcr.io/openhands/agent-server:9e9d9f0-python-node-runtime

About Multi-Architecture Support

  • Each variant tag (e.g., 9e9d9f0-python) is a multi-arch manifest supporting both amd64 and arm64
  • Docker automatically pulls the correct architecture for your platform
  • Individual architecture tags (e.g., 9e9d9f0-python-amd64) are also available if needed

With max_length < 3, title[: max_length - 3] is a negative slice, so the
"truncated" title came out longer than the limit. Cut to max_length
without an ellipsis when there is no room for one.
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

REST API breakage checks (OpenAPI) — ✅ PASSED

Result: ✅ PASSED

Action log

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-sdk/openhands/sdk/conversation
   title_utils.py72199%24
TOTAL54348854384% 

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review was posted by an AI agent (OpenHands).

Reviewed head 9e9d9f0f4a20c32e1c6101a741201c8c95617089.

Scope gate passes: both changed files are SDK conversation title helpers owned by this repository, and the linked issue #6348 is open in this repo with bug and ready-for-dev labels, matching the PR description.

Technical assessment:

  • The reported bug is real on main: with max_length < 3, title[: max_length - 3] is a negative slice, so the "truncated" title kept nearly all the text and grew past the limit (e.g. generate_fallback_title("hello world", 2) → "hello worl...", 13 chars).
  • The fix clamps to title[:max_length] when max_length <= 3 and keeps the ellipsis path for max_length > 3, applied consistently to both generate_fallback_title and generate_title_with_llm. I verified the LLM path feeds into the same truncation via generate_title_from_message, so fixing only one site would have left the other oversized; both are covered.
  • Behavior for max_length >= 4 is unchanged, so existing callers using the default max_length=50 are unaffected. At exactly 3 the result changes from "..." to the first 3 characters; both fit the limit, and the change is disclosed in the PR description.
  • No persistence, serialization, REST, or TypeScript-client surface is touched; no other call sites exist in the repo.

Verification in the workspace at this head: uv run pytest tests/sdk/conversation/test_generate_title.py → 29 passed, including the 3 new parametrized cases (max_length 0, 1, 2), which fail on main and pass here. GitHub Actions on this exact head are green (sdk-tests, agent-server-tests, cross-tests, integration-test, pre-commit, build matrix, OpenAPI checks).

No material correctness, security, or compatibility findings.

✅ APPROVED

@VascoSch92
VascoSch92 merged commit b249e30 into main Nov 7, 2026
54 of 55 checks passed
@VascoSch92
VascoSch92 deleted the vasco/title-tiny-max-length branch November 7, 2026 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants