Skip to content

fix(app-conversation): allow starts in sandboxes on an older image - #903

Merged
hieptl merged 4 commits into
mainfrom
fix/start-conversation-unadvertised-sandbox-spec
Oct 22, 2026
Merged

hieptl merged 4 commits into
mainfrom
fix/start-conversation-unadvertised-sandbox-spec

Conversation

@jpshackelford

@jpshackelford jpshackelford commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

HUMAN:

  • A human has tested these changes.

AGENT:


Why

A conversation can't be started in a sandbox that was created before an agent-server image bump. Runtime-api advertises only the current image, so the sandbox's spec lookup returns None, and the start failed on a bare assert with an empty error message.

The start now falls back to the default sandbox spec, as _get_agent_server_context in the conversation router already does. The only field read from the spec is working_dir, and the default spec has the same one. If there is no default spec either, the start task fails with that error's message instead of an empty one.

This is the first of three PRs planned in #902. The shared helper for the other callers and the grouping change are separate.

Summary

  • _start_app_conversation uses get_default_sandbox_spec() when the sandbox's spec isn't advertised, and logs a warning naming the image and sandbox.
  • Two tests in test_live_status_app_conversation_service.py.

Issue Number

Refs #902

How to Test

tests/unit/app_server/test_live_status_app_conversation_service.py: a start in a sandbox whose image the runtime-api spec service no longer lists reaches READY with the default spec's working directory, and a start with no spec at all fails with the error's message.

Video/Screenshots

None (backend only).

This PR was drafted by an AI agent on behalf of the user.

@jpshackelford can click here to continue refining the PR


Enterprise server image for this PR:

ghcr.io/openhands/enterprise-server:sha-9a54b3f

@jpshackelford jpshackelford added the type: fix A bug fix label Oct 20, 2026
@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  openhands/app_server/app_conversation
  live_status_app_conversation_service.py
Project Total  

This report was generated by python-coverage-comment-action

Runtime-api advertises only the current agent-server image, so a sandbox
created before an image bump has no sandbox spec and the start failed on a
bare assert with an empty error. Fall back to the default spec, as the
conversation router already does; only working_dir is read from it.

Refs #902

Co-authored-by: openhands <openhands@all-hands.dev>
@jpshackelford
jpshackelford force-pushed the fix/start-conversation-unadvertised-sandbox-spec branch from 4ff402e to 14f575b Compare October 20, 2026 14:48
@jpshackelford
jpshackelford marked this pull request as ready for review October 20, 2026 14:49
@jpshackelford jpshackelford added the qa-this Run automated functional QA label Oct 20, 2026

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

Hello John-Mason,

Overall: Non-blocking. No blockers from my side.

Thank you for the detailed write-up in #902, it made the change easy to follow. The fallback matches what _get_agent_server_context already does, and as far as I can tell the start path reads only working_dir from the spec. I ran the two new tests locally. Both pass on this branch, and both fail when I revert the change in _start_app_conversation: the first ends in ERROR instead of READY, and the second gets detail=''. So they cover the bug nicely.

I left 4 comments. None of them are blocking, and please feel free to push back on any of them:

  • Non-blocking (question): has the 1.56.0 → 1.55.1 cross-version check been run? #876 is already on main, and these starts now go through.
  • Non-blocking (suggestion): name the fallback spec in the log, since custom runtime-api configs can set their own working_dir.
  • Non-blocking (suggestion) and Non-blocking (nit): two small ideas for how the first test is set up.

One small FYI outside the diff: for an old stock image like agent-server:1.55.1-python, is_custom_sandbox_spec() returns True. So if an old agent-server rejects the create request, the error calls it a "custom sandbox image". The advice to re-pin still fits, but the wording might confuse someone. It could fit the PR 2 helper, and it's completely fine to leave as is.

Thank you very much 🙏

