CodeWorker

org.llm4s.codegen.CodeWorker
See theCodeWorker companion object
class CodeWorker(sourceDirectory: String, imageName: String, hostPort: Int, client: LLMClient, extraAllowedCommands: Set[String], sandboxConfig: Option[WorkspaceSandboxConfig], containerOptions: ContainerOptions) extends AutoCloseable

A worker for code generation and manipulation tasks. CodeWorker combines a workspace environment with an LLM agent to handle tasks involving code base understanding, modification, and generation.

The agent's commands run in the container without a shell, and only programs on the runner's allowlist run (#1756); a build tool the task needs, such as sbt, goes in extraAllowedCommands.

Value parameters

client

The LLM that drives the agent

containerOptions

How the container is started: its startup wait, resource limits and user (#3063, #3064)

extraAllowedCommands

Programs the runner may run besides its default allowlist, for example Set("sbt")

hostPort

The host port for the container

imageName

The workspace-runner image

sandboxConfig

The runner's whole sandbox config, or None for its profile

sourceDirectory

The directory containing the codebase to work with

Attributes

Companion
object
Source
CodeWorker.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

override def close(): Unit

Attributes

Definition Classes
Source
CodeWorker.scala
def executeTask(task: String, maxSteps: Option[Int]): Result[AgentResult]

Execute a code task and return the result

Execute a code task and return the result

Value parameters

maxSteps

Maximum number of model calls to run (None for the agent's default)

task

The description of the code task to perform

Attributes

Returns

Either an error or the agent's result

Source
CodeWorker.scala

Initialize the workspace and prepare for code tasks

Initialize the workspace and prepare for code tasks

Attributes

Returns

true if the workspace was initialized successfully

Source
CodeWorker.scala
def shutdown(): Boolean

Clean up resources when done

Clean up resources when done

Attributes

Source
CodeWorker.scala
def start(): Result[Unit]

Initializes the workspace as initialize does, or says why it could not start (#3063).

Initializes the workspace as initialize does, or says why it could not start (#3063).

Attributes

Source
CodeWorker.scala