Skip to content

Fix resume reconciliation by treating litellm_extra_body as runtime override - #1115

Merged
xingyaoww merged 2 commits into
mainfrom
fix/cli-resume-litellm-extra-body
Nov 10, 2025
Merged

xingyaoww merged 2 commits into
mainfrom
fix/cli-resume-litellm-extra-body

Conversation

@enyst

@enyst enyst commented Nov 9, 2025 •

Copy link
Copy Markdown
Member

Summary

Fix CLI --resume reconciliation failures caused by runtime-injected LLM metadata (litellm_extra_body) differing from persisted JSON. The CLI injects session-specific metadata (session_id, tags, versions) at load time. On resume, strict equality vs persisted values produced spurious diffs.

Changes

  • openhands-sdk/openhands/sdk/llm/llm.py: Add "litellm_extra_body" to LLM.OVERRIDE_ON_SERIALIZE so the runtime value overrides persisted before diff.
  • tests/sdk/llm/test_llm_reconciliation.py: New test ensuring litellm_extra_body diffs are ignored and runtime value is used in reconciliation.
  • tests/cross/test_agent_reconciliation.py: Fix stray lines/IndentationError so cross test runs cleanly; covers agent reconciliation path.

Rationale

  • litellm_extra_body contains dynamic, runtime-only metadata injected by the CLI (session_id, tags, versions). These should not be treated as persisted contract. Treating it as a runtime override aligns with how secrets are handled (api_key, aws_*), avoiding false-positive diffs.

Validation

  • pre-commit (ruff format/lint, pyright, pycodestyle) passes locally.
  • New and existing unit tests pass.
  • openhands-cli test suite passes when pointed to this local SDK; programmatic resume works without diff errors.

Notes

  • This PR is minimal and focused on the diff issue.

Co-authored-by: openhands openhands@all-hands.dev

@enyst can click here to continue refining the PR


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.12-nodejs22 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:6810767-python

Run

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

All tags pushed for this build

ghcr.io/openhands/agent-server:6810767-golang-amd64
ghcr.io/openhands/agent-server:6810767-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:6810767-golang-arm64
ghcr.io/openhands/agent-server:6810767-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:6810767-java-amd64
ghcr.io/openhands/agent-server:6810767-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:6810767-java-arm64
ghcr.io/openhands/agent-server:6810767-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:6810767-python-amd64
ghcr.io/openhands/agent-server:6810767-nikolaik_s_python-nodejs_tag_python3.12-nodejs22-amd64
ghcr.io/openhands/agent-server:6810767-python-arm64
ghcr.io/openhands/agent-server:6810767-nikolaik_s_python-nodejs_tag_python3.12-nodejs22-arm64
ghcr.io/openhands/agent-server:6810767-golang
ghcr.io/openhands/agent-server:6810767-java
ghcr.io/openhands/agent-server:6810767-python

About Multi-Architecture Support

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

enyst added 2 commits November 9, 2025 04:59
…n\nFix resume reconciliation error when CLI injects dynamic metadata (session_id, tags, versions) into LLM.litellm_extra_body at load time.\n\nBy adding 'litellm_extra_body' to OVERRIDE_ON_SERIALIZE, resolve_diff_from_deserialized now prefers the runtime value and avoids spurious diffs.\n\nCo-authored-by: openhands <openhands@all-hands.dev>
…ody and fix broken cross test\n\n- New unit test ensures resolve_diff_from_deserialized ignores dynamic litellm_extra_body diffs\n- Fix stray lines causing IndentationError in cross test\n\nCo-authored-by: openhands <openhands@all-hands.dev>
@github-actions

github-actions Bot commented Nov 9, 2025

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-sdk/openhands/sdk/llm
   llm.py43817659%309, 313, 318, 322, 326, 330–332, 336–337, 348–349, 351–352, 356, 373, 398, 403, 407, 412, 432, 461, 482, 486, 501, 507–508, 527–528, 536, 561–566, 587–588, 591, 595, 607, 612–615, 622, 625, 633–638, 642–645, 647, 660, 664–666, 668–669, 674–675, 677, 684, 687–692, 760–763, 768–772, 774–779, 781–783, 792–794, 797–798, 839–840, 843–846, 887, 901, 951, 954–956, 959–967, 971–973, 976, 979–981, 988–989, 998, 1005–1007, 1011, 1013–1018, 1020–1037, 1040–1044, 1046–1047, 1053–1062, 1075, 1089, 1094
TOTAL11801542854% 

@enyst
enyst marked this pull request as ready for review November 9, 2025 06:17
@blacksmith-sh

blacksmith-sh Bot commented Nov 10, 2025

Copy link
Copy Markdown
Contributor

[Automatic Post]: I have assigned @CLFutureX as a reviewer based on git blame information. Thanks in advance for the help!

@xingyaoww xingyaoww left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM Thanks!

@xingyaoww
xingyaoww merged commit 9b7799b into main Nov 10, 2025
@xingyaoww
xingyaoww deleted the fix/cli-resume-litellm-extra-body branch November 10, 2025 14:15
StressTestor pushed a commit to StressTestor/software-agent-sdk that referenced this pull request Jun 1, 2026
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