sandbox_id,
)
sandbox_spec = (
await self.sandbox_spec_service.get_default_sandbox_spec()

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.

Hello John-Mason,

Non-blocking (question)

If I'm reading this right, a start in an old-image sandbox used to fail here and will now go through. The app-server then sends a request built with SDK 1.56.0 (#876 is on main and merged into this branch) to whatever agent-server version the sandbox runs. I looked at the 1.55.1 models. StartConversationRequest doesn't set extra, and LLM uses extra='ignore'. So a field the old server doesn't know would be dropped quietly rather than rejected, and a start could reach READY without a setting the user expects.

#902 mentions repeating the cross-version check before the 1.56.0 bump. Do you know if it has been run for 1.56.0 → 1.55.1? If not, what do you think about running it before this ships, or noting in the PR which fields an older server would drop? I may be missing some context here, so I'm happy to be corrected.

Thank you very much 🙏

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.

Hello John-Mason,

Following up on my own question. #936 has since moved main to SDK 1.57.0, so I ran the check from 1.57.0 instead.

  • Schema diff. Compared with 1.56.0 and 1.55.1, the 1.57.0 StartConversationRequest has four new top-level fields: container, conversation_runtime, prompt and worktree_options. Every nested model (agent, LLM, tools, condensers, hooks, MCP, critics, security analyzers) and every discriminator value is the same. 1.56.0 and 1.55.1 have identical request schemas.
  • The app-server never sets those four fields. ConversationSettings.create_request() in 1.57.0 doesn't fill them, and _build_start_conversation_request_for_user doesn't pass them, so they always go out as null.
  • Round trip. A request built with 1.57.0 through ConversationSettings.create_request() validates on the 1.57.0, 1.56.0, 1.55.1 and 1.50.1 server models. On 1.56.0 and 1.55.1, the only keys dropped are those four null fields. On 1.50.1, agent.persona, agent_settings and observability_parent_span_context are dropped as well. They are also null, and the app-server doesn't set them either.

So at the schema level, an older agent-server wouldn't silently drop anything the app-server actually sets. Like the check in #902, this isn't an end-to-end test, and it doesn't cover behavior changes inside the agent-server itself. There's no code change for this thread.

Thank you very much 🙏

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

Thank you! 🙏

@henriquehirako
henriquehirako removed the request for review from all-hands-bot October 20, 2026 21:00
lilagrc and others added 2 commits October 21, 2026 13:32
runtime-api warm configs can set their own working_dir, and an admin can
change a config's image in place. A sandbox left on the previous image then
falls back to the default spec and starts in the default's directory. The
warning now names that spec and its working_dir, so a mismatch shows up in
one log line.

- Log after get_default_sandbox_spec() resolves, with the spec id and
  working_dir.
- In the old-image start test, mock get_sandbox_spec and
  get_default_sandbox_spec instead of patching httpx.AsyncClient for the
  whole start. TestGetSandboxSpec.test_returns_none_for_unknown_id already
  covers the runtime-api spec service returning None for an unknown image.
- Drop the MagicMock and DynamicRemoteSandboxSpecService imports that this
  made unused. This also clears the import-order error that the main merge
  left in this file.
@hieptl

hieptl commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Hello John-Mason,

I pushed 9a54b3f to this branch. It addresses three of the review threads (replies are inline), and it fixes the Lint python failure on 73d24cb. The main merge had kept both conflicting imports in the test file but left them out of order. The branch already includes the latest main, so there are no conflicts.

About the FYI in my review summary (is_custom_sandbox_spec() calls an older stock image like agent-server:1.55.1-python "custom"), I didn't change it here. It only affects the wording of the error raised when the agent-server rejects the create request. The diagnosis in that message, an openhands-sdk mismatch with this release, is still right for an older stock image. Fixing the wording means telling stock images apart from custom ones. I think that fits better with the shared helper planned for PR 2 in #902 than with this small, backport-friendly fix.

Thank you very much 🙏

@hieptl
hieptl merged commit 408b72b into main Oct 22, 2026
24 checks passed
@hieptl
hieptl deleted the fix/start-conversation-unadvertised-sandbox-spec branch October 22, 2026 05:01
@openhands-release-bot openhands-release-bot Bot added the released: 1.76.0 Shipped in 1.76.0 label Oct 22, 2026
@openhands-release-bot

Copy link
Copy Markdown
Contributor

🚀 Released in 1.76.0.

hieptl added a commit that referenced this pull request Oct 23, 2026
…ack (#965)

* fix(sandbox): resolve an existing sandbox's spec with a default fallback

Runtime-api advertises only the current agent-server image, so after an
image bump every sandbox created on the previous image has no sandbox
spec. #903 handled that for conversation start. The other callers that
look up an existing sandbox's spec each handled the missing spec in their
own way: the conversation router fell back with a generic warning, the
file-read endpoint returned an empty string, the post-resume git identity
restore raised and was swallowed, and archive path resolution raised for
conversations without a pinned workspace path. All of them read only
working_dir from the spec, which the default spec shares.

- Add resolve_existing_sandbox_spec() next to resolve_sandbox_spec(): the
  sandbox's own spec when it is still advertised, otherwise the default
  spec plus a warning naming the image, the sandbox and the pick.
- Use it in _start_app_conversation, _get_agent_server_context,
  read_conversation_file, _restore_git_user_settings_after_resume and
  _resolve_archive_path.
- Cover the helper and each caller on a sandbox whose image is no longer
  advertised.

Refs #902

* refactor(sandbox): move resolve_existing_sandbox_spec onto SandboxSpecService

Make the existing-sandbox spec lookup a method on SandboxSpecService,
next to get_default_sandbox_spec, instead of a module-level helper that
takes the service as an argument. The warning now comes from the spec
service's own logger, so callers no longer pass one in.

Caller tests mock the new method; the tests for a sandbox whose image is
no longer advertised use a PresetSandboxSpecService, so they still run
the real fallback through each caller.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

qa-this Run automated functional QA released: 1.76.0 Shipped in 1.76.0 type: fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants