Skip to content

wip: import agent run into devbox - #4785

Open
zreigz wants to merge 4 commits into
masterfrom
lukasz/prod-5485-import-agent-run-into-devbox
Open

zreigz wants to merge 4 commits into
masterfrom
lukasz/prod-5485-import-agent-run-into-devbox

Conversation

@zreigz

@zreigz zreigz commented Dec 2, 2026

Copy link
Copy Markdown
Member

Test Plan

Test environment: https://console.your-env.onplural.sh/

Checklist

  • I have added a meaningful title and summary to convey the impact of this PR to a user.
  • If required, I have updated the Plural documentation accordingly.
  • I have added tests to cover my changes.
  • I have deployed the agent to a test environment and verified that it works as expected (required only when changing agent code).

Plural Flow: console

@zreigz
zreigz requested review from a team as code owners December 2, 2026 15:32
@linear

linear Bot commented Dec 2, 2026

Copy link
Copy Markdown

PROD-5485

@zreigz
zreigz requested a balanced review from Copilot and removed request for a team December 2, 2026 15:37
@greptile-apps

greptile-apps Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5RetriggerView in Greptile

[Medium impact] The change reaches the agent-run page and the selected devbox’s session store.

Fix repeated imports overwriting newer saved history before merging.

Findings

  1. P1 Reimport overwrites newer history ▶
  2. P2 Unwritable devboxes appear ▶
  3. P2 Imports waste Console memory ▶

Summary

Adds an “Open in devbox” action for agent runs with uploaded sessions.

  • An uploaded agent run can continue as a thread in a running devbox.

Reviews (1) · Last reviewed commit: "import agent run into devbox" · Reviewed by Greptile

@zreigz zreigz added the enhancement New feature or request label Dec 2, 2026
Comment thread lib/console/devboxes/threads.ex Resolved
Comment thread lib/console/schema/workbench.ex Resolved
Comment thread lib/console/devboxes/session_archive.ex Resolved

Copilot AI 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.

🟡 Changes recommended

A critical authorization flaw remains where for_writer/2 treats globally readable workbenches as writable via Rbac.globally_readable/3, potentially exposing instances through DevboxInstance.for_writable_workbenches/2, so the change needs correction before approval.

1 open issue
12 files not reviewed
  • go/deployment-operator/pkg/devbox/api/v1/control.pb.go: Generated file
  • go/deployment-operator/pkg/devbox/api/v1/control_grpc.pb.go: Generated file
  • go/deployment-operator/pkg/devbox/api/v1/daemon.pb.go: Generated file
  • go/deployment-operator/pkg/devbox/api/v1/daemon_grpc.pb.go: Generated file
  • go/deployment-operator/pkg/devbox/api/v1/gateway.pb.go: Generated file
  • go/deployment-operator/pkg/devbox/api/v1/gateway_grpc.pb.go: Generated file
  • go/kubernetes-agent/kas/pkg/devbox/api/v1/control.pb.go: Generated file
  • go/kubernetes-agent/kas/pkg/devbox/api/v1/control_grpc.pb.go: Generated file
  • go/kubernetes-agent/kas/pkg/devbox/api/v1/daemon.pb.go: Generated file
  • go/kubernetes-agent/kas/pkg/devbox/api/v1/daemon_grpc.pb.go: Generated file
  • go/kubernetes-agent/kas/pkg/devbox/api/v1/gateway.pb.go: Generated file
  • go/kubernetes-agent/kas/pkg/devbox/api/v1/gateway_grpc.pb.go: Generated file
What changed in this PR

Implements an end-to-end flow to import an Agent Run session into a running Devbox instance by seeding the run’s uploaded session archive into the Devbox agent store, then importing/resuming it as a Devbox thread, with new RPCs, GraphQL API surface area, and a Console UI entrypoint.

Changes:

  • Add SeedAgentSession RPCs and wire them through gateway/daemon/control layers.
  • Add backend domain + GraphQL query/mutation to import an Agent Run into Devbox and list compatible instances.
  • Add Console UI (“Open in devbox”) and regenerate GraphQL/protobuf client artifacts.
