Skip to content

chore: remove verified dead code - #4225

Merged
VascoSch92 merged 1 commit into
mainfrom
vasco/cleanup-dead-code-4224
Jul 27, 2026
Merged

VascoSch92 merged 1 commit into
mainfrom
vasco/cleanup-dead-code-4224

Conversation

@VascoSch92

@VascoSch92 VascoSch92 commented Jul 27, 2026 •

Copy link
Copy Markdown
Member

HUMAN:

Small PR to delete some dead-code


AGENT:

Why

Several symbols in the SDK and agent-server are defined but never used anywhere in the tree. They add maintenance surface (imports to keep valid, type-checking, docs) for no benefit. This removes the dead-code items from #4224 (the duplication, simplification, and model_dump_succint() items in that issue are intentionally not part of this PR).

Each symbol was verified unreferenced before removal: whole-tree git grep shows only the definition site, none appear in any __all__, and no module does from ... import * on them.

Summary

  • Remove _AgentProtocol from openhands-sdk/openhands/sdk/agent/response_dispatch.py (its only reference was a docstring, which now points at the mixin's TYPE_CHECKING block instead) and drop the now-unused Protocol/runtime_checkable imports.
  • Remove ConversationResponse, GenerateTitleRequest, and GenerateTitleResponse from openhands-agent-server/openhands/agent_server/models.py (none are wired to a route) and drop the now-unused from openhands.sdk import LLM import.
  • Remove get_category() from openhands-sdk/openhands/sdk/critic/impl/api/taxonomy.py (a thin wrapper over FEATURE_CATEGORIES.get(), which categorize_features() already calls directly).
  • Remove predict_labels() from openhands-sdk/openhands/sdk/critic/impl/api/client.py.

Net change: −82 lines across 4 files, no behavior change.

Issue Number

Refs #4224 (dead-code items only; other items in the issue are out of scope for this PR).

How to Test

From the repo root:

# 1. Confirm each symbol has no remaining reference anywhere in the tree
git grep -n "_AgentProtocol\|ConversationResponse\|GenerateTitleRequest\|GenerateTitleResponse\|get_category\|predict_labels"
# (only the definition sites existed before this PR; nothing after)

# 2. Lint + type-check the changed files
uv run ruff check openhands-sdk openhands-agent-server
uv run ruff format --check openhands-sdk openhands-agent-server
uv run pyright openhands-sdk/openhands/sdk/agent/response_dispatch.py \
  openhands-sdk/openhands/sdk/critic/impl/api/client.py \
  openhands-sdk/openhands/sdk/critic/impl/api/taxonomy.py \
  openhands-agent-server/openhands/agent_server/models.py

# 3. Run the affected test suites
uv run pytest tests/sdk/critic tests/sdk/agent/test_response_dispatch.py \
  tests/agent_server/test_models.py tests/agent_server/test_openapi_discriminator.py \
  tests/agent_server/test_conversation_response.py -q

Results in this branch:

  • ruff check / ruff format --check: pass, all files formatted.
  • pyright: 0 errors, 0 warnings, 0 informations.
  • pytest: 87 passed.
  • The agent-server OpenAPI schema is unchanged — the three removed models never appeared in it (api.openapi() reports 404 components, none of them the removed models), so the HTTP API surface is untouched.
  • Pre-commit (ruff, pycodestyle, pyright, import-dependency and Tool-registration checks) passes on the commit.

Video/Screenshots

N/A — internal dead-code removal with no runtime or UI behavior change; evidence is the command output above.

Type

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

Notes

  • predict_labels() and get_category() live under the internal critic/impl/api/ package and are not exported via any __all__, so this is not a public-API change.
  • The _AgentProtocol removal is safe because ResponseDispatchMixin already re-declares the same members under its own if TYPE_CHECKING: block, which is what pyright actually uses.

Agent Server images for this PR

• 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 amd64, arm64 nikolaik/python-nodejs:python3.13-nodejs22-slim 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:2382870-python

Run

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

All tags pushed for this build

ghcr.io/openhands/agent-server:2382870-golang-amd64
ghcr.io/openhands/agent-server:23828702504b3a74b0410c75018ca3e928dfb02f-golang-amd64
ghcr.io/openhands/agent-server:vasco-cleanup-dead-code-4224-golang-amd64
ghcr.io/openhands/agent-server:2382870-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:2382870-golang-arm64
ghcr.io/openhands/agent-server:23828702504b3a74b0410c75018ca3e928dfb02f-golang-arm64
ghcr.io/openhands/agent-server:vasco-cleanup-dead-code-4224-golang-arm64
ghcr.io/openhands/agent-server:2382870-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:2382870-java-amd64
ghcr.io/openhands/agent-server:23828702504b3a74b0410c75018ca3e928dfb02f-java-amd64
ghcr.io/openhands/agent-server:vasco-cleanup-dead-code-4224-java-amd64
ghcr.io/openhands/agent-server:2382870-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:2382870-java-arm64
ghcr.io/openhands/agent-server:23828702504b3a74b0410c75018ca3e928dfb02f-java-arm64
ghcr.io/openhands/agent-server:vasco-cleanup-dead-code-4224-java-arm64
ghcr.io/openhands/agent-server:2382870-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:2382870-python-amd64
ghcr.io/openhands/agent-server:23828702504b3a74b0410c75018ca3e928dfb02f-python-amd64
ghcr.io/openhands/agent-server:vasco-cleanup-dead-code-4224-python-amd64
ghcr.io/openhands/agent-server:2382870-nikolaik_s_python-nodejs_tag_python3.13-nodejs22-slim-amd64
ghcr.io/openhands/agent-server:2382870-python-arm64
ghcr.io/openhands/agent-server:23828702504b3a74b0410c75018ca3e928dfb02f-python-arm64
ghcr.io/openhands/agent-server:vasco-cleanup-dead-code-4224-python-arm64
ghcr.io/openhands/agent-server:2382870-nikolaik_s_python-nodejs_tag_python3.13-nodejs22-slim-arm64
ghcr.io/openhands/agent-server:2382870-golang
ghcr.io/openhands/agent-server:23828702504b3a74b0410c75018ca3e928dfb02f-golang
ghcr.io/openhands/agent-server:vasco-cleanup-dead-code-4224-golang
ghcr.io/openhands/agent-server:2382870-golang_tag_1.21-bookworm
ghcr.io/openhands/agent-server:2382870-java
ghcr.io/openhands/agent-server:23828702504b3a74b0410c75018ca3e928dfb02f-java
ghcr.io/openhands/agent-server:vasco-cleanup-dead-code-4224-java
ghcr.io/openhands/agent-server:2382870-eclipse-temurin_tag_17-jdk
ghcr.io/openhands/agent-server:2382870-python
ghcr.io/openhands/agent-server:23828702504b3a74b0410c75018ca3e928dfb02f-python
ghcr.io/openhands/agent-server:vasco-cleanup-dead-code-4224-python
ghcr.io/openhands/agent-server:2382870-nikolaik_s_python-nodejs_tag_python3.13-nodejs22-slim

About Multi-Architecture Support

  • Each variant tag (e.g., 2382870-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., 2382870-python-amd64) are also available if needed

Remove six symbols confirmed unreferenced across the whole tree (git grep,
absent from every __all__, no star-imports):

- _AgentProtocol (openhands-sdk/.../agent/response_dispatch.py) — only
  mentioned in a docstring, which now points at the mixin's TYPE_CHECKING
  block instead.
- ConversationResponse, GenerateTitleRequest, GenerateTitleResponse
  (openhands-agent-server/.../models.py) — not wired to any route and absent
  from the generated OpenAPI schema, so the HTTP API is unchanged; the now
  unused 'from openhands.sdk import LLM' import is dropped.
- get_category() (openhands-sdk/.../critic/impl/api/taxonomy.py)
- predict_labels() (openhands-sdk/.../critic/impl/api/client.py)

Refs #4224
@github-actions

Copy link
Copy Markdown
Contributor

Python API breakage checks — ✅ PASSED

Result: ✅ PASSED

Action log

@github-actions

Copy link
Copy Markdown
Contributor

REST API breakage checks (OpenAPI) — ✅ PASSED

Result: ✅ PASSED

Action log

@VascoSch92
VascoSch92 marked this pull request as ready for review July 27, 2026 07:31
@github-actions

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-sdk/openhands/sdk/agent
   response_dispatch.py77791%153, 203, 227, 231, 288–290
openhands-sdk/openhands/sdk/critic/impl/api
   client.py1235258%190, 196–198, 205–206, 209, 214–218, 223–227, 234–235, 238, 241–242, 245, 253, 258–260, 268, 270, 272–274, 276, 284–286, 295–296, 298–299, 311–312, 314–318, 323–325, 331–332
   taxonomy.py443814%59–60, 62–65, 67, 101, 110–114, 116, 118–120, 127, 129–130, 133–134, 137–138, 140–141, 147, 149–155, 157, 160, 166, 168
TOTAL32737412287% 

@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.

✅ QA Report: PASS

Verified the dead-code cleanup by running the affected SDK and agent-server paths before and after the PR; behavior stayed unchanged while the targeted symbols disappeared.

Does this PR achieve its stated goal?

Yes. The PR set out to remove verified dead code without changing runtime behavior. I confirmed the five targeted symbols were present on origin/main and absent on the PR branch, while a real SDK conversation, response classification, critic categorization, a live agent-server /server_info request, and the generated OpenAPI schema all behaved the same before and after.

Phase Result
Environment Setup ✅ make build completed successfully; no tests/linters/typecheckers were run locally.
CI Status 🟡 GitHub shows 23 successful, 0 failing, 7 pending, 2 skipped checks at review time.
Functional Verification ✅ Real SDK and agent-server behavior matched base; OpenAPI schemas were identical.
Functional Verification

Test 1: Targeted symbols are removed while SDK/critic behavior stays stable

Step 1 — Establish baseline on origin/main:
Ran a Python script that imported the response dispatcher, critic taxonomy/client, and agent-server models, then exercised response classification and critic categorization with concrete inputs.

Output:

{'response_dispatch': ['content', 'empty'], 'critic_categories': {'sentiment': None, 'agent_behavioral_issues': [{'name': 'did_not_follow_instruction', 'display_name': 'Did Not Follow Instruction', 'probability': 2.0}], 'user_followup_patterns': [], 'infrastructure_issues': [], 'other': []}, 'removed_symbols_available': {'get_category': True, 'predict_labels': True, 'ConversationResponse': True, 'GenerateTitleRequest': True, 'GenerateTitleResponse': True}}

This shows the old branch still exposed the targeted dead-code symbols, and the nearby runtime paths produced concrete outputs.

Step 2 — Apply the PR's changes:
Checked out vasco/cleanup-dead-code-4224 at 23828702504b3a74b0410c75018ca3e928dfb02f.

Step 3 — Re-run with the PR in place:
Ran the same script.

Output:

{'response_dispatch': ['content', 'empty'], 'critic_categories': {'sentiment': None, 'agent_behavioral_issues': [{'name': 'did_not_follow_instruction', 'display_name': 'Did Not Follow Instruction', 'probability': 2.0}], 'user_followup_patterns': [], 'infrastructure_issues': [], 'other': []}, 'removed_symbols_available': {'get_category': False, 'predict_labels': False, 'ConversationResponse': False, 'GenerateTitleRequest': False, 'GenerateTitleResponse': False}}

This confirms the symbols were removed, while response classification and critic categorization returned the same results.

Test 2: Real SDK conversation still dispatches assistant content

Step 1 — Establish baseline on origin/main:
Ran a real SDK Agent + Conversation with the configured LLM and prompt Respond with exactly QA_OK and no other text.

Output:

{'agent_reply': 'QA_OK', 'message_events': 2}

This exercises the user-facing SDK conversation path and confirms the base branch dispatches a content response normally.

Step 2 — Apply the PR's changes:
Checked out vasco/cleanup-dead-code-4224.

Step 3 — Re-run with the PR in place:
Ran the same SDK conversation.

Output:

{'agent_reply': 'QA_OK', 'message_events': 2}

This confirms the ResponseDispatchMixin cleanup did not break normal assistant-message dispatch.

Test 3: Live agent-server still serves HTTP and OpenAPI is unchanged

Step 1 — Establish baseline on origin/main:
Started the real agent server with uv run python -m openhands.agent_server --host 127.0.0.1 --port 18764, then requested /server_info and /openapi.json with curl.

Output summary:

/server_info -> 200, title "OpenHands Agent Server", version "1.37.1"
openapi_removed_components -> {'schema_count': 438, 'removed_present': {'ConversationResponse': False, 'GenerateTitleRequest': False, 'GenerateTitleResponse': False}}

This shows the base server starts and the soon-to-be-removed models were not exposed as OpenAPI components.

Step 2 — Apply the PR's changes:
Checked out vasco/cleanup-dead-code-4224.

Step 3 — Re-run with the PR in place:
Started the real agent server with uv run python -m openhands.agent_server --host 127.0.0.1 --port 18765, then requested the same endpoints.

Output summary:

/server_info -> 200, title "OpenHands Agent Server", version "1.37.1"
openapi_removed_components -> {'schema_count': 438, 'removed_present': {'ConversationResponse': False, 'GenerateTitleRequest': False, 'GenerateTitleResponse': False}}
OpenAPI comparison -> {'openapi_equal': True, 'base_schemas': 438, 'pr_schemas': 438}

This confirms the agent-server still runs and the REST/OpenAPI surface is unchanged by the model cleanup.

Issues Found

None.

This review was created by an AI agent (OpenHands) on behalf of the user.

@neubig neubig left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approved — I found no live org-internal consumers of the removed symbols. The only exact downstream artifact was the stale TypeScript Swagger snapshot, which is being removed in OpenHands/typescript-client#292.

@VascoSch92
VascoSch92 merged commit 68cd02e into main Jul 27, 2026
48 checks passed
@VascoSch92
VascoSch92 deleted the vasco/cleanup-dead-code-4224 branch July 27, 2026 09:16
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.

3 participants