fix(kernel): send profile as object so KERNEL_PROFILE_NAME works#1474
Open
boatri wants to merge 1 commit into
Open
fix(kernel): send profile as object so KERNEL_PROFILE_NAME works#1474boatri wants to merge 1 commit into
boatri wants to merge 1 commit into
Conversation
connect_kernel() serialized the create-browser `profile` field as a bare
string, but Kernel's API expects an object (`{ name, save_changes }`). Every
open with KERNEL_PROFILE_NAME set was rejected at JSON-decode time with a 400
("cannot unmarshal string into ... profile of type map[string]json.RawMessage"),
regardless of whether the profile existed.
Send `{ name, save_changes: true }`. save_changes defaults to true so cookies/
logins persist across sessions, matching the documented profile behavior (the
SDK's own default is false, which would silently not persist).
Add unit tests covering the object shape and the unset/empty cases.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
@boatri is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1473
Summary
connect_kernel()sent the create-browserprofilefield as a bare string; Kernel's API expects an object ({ name, save_changes }), so every open withKERNEL_PROFILE_NAMEset failed with a 400 at JSON-decode time.{ name, save_changes: true }instead.save_changesdefaults totrueso cookies/logins persist across sessions, matching the documented profile behavior (the SDK default isfalse, which would load the profile but silently never persist).kernel_profile_from_env()helper and add unit tests for the object shape and the unset/empty cases.Why
With
KERNEL_PROFILE_NAMEset,agent-browser openalways failed:The API expects the
@onkernel/sdkBrowserProfileshape ({ id?, name?, save_changes? }), not a string. Posting toPOST /browsersdirectly with the same pre-existing profile, varying only theprofilefield:profilevalue"my-profile"(string, old behavior)cannot unmarshal string into ... profile{ "name": "my-profile", "save_changes": true }(this PR)So the string is rejected at decode time regardless of whether the profile exists — purely a serialization mismatch.
Test plan
cargo fmt --manifest-path cli/Cargo.toml -- --checkcargo clippy --manifest-path cli/Cargo.toml -- -D warnings(clean)cargo test --manifest-path cli/Cargo.toml— new unit tests pass:test_kernel_profile_from_env_is_object_not_stringtest_kernel_profile_from_env_unset_or_emptyKERNEL_PROFILE_NAME=<profile> agent-browser open …now returns 200 (was 400)localStoragein session A, closed, reopened the same profile in session B → value persisted (confirmssave_changes: true)