Skip to content

Creating backend abstraction for self hosted worker #29

Open
ianhodge wants to merge 1 commit intomainfrom
03-10-ian_creating_backend_abstraction_for_self_hosted_worker
Open

Creating backend abstraction for self hosted worker #29
ianhodge wants to merge 1 commit intomainfrom
03-10-ian_creating_backend_abstraction_for_self_hosted_worker

Conversation

@ianhodge
Copy link
Member

@ianhodge ianhodge commented Mar 10, 2026

What

Pure refactor: introduces a Backend interface and extracts all Docker logic from worker.go into a separate DockerBackend implementation. No behavior change.

Changes

  • internal/worker/backend.go — New Backend interface with ExecuteTask and Shutdown methods
  • internal/worker/docker.goDockerBackend struct with all Docker-specific logic extracted from worker.go (image pulling, sidecar management, container lifecycle, registry auth, etc.)
  • internal/worker/worker.go — Slimmed down: Worker struct now holds a backend Backend field instead of dockerClient/platform. New() creates a DockerBackend, executeTask delegates to w.backend.ExecuteTask(), Shutdown calls w.backend.Shutdown()

Testing

  • Builds clean (go build ./...)
  • Manually verified against staging — worker connects, receives task assignments, and executes them in Docker identically to before

Overall plan: non-containerized self-hosted agents

This PR is 1 of 3 to add direct (non-Docker) execution support:

  1. PR 1 (this PR): Backend interface + Docker extraction — pure refactor to enable the next two PRs
  2. PR 2: YAML config file support (--config-file) — adds gopkg.in/yaml.v3, config parsing/merging for worker_id, cleanup, docker.volumes, docker.environment
  3. PR 3: Direct backend (--backend direct) — runs agents directly on the host via the Oz CLI, with setup/teardown scripts, per-agent workspace directories, and environment file injection

Co-Authored-By: Oz oz-agent@warp.dev

Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@ianhodge ianhodge changed the title ian/creating_backend_abstraction_for_self_hosted_worker Backend interface + Docker extraction for direct backend support Mar 10, 2026
@ianhodge ianhodge changed the title Backend interface + Docker extraction for direct backend support Creating backend abstraction for self hosted worker Mar 10, 2026
@ianhodge ianhodge requested a review from bnavetta March 10, 2026 22:39
@ianhodge ianhodge marked this pull request as ready for review March 10, 2026 22:39
// Backend defines the interface for task execution backends.
type Backend interface {
// ExecuteTask runs the agent for the given task assignment.
ExecuteTask(ctx context.Context, assignment *types.TaskAssignmentMessage) error
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should have a slight layer of abstraction between the TaskAssignmentMessage and the backend interface.

There are a couple common concerns we shouldn't have to handle in the backend implementations:

  • Resolving common environment variables, like the Git config below
  • Choosing a default Docker image (even if some backends will ignore this)
  • Determining the base CLI args (even if the full command is backend-specific)

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