Skip to content

Fix _GatedLLM.completion override after _return_metrics removal#3794

Closed
VascoSch92 wants to merge 1 commit into
mainfrom
fix/goal-loop-test-return-metrics-signature
Closed

Fix _GatedLLM.completion override after _return_metrics removal#3794
VascoSch92 wants to merge 1 commit into
mainfrom
fix/goal-loop-test-return-metrics-signature

Conversation

@VascoSch92

@VascoSch92 VascoSch92 commented Jun 18, 2026

Copy link
Copy Markdown
Member

Problem

Pre-commit (pyright) fails on main/rel-1.29.0 with two errors in tests/agent_server/test_goal_loop.py:

test_goal_loop.py:42 - error: Method "completion" overrides class "TestLLM" in an incompatible manner
test_goal_loop.py:58 - error: Expected 4 positional arguments (reportCallIssue)

This is a logical merge conflict between two independently-green changes that landed on 2026-06-18:

  • 2bedbd8f "Remove acp_env and _return_metrics deprecations (removed_in 1.29.0)" — deleted the _return_metrics parameter from LLM.completion / TestLLM.completion (now 4 positional params).
  • feat(agent-server): add /goal agent-server endpoint, background loop, and stop/resume #3770 "add /goal agent-server endpoint…" — added test_goal_loop.py, whose _GatedLLM.completion was written against the old signature (with _return_metrics) and was CI'd before the removal merged.

Neither PR was red on its own; the combined tree is the first place pyright type-checks both together.

Fix

Drop _return_metrics from the _GatedLLM.completion override — both the signature and the super().completion(...) call — to match the current 4-positional signature. No behavior change.


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:5239de8-python

Run

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

All tags pushed for this build

ghcr.io/openhands/agent-server:5239de8-golang-amd64
ghcr.io/openhands/agent-server:5239de8a6dd65a9e6082d100d48a11b6bbb27db3-golang-amd64
ghcr.io/openhands/agent-server:fix-goal-loop-test-return-metrics-signature-golang-amd64
ghcr.io/openhands/agent-server:5239de8-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:5239de8-golang-arm64
ghcr.io/openhands/agent-server:5239de8a6dd65a9e6082d100d48a11b6bbb27db3-golang-arm64
ghcr.io/openhands/agent-server:fix-goal-loop-test-return-metrics-signature-golang-arm64
ghcr.io/openhands/agent-server:5239de8-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:5239de8-java-amd64
ghcr.io/openhands/agent-server:5239de8a6dd65a9e6082d100d48a11b6bbb27db3-java-amd64
ghcr.io/openhands/agent-server:fix-goal-loop-test-return-metrics-signature-java-amd64
ghcr.io/openhands/agent-server:5239de8-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:5239de8-java-arm64
ghcr.io/openhands/agent-server:5239de8a6dd65a9e6082d100d48a11b6bbb27db3-java-arm64
ghcr.io/openhands/agent-server:fix-goal-loop-test-return-metrics-signature-java-arm64
ghcr.io/openhands/agent-server:5239de8-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:5239de8-python-amd64
ghcr.io/openhands/agent-server:5239de8a6dd65a9e6082d100d48a11b6bbb27db3-python-amd64
ghcr.io/openhands/agent-server:fix-goal-loop-test-return-metrics-signature-python-amd64
ghcr.io/openhands/agent-server:5239de8-nikolaik_s_python-nodejs_tag_python3.13-nodejs22-slim-amd64
ghcr.io/openhands/agent-server:5239de8-python-arm64
ghcr.io/openhands/agent-server:5239de8a6dd65a9e6082d100d48a11b6bbb27db3-python-arm64
ghcr.io/openhands/agent-server:fix-goal-loop-test-return-metrics-signature-python-arm64
ghcr.io/openhands/agent-server:5239de8-nikolaik_s_python-nodejs_tag_python3.13-nodejs22-slim-arm64
ghcr.io/openhands/agent-server:5239de8-golang
ghcr.io/openhands/agent-server:5239de8a6dd65a9e6082d100d48a11b6bbb27db3-golang
ghcr.io/openhands/agent-server:fix-goal-loop-test-return-metrics-signature-golang
ghcr.io/openhands/agent-server:5239de8-golang_tag_1.21-bookworm
ghcr.io/openhands/agent-server:5239de8-java
ghcr.io/openhands/agent-server:5239de8a6dd65a9e6082d100d48a11b6bbb27db3-java
ghcr.io/openhands/agent-server:fix-goal-loop-test-return-metrics-signature-java
ghcr.io/openhands/agent-server:5239de8-eclipse-temurin_tag_17-jdk
ghcr.io/openhands/agent-server:5239de8-python
ghcr.io/openhands/agent-server:5239de8a6dd65a9e6082d100d48a11b6bbb27db3-python
ghcr.io/openhands/agent-server:fix-goal-loop-test-return-metrics-signature-python
ghcr.io/openhands/agent-server:5239de8-nikolaik_s_python-nodejs_tag_python3.13-nodejs22-slim

About Multi-Architecture Support

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

