Repository navigation
fix(app-conversation): allow starts in sandboxes on an older image - #903
Conversation
Coverage reportClick to see where and how coverage changed
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>
4ff402e to
14f575b
Compare
hieptl
left a comment
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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 🙏
There was a problem hiding this comment.
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
StartConversationRequesthas four new top-level fields:container,conversation_runtime,promptandworktree_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_userdoesn't pass them, so they always go out asnull. - 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 fournullfields. On 1.50.1,agent.persona,agent_settingsandobservability_parent_span_contextare dropped as well. They are alsonull, 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 🙏
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.
|
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 About the FYI in my review summary ( Thank you very much 🙏 |
|
🚀 Released in 1.76.0. |
…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.
HUMAN:
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 bareassertwith an empty error message.The start now falls back to the default sandbox spec, as
_get_agent_server_contextin the conversation router already does. The only field read from the spec isworking_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_conversationusesget_default_sandbox_spec()when the sandbox's spec isn't advertised, and logs a warning naming the image and sandbox.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 reachesREADYwith 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: