Documentation
¶
Overview ¶
Package taskrun provides task-run execution.
RunTask executes a single run in-process: materialize workspace, optionally restore session from the previous run, run the agent runtime, persist outputs, and update run state via TaskRunUpdater.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildRunAgentsMdContent ¶
BuildRunAgentsMdContent builds the full AGENTS.md content for a run: the run directory structure section first, then optional workspace AGENTS.md from runHome (if present). runHome is the materialized workspace home dir (run's home/).
func RunTask ¶
func RunTask(ctx context.Context, input RunTaskInput) error
RunTask runs a single task run: materialize workspace, optionally restore session from previous run, execute agent in-process, upload run state to blob, update run and task via updater. If input.StreamSender is non-nil, stdout is streamed to the server as deltas; full output is still accumulated for persist and PATCH.
func WriteRunAgentsMd ¶
WriteRunAgentsMd writes AGENTS.md into runDir with content from BuildRunAgentsMdContent(runHome). Call after materializing runHome and before running the agent so it picks up run context from cwd.
Types ¶
type RunResult ¶
type RunResult struct {
EndTime int64
OutputStr string
RunArtifactsDir string
Output []byte
PromptTokens *int
CompletionTokens *int
// TracePath locates this run's durable trace inside run-global storage,
// e.g. "traces/<session>/rt_….jsonl". Empty when no trace was written.
// Recorded because the trace's file name is the agent run id, which is
// generated inside the run and is not otherwise persisted — without this
// the uploaded trace could not be found again.
TracePath string
}
RunResult holds the outcome of a successful run (output and paths) for reportRunSuccess.
type RunTaskInput ¶
type RunTaskInput struct {
Task *model.Task
Run *model.TaskRun
SessionID string
Paths RuntimePaths
Persist blob.PersistStorage
ArtifactStorage blob.ArtifactStorage
Updater TaskRunUpdater
StreamSender workerclient.StreamSender
Model config.ModelEntry
}
RunTaskInput holds all inputs for RunTask. Callers build this struct and pass it to RunTask.
type RuntimePaths ¶
type RuntimePaths interface {
PersistentUserDir(userID string) string
RuntimeTaskRunDir(userID, conversationID, taskID, taskRunID string) string
RuntimeTaskRunHomeDir(userID, conversationID, taskID, taskRunID string) string
RuntimeTaskRunArtifactsDir(userID, conversationID, taskID, taskRunID string) string
RuntimeTaskRunGlobalDir(userID, conversationID, taskID, taskRunID string) string
RunOutputDir(userID, conversationID, taskID, taskRunID string) string
}
RuntimePaths provides filesystem layout for user files, tasks, runs, and artifacts. It is injected for testability and to avoid hard dependency on internal/config.
func NewRuntimePathsFromRoot ¶
func NewRuntimePathsFromRoot(root string) RuntimePaths
NewRuntimePathsFromRoot returns a RuntimePaths that uses root as the parent of all user dirs.
type TaskRunUpdater ¶
type TaskRunUpdater interface {
UpdateRunStatus(ctx context.Context, taskRunID string, req *workerclient.PatchTaskRunRequest) error
}
TaskRunUpdater is used by the worker to update run status and register artifacts via HTTP. When status is SUCCEEDED with artifact, server creates artifact and syncs task denormalized fields. When status is FAILED, server syncs task denormalized from run.