The `_return_metrics` parameter was removed from LLM/TestLLM.completion in
2bedbd8 (removed_in 1.29.0), but tests/agent_server/test_goal_loop.py's
_GatedLLM override (added later in #3770) still declared it as a positional
param and forwarded it to super().completion(), which pyright flagged as
an incompatible override and a 5-positional call against a 4-positional
signature. Drop _return_metrics to match the current signature.
@github-actions

Copy link
Copy Markdown
Contributor

Python API breakage checks — ✅ PASSED

Result:PASSED

Action log

@VascoSch92 VascoSch92 requested a review from enyst June 18, 2026 15:00
@VascoSch92 VascoSch92 marked this pull request as ready for review June 18, 2026 15:00
@github-actions

Copy link
Copy Markdown
Contributor

REST API breakage checks (OpenAPI) — ✅ PASSED

Result:PASSED

Action log

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

🍰

@VascoSch92 VascoSch92 enabled auto-merge (squash) June 18, 2026 15:01
@github-actions

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
TOTAL328131419456% 
report-only-changed-files is enabled. No files were changed during this commit :)

@VascoSch92

Copy link
Copy Markdown
Member Author

Closing — this targeted main, but the _return_metrics removal only exists on rel-1.29.0, not main. On main the parameter still exists, so this override is already correct there and this change would have introduced a pyright failure (which the PR's own pre-commit caught). Redone correctly against the release branch in #3795.

@VascoSch92 VascoSch92 closed this Jun 18, 2026
auto-merge was automatically disabled June 18, 2026 15:06

Pull request was closed

@VascoSch92 VascoSch92 deleted the fix/goal-loop-test-return-metrics-signature branch June 18, 2026 15:06

@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: FAIL

The PR removes _return_metrics from _GatedLLM.completion, but the actual PR base still expects that parameter and the changed helper regresses the current completion call shape.

Does this PR achieve its stated goal?

No. The stated goal is to align _GatedLLM.completion with TestLLM.completion after _return_metrics removal, but in this PR's checked-out base/head environment TestLLM.completion still includes _return_metrics. Exercising the current positional completion signature succeeds on the base commit and raises a TypeError on the PR head; the existing CI pre-commit check also reports the same incompatible override.

Phase Result
Environment Setup make build completed successfully and installed the uv-managed dev environment.
CI Status ❌ PR is closed unmerged; existing checks show pre-commit failed with pyright override errors and PR description validation failed.
Functional Verification ❌ The PR head fails a completion call shape that works on the base commit.
Functional Verification

Test 1: Current TestLLM.completion positional call shape

Step 1 — Reproduce / establish baseline without the fix:
Checked out base commit 9e290793addcf7397bce315b8c85803a8b70f804 and ran a scripted _GatedLLM.completion(...) call using the current positional signature:

uv run python - <<'PY'
from openhands.sdk.llm import Message
from tests.agent_server.test_goal_loop import _GatedLLM

def on_token(token: str) -> None:
    pass

llm = _GatedLLM(model='test-model')
llm.__pydantic_private__['_scripted_responses'].append(
    Message(role='assistant', content='Hello from scripted LLM')
)
response = llm.completion(
    [Message(role='user', content='Say hello')],
    None,
    False,
    True,
    on_token,
)
print('response_type', type(response).__name__)
print('message_text', response.message.content[0].text)
PY

Observed:

response_type LLMResponse
message_text Hello from scripted LLM

This shows the base helper accepts the current TestLLM.completion positional call shape and returns the scripted LLM response.

Step 2 — Apply the PR's changes:
Checked out fix/goal-loop-test-return-metrics-signature at 5239de8a6dd65a9e6082d100d48a11b6bbb27db3.

Step 3 — Re-run with the fix in place:
Ran the same scripted completion call on the PR head:

Traceback (most recent call last):
  File "<stdin>", line 11, in <module>
TypeError: _GatedLLM.completion() takes from 2 to 5 positional arguments but 6 were given

This shows the PR head does not align with the actual base signature in this checkout; it rejects a call shape that worked before.

Test 2: Runtime signature alignment

On PR head, I inspected the runtime signatures without running pyright:

TestLLM.completion (self, messages: 'list[Message]', tools: 'Sequence[ToolDefinition] | None' = None, _return_metrics: 'bool' = False, add_security_risk_prediction: 'bool' = False, on_token: 'TokenCallbackType | None' = None, **kwargs: 'Any') -> 'LLMResponse'
_GatedLLM.completion (self, messages, tools=None, add_security_risk_prediction=False, on_token=None, **kwargs)

This confirms the PR head's override is missing _return_metrics while the base class still has it in this PR context.

Existing CI observation

I did not rerun tests, pre-commit, linters, or pyright locally. I only inspected the existing GitHub check log, which reports:

Type check with pyright..................................................Failed
/home/runner/work/software-agent-sdk/software-agent-sdk/tests/agent_server/test_goal_loop.py:42:9 - error: Method "completion" overrides class "TestLLM" in an incompatible manner
  Positional parameter count mismatch; base method has 7, but override has 6

Issues Found

  • 🔴 Blocker: The PR does not achieve its goal in the actual PR base/head context: _GatedLLM.completion no longer matches TestLLM.completion, and a real scripted completion call using the current positional signature now raises TypeError.

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

messages,
tools=None,
_return_metrics=False,
add_security_risk_prediction=False,

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.

🔴 Critical: Functional QA shows this override no longer accepts the current TestLLM.completion positional signature in this PR's base. Calling _GatedLLM.completion(messages, None, False, True, on_token) succeeds on the base commit but raises TypeError: _GatedLLM.completion() takes from 2 to 5 positional arguments but 6 were given on this head. The existing CI pyright log reports the same mismatch: the base method still has _return_metrics in this PR context, so this change does not achieve the stated goal.

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

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.

4 participants