Documentation
¶
Overview ¶
Package llmlifecycle owns durable structured LLM task execution.
Index ¶
- Constants
- func Fingerprint(adapter, taskID, phase, model, effort, prompt string, deps []string) string
- func ResetIfInputFingerprintChanged(paths Paths, taskID, fingerprint string) error
- func ResumeSessionID(meta Metadata) string
- func SanitizeError(err error) string
- func TaskErrorText(meta Metadata) string
- func ValidateMetadata(meta Metadata, req Request, adapter string) error
- func ValidatePayloadPath(paths Paths, taskID, field, recordedPath string) (string, error)
- func WriteFailure(paths Paths, meta *Metadata, attempts []llm.StructuredValidationAttempt) error
- func WriteMetadata(paths Paths, meta Metadata) error
- func WriteSuccess(paths Paths, meta *Metadata, output []byte) error
- type AttemptMetadata
- type Metadata
- type Paths
- type Progress
- type ProgressEvent
- type ProgressResult
- type ProgressSpan
- type Request
- type Result
- type SessionDraft
- type Status
- type Store
- type TaskError
Constants ¶
const SchemaVersion = 1
SchemaVersion identifies the on-disk LLM task artifact schema.
Variables ¶
This section is empty.
Functions ¶
func Fingerprint ¶
Fingerprint returns the stable reuse fingerprint for task inputs.
func ResetIfInputFingerprintChanged ¶ added in v0.10.228
ResetIfInputFingerprintChanged removes stale task artifacts when inputs change.
func ResumeSessionID ¶
ResumeSessionID returns the best provider session ID for retrying a task.
func SanitizeError ¶
SanitizeError prepares provider errors for durable metadata and markdown.
func TaskErrorText ¶
TaskErrorText returns the persisted error text for a failed task.
func ValidateMetadata ¶
ValidateMetadata checks whether task metadata is reusable for the request.
func ValidatePayloadPath ¶
ValidatePayloadPath ensures a recorded payload path stays inside the task directory.
func WriteFailure ¶
func WriteFailure(paths Paths, meta *Metadata, attempts []llm.StructuredValidationAttempt) error
WriteFailure writes invalid attempts and metadata for a failed task.
func WriteMetadata ¶
WriteMetadata writes task metadata atomically.
Types ¶
type AttemptMetadata ¶
type AttemptMetadata struct {
Attempt string `json:"attempt"`
ProviderSessionID string `json:"provider_session_id,omitempty"`
RawOutputPath string `json:"raw_output_path,omitempty"`
DecodeError string `json:"decode_error,omitempty"`
}
AttemptMetadata records one invalid structured-output attempt.
type Metadata ¶
type Metadata struct {
SchemaVersion int `json:"schema_version"`
TaskID string `json:"task_id"`
Phase string `json:"phase"`
DependencyTaskIDs []string `json:"dependency_task_ids,omitempty"`
InputFingerprint string `json:"input_fingerprint"`
AgentID string `json:"agent_id,omitempty"`
Status Status `json:"status"`
SessionRowID string `json:"session_row_id,omitempty"`
ProviderSessionID string `json:"provider_session_id,omitempty"`
Adapter string `json:"adapter"`
Model string `json:"model"`
Effort string `json:"effort,omitempty"`
LogPath string `json:"log_path,omitempty"`
ValidatedOutputPath string `json:"validated_output_path,omitempty"`
Error string `json:"error,omitempty"`
TokensIn *int `json:"tokens_in,omitempty"`
TokensOut *int `json:"tokens_out,omitempty"`
CacheRead *int `json:"cache_read,omitempty"`
CacheCreate *int `json:"cache_create,omitempty"`
CostUSD *float64 `json:"cost_usd,omitempty"`
Speed string `json:"speed,omitempty"`
Attempts []AttemptMetadata `json:"attempts,omitempty"`
}
Metadata is the durable descriptor for one structured LLM task.
func BaseMetadata ¶
func BaseMetadata(req Request, draft SessionDraft) Metadata
BaseMetadata builds metadata shared by success and failure paths.
type Paths ¶
type Paths struct {
LLMTasksDir string
}
Paths identifies the artifact root for durable LLM tasks.
func (Paths) RawAttempt ¶
RawAttempt returns the raw structured-output attempt payload path.
type Progress ¶
type Progress interface {
StartLLMTask(ProgressEvent) ProgressSpan
LoadLLMTask(ProgressEvent, ProgressResult)
}
Progress observes LLM task execution and cache-load events.
type ProgressEvent ¶
type ProgressEvent struct {
TaskID string
Phase string
AgentID string
Model string
Effort string
LogPath string
ResumeSessionID string
Source string
}
ProgressEvent describes the task being executed or loaded.
func NewProgressEvent ¶
func NewProgressEvent(req Request, resumeSessionID string) ProgressEvent
NewProgressEvent builds a progress event from a task request.
type ProgressResult ¶
type ProgressResult struct {
ProviderSessionID string
Status string
ValidationAttempts int
Cached bool
Usage llm.Usage
}
ProgressResult records the observable result for a task progress event.
type ProgressSpan ¶
type ProgressSpan interface {
End(error, ProgressResult)
}
ProgressSpan is an in-flight LLM task progress event.
type Request ¶
type Request struct {
Store Store
Adapter llm.Adapter
RunID string
TaskID string
Phase string
DependencyTaskIDs []string
AllowNoRunCache bool
InputFingerprint string
Paths Paths
Role ledger.SessionRole
AgentID *string
Model string
Effort string
LogPath string
Prompt string
BaseRequest llm.Request
ResumeSessionID string
FailureStatus Status
Progress Progress
Now func() time.Time
NewSessionRowID func() string
}
Request contains all dependencies and inputs for one structured LLM task.
type Result ¶
type Result[T any] struct { Value T Draft SessionDraft Session ledger.Session Cached bool }
Result contains either a decoded task value or durable failure/session state.
type SessionDraft ¶
type SessionDraft struct {
RowID string
ProviderReportedSessionID string
ProviderSessionID string
Role ledger.SessionRole
AgentID *string
Adapter string
Model string
Effort string
StartedAt time.Time
CompletedAt time.Time
Response llm.Response
}
SessionDraft captures provider telemetry before it is persisted to the ledger.
func SessionDraftFromLedger ¶
func SessionDraftFromLedger(session ledger.Session) SessionDraft
SessionDraftFromLedger rebuilds a lifecycle draft from a ledger session.
func SessionDraftFromMetadata ¶
func SessionDraftFromMetadata(meta Metadata) SessionDraft
SessionDraftFromMetadata rebuilds a lifecycle draft from task metadata.
type Status ¶
type Status string
Status is the durable outcome recorded for one structured LLM task.
const ( // StatusSucceeded marks a task with validated reusable output. StatusSucceeded Status = "succeeded" // StatusFailedIsolated marks a recoverable task-local failure. StatusFailedIsolated Status = "failed_isolated" // StatusFailedBlocking marks a failure that must be retried before progress. StatusFailedBlocking Status = "failed_blocking" )
type Store ¶
type Store interface {
InsertSession(context.Context, ledger.Session) error
GetSession(context.Context, string) (ledger.Session, error)
}
Store is the durable session store required by run-owned LLM tasks.
type TaskError ¶
type TaskError struct {
// contains filtered or unexported fields
}
TaskError wraps an LLM task error with its durable status.