> For the complete documentation index, see [llms.txt](/llms.txt).
> A full single-fetch corpus is available at [llms-full.txt](/llms-full.txt).
---
last_verified: 2026-10-09
title: Worker
description: Create a Go worker, register every component explicitly, and connect it to AGNT5
category: Go SDK
hideRightSidebar: true
---

A worker is the process that runs your components. It registers them with AGNT5, receives runs, and executes them. `agnt5 dev` starts it locally and `agnt5 deploy` runs it in an environment, both using the command in `agnt5.yaml`.

## `agnt5.NewWorker(serviceName, opts...)`

```go
func main() {
	worker := agnt5.NewWorker("support", agnt5.WithServiceVersion("1.0.0"))

	must(agnt5.RegisterFunction(worker, "send_email", sendEmail))
	must(agnt5.RegisterWorkflow(worker, "onboarding", onboarding))
	must(agnt5.RegisterTool(worker, getWeather))
	must(agnt5.RegisterAgent(worker, supportAgent))

	if err := worker.Run(context.Background()); err != nil {
		log.Fatal(err)
	}
}

func must(err error) {
	if err != nil {
		log.Fatal(err)
	}
}
```

| Option | Description |
|---|---|
| `WithServiceVersion(version)` | A version string for this worker, shown with its components. |
| `WithCoordinatorEndpoint(endpoint)` | The AGNT5 coordinator to connect to. `agnt5 dev` and deployments configure it for you. |

## Registering components

Every component is registered explicitly before `worker.Run`:

| Component | Register with |
|---|---|
| Function | `agnt5.RegisterFunction(worker, name, handler, opts...)` |
| Workflow | `agnt5.RegisterWorkflow(worker, name, handler, opts...)` |
| Tool | `agnt5.RegisterTool(worker, tool)` |
| Agent | `agnt5.RegisterAgent(worker, agent)` |

To check what registered, run `agnt5 components --dev` while `agnt5 dev` is running.

## `worker.Run(ctx)`

Connects to AGNT5, registers the components, and serves runs until the process stops.

## `agnt5.yaml`

```yaml
name: support
language: go
worker:
  command: "go run ."
```

## Next steps

* [Getting started](/sdk/go/getting-started.md): a complete project with a worker.
* [Local development](/docs/build/local-development.md): run the worker with `agnt5 dev`.
* [Deploying](/docs/run/deploying.md): run it in an environment.