File Description
test/​support/​devbox_control.ex Extends the devbox control test support to include the new seed_agent_session/2 behavior.
test/​console/​devboxes/​threads_test.exs Adds tests covering importing an agent run into a devbox thread and selecting compatible instances.
schema/​schema.graphql Updates the GraphQL schema to expose compatible devbox instance discovery and an agent-run-to-devbox import mutation.
proto/​devbox/​v1/​gateway.proto Adds the SeedAgentSession RPC to the gateway service definition.
proto/​devbox/​v1/​daemon.proto Adds the SeedAgentSession RPC to the daemon service definition.
proto/​devbox/​v1/​control.proto Introduces control-layer request/response types for seeding agent sessions and extends import metadata (e.g., cwd).
lib/​grpc/​devbox/​v1/​gateway.pb.ex Regenerates Elixir gRPC/protobuf bindings for the gateway API changes.
lib/​grpc/​devbox/​v1/​daemon.pb.ex Regenerates Elixir gRPC/protobuf bindings for the daemon API changes.
lib/​grpc/​devbox/​v1/​control.pb.ex Regenerates Elixir gRPC/protobuf bindings for new control messages and fields.
lib/​console/​schema/​workbench.ex Adds/updates workbench query helpers used to determine writer access for devbox compatibility filtering.
lib/​console/​schema/​devbox_instance.ex Adds instance scoping to return instances tied to writable workbenches for compatibility checks.
lib/​console/​graphql/​resolvers/​deployments/​devbox.ex Implements resolvers for listing compatible devbox instances and importing an agent run into devbox.
lib/​console/​graphql/​deployments/​devbox.ex Wires new devbox-related GraphQL fields into the schema, including authorization/middleware as needed.
lib/​console/​devboxes/​threads.ex Implements the domain flow to seed an agent session and import/resume it as a devbox thread, plus compatibility logic.
lib/​console/​devboxes/​session_archive.ex Adds functionality to download and parse the agent-run session archive/manifest used during import.
lib/​console/​devboxes/​control/​grpc.ex Adds gRPC client support for seed_agent_session and passes new import parameters to the control plane.
lib/​console/​devboxes/​control.ex Extends the control behaviour/interface to support seeding agent sessions.
js/​console/​src/​graph/​devbox.graphql Adds GraphQL documents for compatible instance listing and agent-run import to devbox.
js/​console/​src/​generated/​persisted-queries/​client.json Updates persisted query artifacts to include the new devbox import operations.
js/​console/​src/​generated/​graphql.ts Regenerates TypeScript GraphQL types/hooks for the new schema operations.
js/​console/​src/​generated/​graphql-operations.ts Regenerates/exports the new GraphQL operation definitions for client usage.
js/​console/​src/​generated/​graphql-documents.ts Regenerates the compiled GraphQL document nodes for the new query and mutation.
js/​console/​src/​components/​ai/​agent-runs/​details/​AIAgentRunDevboxButton.tsx Adds a UI control/modal to select a devbox instance and trigger importing the agent run into it.
js/​console/​src/​components/​ai/​agent-runs/​details/​AIAgentRun.tsx Integrates the new devbox import button into the agent run details page.
go/​kubernetes-agent/​kas/​pkg/​devbox/​api/​v1/​gateway.pb.go Regenerates KAS-side Go protobuf bindings for the gateway API updates.
go/​kubernetes-agent/​kas/​pkg/​devbox/​api/​v1/​gateway_grpc.pb.go Regenerates KAS-side Go gRPC stubs for the gateway service updates.
go/​kubernetes-agent/​kas/​pkg/​devbox/​api/​v1/​daemon.pb.go Regenerates KAS-side Go protobuf bindings for the daemon API updates.
go/​kubernetes-agent/​kas/​pkg/​devbox/​api/​v1/​daemon_grpc.pb.go Regenerates KAS-side Go gRPC stubs for the daemon service updates.
go/​kubernetes-agent/​kas/​pkg/​devbox/​api/​v1/​control_grpc.pb.go Regenerates KAS-side Go gRPC stubs for the control service updates.
go/​deployment-operator/​pkg/​devbox/​gateway/​core/​server.go Implements gateway forwarding for the new seed-agent-session RPC to the running daemon.
go/​deployment-operator/​pkg/​devbox/​daemon/​rpc.go Implements the daemon RPC handler for seeding an agent session and returning metadata.
go/​deployment-operator/​pkg/​devbox/​daemon/​agents/​threads.go Updates thread import behavior to support cwd and constrain/normalize imported session working directory behavior.
go/​deployment-operator/​pkg/​devbox/​daemon/​agents/​sessionseed.go Adds the session seeding implementation to restore/download agent-run archives into the agent’s native session store.
go/​deployment-operator/​pkg/​devbox/​daemon/​agents/​sessionseed_test.go Adds unit tests validating session seeding behavior across supported import paths and providers.
go/​deployment-operator/​pkg/​devbox/​api/​v1/​gateway.pb.go Regenerates deployment-operator Go protobuf bindings for the gateway API updates.
go/​deployment-operator/​pkg/​devbox/​api/​v1/​gateway_grpc.pb.go Regenerates deployment-operator Go gRPC stubs for the gateway service updates.
go/​deployment-operator/​pkg/​devbox/​api/​v1/​daemon.pb.go Regenerates deployment-operator Go protobuf bindings for the daemon API updates.
go/​deployment-operator/​pkg/​devbox/​api/​v1/​daemon_grpc.pb.go Regenerates deployment-operator Go gRPC stubs for the daemon service updates.
go/​deployment-operator/​pkg/​devbox/​api/​v1/​control.pb.go Regenerates deployment-operator Go protobuf bindings for new control messages/fields.
go/​deployment-operator/​pkg/​devbox/​api/​v1/​control_grpc.pb.go Regenerates deployment-operator Go gRPC stubs for the control service updates.

Review effort: Balanced
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.

Comment thread lib/console/schema/workbench.ex Resolved
zreigz and others added 3 commits December 2, 2026 16:59
Global read access no longer lists instances the user cannot write, and reading the session manifest no longer loads the rest of the archive.
Sandbox egress DNS cannot resolve object-store hosts, so the gateway fetches session_url and forwards archive bytes for the daemon to plant.

Co-authored-by: Cursor <cursoragent@cursor.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants