Help us shape the future of Go! Take the 2026 Go Developer Survey

trajectory

package
v0.10.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package trajectory records an agent run as JSON.

Index

Constants

View Source
const (
	MaxPlanItems    = 50
	MaxPlanItemText = 500
	MaxPlanNote     = 2000
)

Plan limits enforced by update_plan and checkpoint validation.

View Source
const AnswerNotice = "The user answered your question. The workspace may have changed while the run was waiting; " +
	"revalidate earlier observations before relying on them. Live processes and shell state are not restored. The answer is below."

AnswerNotice is part of the versioned checkpoint contract. It starts the tool result that answers a NeedsInput run's pending ask_user call; the user's answer follows it.

View Source
const ContinuationNotice = "The previous invocation stopped before this task finished. " +
	"The conversation above is saved history up to the last checkpoint. " +
	"The workspace may have changed since that save, and commands may have produced " +
	"side effects that are not reflected in the transcript. Inspect and revalidate " +
	"the current workspace before continuing. Live processes and shell state are not " +
	"restored; historical process IDs cannot be used to reattach to old processes."

ContinuationNotice is part of the versioned checkpoint contract. It is a user message at each recorded resume boundary, never a new system prompt.

View Source
const FollowUpNotice = "The previous invocation finished. The conversation above is its saved history. " +
	"The workspace may have changed since it finished. Inspect and revalidate the current " +
	"workspace before relying on earlier observations. Live processes and shell state are not " +
	"restored. The user's follow-up task is below."

FollowUpNotice is part of the versioned checkpoint contract. It starts the user message at each follow-up boundary, where a finished run is continued with a new instruction; the instruction follows it.

View Source
const SchemaVersion = 2

SchemaVersion is the resume-metadata version written by this build. Version 1 checkpoints (no pending calls, processes, or plan) still load.

View Source
const StatusNeedsInput = "NeedsInput"

StatusNeedsInput is the exit status of a run that ended with an ask_user question. It is neither finished nor unfinished: only an answer continues it.

Variables

This section is empty.

Functions

func Finished added in v0.5.0

func Finished(status string) bool

Finished reports whether status is a successful termination that can only be continued with a follow-up task.

func ValidatePlanItems added in v0.5.0

func ValidatePlanItems(items []PlanItem, note string) error

ValidatePlanItems checks one complete plan.

Types

type AdditionalDir added in v0.5.0

type AdditionalDir struct {
	Path string `json:"path"`
	Mode string `json:"mode"`
}

AdditionalDir is one additional directory: an absolute path and its effective mode, "read" or "write".

type CommandEnvInfo added in v0.5.0

type CommandEnvInfo struct {
	Inherit        string   `json:"inherit"`
	ExcludeSecrets bool     `json:"exclude_secrets"`
	Passed         []string `json:"passed"`
}

CommandEnvInfo records the command_env policy bash and start_process commands ran with: names only, never values.

type CommandToolInfo added in v0.5.0

type CommandToolInfo struct {
	Name         string   `json:"name"`
	Argv         []string `json:"argv"`
	SchemaDigest string   `json:"schema_digest"`
}

CommandToolInfo records one command_tools definition: what its name ran.

type Compaction added in v0.4.0

type Compaction struct {
	Step         int    `json:"step"`   // steps completed when it ran
	Reason       string `json:"reason"` // "proactive" or "overflow"
	Stage        string `json:"stage"`  // "elide" or "summarize"
	TokensBefore int    `json:"tokens_before"`
	TokensAfter  int    `json:"tokens_after"`
	// Elided lists messages whose tool output was replaced by a placeholder.
	Elided []int `json:"elided,omitempty"`
	// Summarized lists messages replaced by Summary.
	Summarized []int   `json:"summarized,omitempty"`
	Summary    string  `json:"summary,omitempty"`
	USD        float64 `json:"usd,omitempty"` // cost of the summarization call
	// View is what the model is sent next: indexes into Messages, with -1
	// for the summary message.
	View []int `json:"view"`
	// PlanVersion is the plan version pinned in the view, when enabled.
	PlanVersion int `json:"plan_version,omitempty"`
}

Compaction describes one compaction of the model's view of the history. Indexes refer to Trajectory.Messages.

type EnvironmentInfo added in v0.5.0

type EnvironmentInfo struct {
	Name    string `json:"name"`
	Runtime string `json:"runtime,omitempty"`
	Image   string `json:"image,omitempty"`
}

EnvironmentInfo records the non-local environment bash commands ran in.

type FileAccessInfo added in v0.5.0

type FileAccessInfo struct {
	DenyRead  []string `json:"deny_read"`
	DenyWrite []string `json:"deny_write"`
}

FileAccessInfo records the file_access rules the built-in file tools enforced.

type LockdownDenial added in v0.9.0

type LockdownDenial struct {
	Channel    string `json:"channel"`
	Tool       string `json:"tool"`
	ToolCallID string `json:"tool_call_id"`
	Step       int    `json:"step"`
	Host       string `json:"host,omitempty"`
}

LockdownDenial is one tool call the lockdown refused after taint.

type MemoryLine added in v0.9.0

type MemoryLine struct {
	ID   string `json:"id"`
	Date string `json:"date"`
	Text string `json:"text"`
}

MemoryLine is one project memory entry loaded into the system prompt.

type ModelSwitch added in v0.5.0

type ModelSwitch struct {
	Step   int    `json:"step"`
	From   string `json:"from"`
	To     string `json:"to"`
	Reason string `json:"reason"`
}

ModelSwitch is one fallback switch: at step Step (the step being requested), the request failed on From with Reason after every retry and was re-sent to To.

type NetworkDenial added in v0.5.0

type NetworkDenial struct {
	Host   string `json:"host"`
	Port   int    `json:"port"`
	Reason string `json:"reason"`
}

NetworkDenial is one request the sandbox allowlist proxy refused.

type PendingCall added in v0.5.0

type PendingCall struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

PendingCall identifies a tool call without a recorded result.

type PermissionsInfo added in v0.8.0

type PermissionsInfo struct {
	Default        string                `json:"default"`
	NonInteractive string                `json:"non_interactive"`
	RuleCount      int                   `json:"rule_count"`
	Rules          []PermissionsRuleInfo `json:"rules,omitempty"`
}

PermissionsInfo records the tool permission policy a run enforced. Rules are config data, never secrets.

type PermissionsRuleInfo added in v0.8.0

type PermissionsRuleInfo struct {
	Tool     string `json:"tool"`
	Command  string `json:"command,omitempty"`
	Path     string `json:"path,omitempty"`
	Host     string `json:"host,omitempty"`
	Decision string `json:"decision"`
	Message  string `json:"message,omitempty"`
}

PermissionsRuleInfo is one permissions rule in a trajectory's summary.

type Plan added in v0.5.0

type Plan struct {
	Version     int        `json:"version"`
	Items       []PlanItem `json:"items"`
	Note        string     `json:"note,omitempty"`
	UpdatedStep int        `json:"updated_step"`
}

Plan is the model's persistent task plan, kept outside Messages so compaction never removes it.

type PlanChange added in v0.5.0

type PlanChange struct {
	Step    int    `json:"step"`
	Version int    `json:"version"`
	Diff    string `json:"diff"`
}

PlanChange audits one update_plan call.

type PlanItem added in v0.5.0

type PlanItem struct {
	ID     string `json:"id"`
	Text   string `json:"text"`
	Status string `json:"status"` // pending, in_progress, done, or blocked
}

PlanItem is one plan entry.

type PluginInfo added in v0.9.0

type PluginInfo struct {
	Name           string             `json:"name"`
	Version        string             `json:"version,omitempty"`
	Path           string             `json:"path"`
	ManifestSHA256 string             `json:"plugin_json_sha256"`
	MCPSHA256      string             `json:"mcp_json_sha256,omitempty"`
	Skills         []string           `json:"skills,omitempty"`
	MCPServers     []PluginServerInfo `json:"mcp_servers,omitempty"`
}

PluginInfo records one configured plugin that loaded, for trajectories and run.started. Digests are hex SHA-256 of the files as read; mcp.json env values are never recorded.

type PluginServerInfo added in v0.9.0

type PluginServerInfo struct {
	Server string `json:"server"`
	Alias  string `json:"alias"`
}

PluginServerInfo is one authorized plugin MCP server.

type ProcessInfo added in v0.5.0

type ProcessInfo struct {
	ID      string `json:"id"`
	PID     int    `json:"pid,omitempty"`
	Command string `json:"command"`
}

ProcessInfo describes a background process registered by start_process.

type Question added in v0.5.0

type Question struct {
	ToolCallID string   `json:"tool_call_id"`
	Question   string   `json:"question"`
	Options    []string `json:"options,omitempty"`
}

Question is one ask_user question waiting for an answer.

type RedactSecretsInfo added in v0.5.0

type RedactSecretsInfo struct {
	Enabled  bool     `json:"enabled"`
	Patterns bool     `json:"patterns"`
	Names    []string `json:"names"`
}

RedactSecretsInfo records the redact_secrets setting a run's tool output was masked with: variable names only, never values.

type ResumeInfo added in v0.4.0

type ResumeInfo struct {
	Source     string `json:"source"`      // path of the input checkpoint
	ExitStatus string `json:"exit_status"` // previous termination status
	Steps      int    `json:"steps"`       // steps at the previous termination
	Submission string `json:"submission,omitempty"`
	Message    int    `json:"message"` // continuation notice index in Messages
	// FollowUp marks a boundary where a finished (Submitted or Completed)
	// run was continued with a new user instruction. Its message starts with
	// FollowUpNotice instead of ContinuationNotice.
	FollowUp bool `json:"follow_up,omitempty"`
	// Answer marks a boundary where a NeedsInput run was continued with the
	// user's answer. Its message is the pending ask_user call's tool result,
	// starting with AnswerNotice.
	Answer   bool        `json:"answer,omitempty"`
	Previous *ResumeInfo `json:"previous,omitempty"`
}

ResumeInfo records the checkpoint a run continued, so the previous termination stays distinguishable from the active result.

type ReviewInfo added in v0.5.0

type ReviewInfo struct {
	Target        string `json:"target"` // uncommitted, base or commit
	Ref           string `json:"ref,omitempty"`
	BaseCommit    string `json:"base_commit,omitempty"`
	HeadCommit    string `json:"head_commit,omitempty"`
	Commit        string `json:"commit,omitempty"`
	FilesChanged  int    `json:"files_changed"`
	DiffBytes     int    `json:"diff_bytes"`
	DiffBytesSent int    `json:"diff_bytes_sent"`
	Truncated     bool   `json:"truncated"`
	HiddenPaths   int    `json:"hidden_paths"`
}

ReviewInfo records the Git change set a review run (--review, --review-base, --review-commit) gave the model: the target, the ref as typed, the resolved commits, and how much of the diff was sent.

type SandboxInfo added in v0.5.0

type SandboxInfo struct {
	Backend  string   `json:"backend"`
	Writable []string `json:"writable"`
	Network  bool     `json:"network"`
	// AllowedDomains is set in allowlist mode: commands could reach only
	// these hosts, through tinyagent's proxy.
	AllowedDomains []string `json:"allowed_domains,omitempty"`
}

SandboxInfo records the OS sandbox that confined bash commands.

type ScopedAgentsMDLoad added in v0.5.0

type ScopedAgentsMDLoad struct {
	// Path is the file, relative to Root and slash separated.
	Path string `json:"path"`
	// ScopeDir is its directory with a trailing slash, e.g. "pkg/a/".
	ScopeDir string `json:"scope_dir"`
	// Bytes is the file's size on disk.
	Bytes     int  `json:"bytes"`
	Truncated bool `json:"truncated,omitempty"`
	// Delivered is the number of content bytes appended (after the cap).
	Delivered  int    `json:"delivered_bytes"`
	Tool       string `json:"tool"`
	ToolCallID string `json:"tool_call_id"`
	Step       int    `json:"step"`
	// Message is the index in Messages of the tool result carrying it.
	Message int `json:"message"`
}

ScopedAgentsMDLoad is one scoped AGENTS.md delivered with a tool result.

type SkillInfo added in v0.5.0

type SkillInfo struct {
	Name  string `json:"name"`
	Scope string `json:"scope"`
	Path  string `json:"path"`
	// Plugin names the plugin a plugin-scope skill came from.
	Plugin string `json:"plugin,omitempty"`
}

SkillInfo identifies one discovered skill.

type Snapshot added in v0.5.0

type Snapshot struct {
	ID string `json:"id"`
	// Step is the step count when it was taken: 0 for the first baseline,
	// N for the snapshot taken before step N's tool batch ran.
	Step int `json:"step"`
	// Kind is "baseline", "step", "final" or "pre-rewind".
	Kind string `json:"kind"`
	Time string `json:"time"` // RFC 3339
	// Files is how many files and symlinks were captured, Bytes their total
	// size.
	Files int   `json:"files"`
	Bytes int64 `json:"bytes"`
	// SkippedIgnored counts gitignored paths left out (an ignored directory
	// counts once); SkippedLarge counts files over max_file_bytes, and
	// LargePaths lists the first few of them.
	SkippedIgnored int      `json:"skipped_ignored,omitempty"`
	SkippedLarge   int      `json:"skipped_large,omitempty"`
	LargePaths     []string `json:"large_paths,omitempty"`
	// Store is the snapshot store directory.
	Store string `json:"store"`
}

Snapshot is the trajectory's record of one workspace snapshot.

type Subagent added in v0.5.0

type Subagent struct {
	ID         string `json:"id"`
	ToolCallID string `json:"tool_call_id"`
	Task       string `json:"task"`
	Label      string `json:"label,omitempty"`
	Model      string `json:"model"`
	// ParentStep is the parent's step count when the call ran.
	ParentStep       int             `json:"parent_step"`
	Status           string          `json:"status"`
	Steps            int             `json:"steps"`
	InputTokens      int             `json:"input_tokens"`
	OutputTokens     int             `json:"output_tokens"`
	CacheReadTokens  int             `json:"cache_read_tokens,omitempty"`
	CacheWriteTokens int             `json:"cache_write_tokens,omitempty"`
	Cost             float64         `json:"cost"`
	Report           string          `json:"report,omitempty"`
	Messages         []model.Message `json:"messages"`
	// Kind is "worker" for a worker run; empty for a delegate child.
	Kind string `json:"kind,omitempty"`
	// Worker runs only: the worktree, its branch, the snapshot commit it
	// started from, the commit holding its changes ("" when it changed
	// nothing), and whether apply_worker applied it.
	Worktree   string `json:"worktree,omitempty"`
	Branch     string `json:"branch,omitempty"`
	BaseCommit string `json:"base_commit,omitempty"`
	Commit     string `json:"commit,omitempty"`
	Applied    bool   `json:"applied,omitempty"`
}

Subagent is one delegate child run.

type TaintSource added in v0.9.0

type TaintSource struct {
	Source     string `json:"source"`
	Step       int    `json:"step"`
	ToolCallID string `json:"tool_call_id,omitempty"`
	Tool       string `json:"tool,omitempty"`
	Host       string `json:"host,omitempty"`
	// Resumed marks a source carried over from an earlier invocation.
	Resumed bool `json:"resumed,omitempty"`
}

TaintSource is one recorded taint of the untrusted-content lockdown (#171): what brought untrusted content into context and where. It holds source and tool names, ids, steps and hosts, never content.

type ToolCallRef added in v0.5.0

type ToolCallRef = model.ToolCall

ToolCallRef is a recorded tool call.

type ToolOutputFile added in v0.5.0

type ToolOutputFile struct {
	ToolCallID  string `json:"tool_call_id"`
	OutputFile  string `json:"output_file"` // relative to the run's root, slash separated
	OutputBytes int    `json:"output_bytes"`
}

ToolOutputFile records where one tool result's full text was saved.

type Trajectory

type Trajectory struct {
	// Environment is set when bash and start_process ran outside the host,
	// e.g. in a container.
	Environment *EnvironmentInfo `json:"environment,omitempty"`
	// Sandbox is set when bash and start_process ran in an OS sandbox.
	Sandbox *SandboxInfo `json:"sandbox,omitempty"`
	// CommandEnv is set when a command_env policy filtered the environment
	// of bash and start_process; it records this invocation's policy.
	CommandEnv *CommandEnvInfo `json:"command_env,omitempty"`
	// RedactSecrets is set when redact_secrets masked known secret values
	// in tool output; it records this invocation's setting. Earlier
	// results in a resumed history are not rewritten.
	RedactSecrets *RedactSecretsInfo `json:"redact_secrets,omitempty"`
	// CommandTools lists this invocation's command_tools definitions.
	CommandTools []CommandToolInfo `json:"command_tools,omitempty"`
	// CommandToolNames lists every command tool name offered in any
	// invocation of the run, so earlier calls stay valid history on resume.
	CommandToolNames []string `json:"command_tool_names,omitempty"`
	// FileAccess is set when file_access rules restricted the file tools;
	// it records this invocation's rules.
	FileAccess *FileAccessInfo `json:"file_access,omitempty"`
	// Permissions is set when a permissions policy restricted tool calls;
	// it records this invocation's policy.
	Permissions *PermissionsInfo `json:"permissions,omitempty"`
	// Worktree is set when the run was started with --worktree: Root is
	// that worktree (or its subdirectory).
	Worktree *WorktreeInfo `json:"worktree,omitempty"`
	// Review is set when the run reviewed a Git change set collected by
	// tinyagent; the diff itself is in the first user message.
	Review *ReviewInfo `json:"review,omitempty"`
	// AdditionalDirs lists the directories outside Root the file tools could
	// reach in this invocation, with their effective mode.
	AdditionalDirs []AdditionalDir `json:"additional_dirs,omitempty"`

	// LockdownEnabled records whether this invocation ran with the
	// untrusted-content lockdown. Tainted is set once untrusted content
	// entered the run's context and stays set across resumes and
	// follow-ups; a tainted checkpoint can't be resumed without lockdown.
	// TaintSources and LockdownDenials accumulate over the resume chain.
	LockdownEnabled bool             `json:"lockdown_enabled,omitempty"`
	Tainted         bool             `json:"tainted,omitempty"`
	TaintSources    []TaintSource    `json:"taint_sources,omitempty"`
	LockdownDenials []LockdownDenial `json:"lockdown_denials,omitempty"`

	// SandboxNetworkDenials lists the requests the allowlist proxy refused.
	SandboxNetworkDenials []NetworkDenial `json:"sandbox_network_denials,omitempty"`
	ReadOnly              bool            `json:"read_only"`
	Task                  string          `json:"task"`
	Model                 string          `json:"model"`
	// ReasoningEffort is the reasoning_effort sent with every request, if any.
	ReasoningEffort string `json:"reasoning_effort,omitempty"`
	// OpenAIAPI is the openai provider's resolved transport, "responses" or
	// "chat"; empty for other providers and older trajectories.
	OpenAIAPI string `json:"openai_api,omitempty"`
	// Profile is the config profile selected with --profile; empty when
	// none. Only the name is recorded, never the profile's settings.
	Profile string `json:"profile,omitempty"`
	// ProviderAPI and ProviderBaseURL describe a config-defined provider
	// (its id is the model spec's prefix); empty for built-in providers.
	// Keys and header values are never recorded.
	ProviderAPI     string `json:"provider_api,omitempty"`
	ProviderBaseURL string `json:"provider_base_url,omitempty"`
	// FallbackModels is the fallback chain of the latest invocation
	// (fallback_models, --fallback-model); empty without one.
	FallbackModels []string `json:"fallback_models,omitempty"`
	// ModelSwitches records each move down the fallback chain, in order.
	ModelSwitches []ModelSwitch `json:"model_switches,omitempty"`
	// ActiveModel is the model that served the latest request when a
	// fallback chain is configured; Model stays the primary. Assistant
	// messages then carry the serving model in Extra["model"].
	ActiveModel  string          `json:"active_model,omitempty"`
	Messages     []model.Message `json:"messages"`
	Steps        int             `json:"steps"`
	Cost         float64         `json:"cost"`
	InputTokens  int             `json:"input_tokens"`
	OutputTokens int             `json:"output_tokens"`
	// Prompt-cache totals, included in InputTokens.
	CacheReadTokens  int    `json:"cache_read_tokens,omitempty"`
	CacheWriteTokens int    `json:"cache_write_tokens,omitempty"`
	ExitStatus       string `json:"exit_status"`
	Submission       string `json:"submission"`
	// StructuredOutput is the validated result of an --output-schema run
	// that ended Submitted; Submission holds the same JSON as a string.
	StructuredOutput json.RawMessage `json:"structured_output,omitempty"`
	// OutputSchema and OutputSchemaDigest record the --output-schema used.
	OutputSchema       map[string]any `json:"output_schema,omitempty"`
	OutputSchemaDigest string         `json:"output_schema_digest,omitempty"`
	// Compactions records each time the context sent to the model was
	// compacted. Messages always keeps the full, original history.
	Compactions []Compaction `json:"compactions,omitempty"`
	// BackgroundProcesses summarizes background processes still registered
	// when the run ended (all are killed): status and output tail of each.
	BackgroundProcesses string `json:"background_processes,omitempty"`

	// Resume metadata, present on trajectories written by this version. It
	// lets a later invocation validate and continue an unfinished run.
	SchemaVersion int    `json:"schema_version,omitempty"`
	Root          string `json:"root,omitempty"` // canonical working directory
	// SystemPrompt is the effective system prompt (with {{cwd}}/{{os}}
	// substituted and AGENTS.md appended) the run used.
	SystemPrompt string `json:"system_prompt,omitempty"`
	// SkipAgentsMD records whether AGENTS.md was excluded from the prompt.
	SkipAgentsMD          bool     `json:"skip_agents_md"`
	Tools                 []string `json:"tools,omitempty"`          // tool names, in spec order
	ToolSignature         string   `json:"tool_signature,omitempty"` // versioned spec/semantics fingerprint
	MCPEnabled            bool     `json:"mcp_enabled,omitempty"`
	ExternalTools         []string `json:"external_tools,omitempty"`
	ExternalToolSignature string   `json:"external_tool_signature,omitempty"`
	// FormatErrors counts malformed tool calls over the whole run, and
	// ConsecutiveFormatErrors the current run of steps whose calls were all
	// malformed; it is restored on resume. FormatErrorMessages lists the
	// indexes in Messages of tool results that were format-error corrections.
	FormatErrors            int    `json:"format_errors,omitempty"`
	ConsecutiveFormatErrors int    `json:"consecutive_format_errors,omitempty"`
	FormatErrorMessages     []int  `json:"format_error_messages,omitempty"`
	LastFormatError         string `json:"last_format_error,omitempty"`
	// Truncations counts responses cut off at the output-token limit over
	// the whole run, and ConsecutiveTruncations the current run of them; it
	// is restored on resume. MaxOutputTokens is the effective per-request
	// output budget (0 = provider default).
	Truncations            int `json:"truncations,omitempty"`
	ConsecutiveTruncations int `json:"consecutive_truncations,omitempty"`
	MaxOutputTokens        int `json:"max_output_tokens,omitempty"`
	// StopContinuations counts the times stop hooks sent the model back to
	// work; it is restored on resume. StopReason is the last stop-hook
	// feedback of a VerificationFailed run.
	StopContinuations int    `json:"stop_continuations,omitempty"`
	StopReason        string `json:"stop_reason,omitempty"`
	// Verify-on-stop guard state (verify_on_stop): VerifyPending means
	// files may have changed since the last successful verification,
	// VerifyBlocked that the last bash call was refused, VerifyReprompts
	// counts the times the model was sent back to verify, and Unverified
	// marks a run that finished with unverified changes.
	VerifyPending   bool `json:"verify_pending,omitempty"`
	VerifyBlocked   bool `json:"verify_blocked,omitempty"`
	VerifyReprompts int  `json:"verify_reprompts,omitempty"`
	Unverified      bool `json:"unverified,omitempty"`
	// Resume records the checkpoint this run continued, when it did.
	Resume *ResumeInfo `json:"resume,omitempty"`

	// PendingCalls (schema 2) is the write-ahead record of the last assistant
	// turn's tool calls that have started or are about to start but have no
	// result yet. It is empty at every completed step boundary.
	PendingCalls []PendingCall `json:"pending_calls,omitempty"`
	// Processes (schema 2) lists the background processes registered at the
	// last save. None survive the invocation that started them.
	Processes []ProcessInfo `json:"processes,omitempty"`
	// PlanEnabled (schema 2) records whether the opt-in update_plan tool was
	// offered. A resume must use the same setting.
	PlanEnabled bool         `json:"plan_enabled,omitempty"`
	Plan        *Plan        `json:"plan,omitempty"`
	PlanHistory []PlanChange `json:"plan_history,omitempty"`
	// ImagesEnabled (schema 2) records whether the opt-in --images setting
	// (view_image and MCP image pass-through) was on. A resume must use the
	// same setting. Image bytes are stored inline, base64, in Messages.
	ImagesEnabled bool `json:"images_enabled,omitempty"`
	// ApplyPatchEnabled (schema 2) records whether the opt-in apply_patch
	// tool was enabled. A resume must use the same setting.
	ApplyPatchEnabled bool `json:"apply_patch_enabled,omitempty"`
	// SubagentsEnabled (schema 2) records whether the opt-in delegate tool
	// was offered. A resume must use the same setting.
	SubagentsEnabled bool `json:"subagents_enabled,omitempty"`
	// WorkersEnabled records whether the opt-in worker and apply_worker
	// tools were offered. A resume must use the same setting.
	WorkersEnabled bool `json:"workers_enabled,omitempty"`
	// WebFetchEnabled (schema 2) records whether the opt-in web_fetch tool
	// was offered. A resume must use the same setting.
	WebFetchEnabled bool `json:"web_fetch_enabled,omitempty"`
	// WebFetch is set when web_fetch was offered; it records this
	// invocation's allowlist.
	WebFetch *WebFetchInfo `json:"web_fetch,omitempty"`
	// LSPEnabled (schema 2) records whether language servers (the lsp
	// tool and post-edit diagnostics) were on. A resume must use the same
	// setting.
	LSPEnabled bool `json:"lsp_enabled,omitempty"`
	// LSPServers names this invocation's configured language servers.
	LSPServers []string `json:"lsp_servers,omitempty"`
	// AskUserEnabled (schema 2) records whether the opt-in ask_user tool
	// was offered. A resume must use the same setting.
	AskUserEnabled bool `json:"ask_user_enabled,omitempty"`
	// QuestionsAsked counts the ask_user questions that ended a run, over
	// the whole resume chain.
	QuestionsAsked int `json:"questions_asked,omitempty"`
	// PendingQuestion is the unanswered question of a NeedsInput run; its
	// call is the only pending call. A resume delivers the answer as that
	// call's result.
	PendingQuestion *Question `json:"pending_question,omitempty"`
	// ScopedAgentsMDEnabled (schema 2) records whether AGENTS.md files
	// below Root were delivered with file tool results (--scoped-agents-md).
	ScopedAgentsMDEnabled bool `json:"scoped_agents_md_enabled,omitempty"`
	// ScopedAgentsMD lists the scoped AGENTS.md paths (relative to Root,
	// slash separated) whose delivering tool result is still in context.
	ScopedAgentsMD []string `json:"scoped_agents_md,omitempty"`
	// ScopedAgentsMDLoads records every scoped AGENTS.md delivery, in order.
	ScopedAgentsMDLoads []ScopedAgentsMDLoad `json:"scoped_agents_md_loads,omitempty"`
	// ScopedAgentsMDSince is when the run first started with scoped
	// AGENTS.md on (RFC 3339): files modified after it are not delivered.
	ScopedAgentsMDSince string `json:"scoped_agents_md_since,omitempty"`
	// Subagents records each delegate call's child run, in call order,
	// with its full history. Their tokens and cost are included in the
	// run totals; their model calls are counted in SubagentSteps, not
	// Steps.
	Subagents     []Subagent `json:"subagents,omitempty"`
	SubagentSteps int        `json:"subagent_steps,omitempty"`
	// ToolOutputFiles (schema 2) lists the over-limit tool results whose
	// full text was saved with tool_output_files on.
	ToolOutputFiles []ToolOutputFile `json:"tool_output_files,omitempty"`
	// SkillsEnabled records whether Agent Skills discovery was on. A resume
	// rediscovers skills and must rebuild the same catalog. Older
	// checkpoints, without the field, resume with skills off.
	SkillsEnabled bool `json:"skills_enabled,omitempty"`
	// Skills is the discovered catalog (not the skill bodies).
	Skills []SkillInfo `json:"skills,omitempty"`
	// Plugins records the configured plugins that loaded (issue #173).
	Plugins []PluginInfo `json:"plugins,omitempty"`
	// SnapshotsEnabled records whether the last invocation took opt-in
	// workspace snapshots (--snapshots). It is per invocation: a resume may
	// turn snapshots on or off.
	SnapshotsEnabled bool `json:"snapshots_enabled,omitempty"`
	// Snapshots indexes the workspace snapshots taken for this run, oldest
	// first, across resumes and rewinds. The file contents live in the
	// snapshot store named by each entry, never in the trajectory.
	Snapshots []Snapshot `json:"snapshots,omitempty"`
	// MemoryEnabled records whether project memory was on (issue #170).
	// A resume or follow-up rebuilds the Project memory section from
	// Memory and never re-reads the store. Older checkpoints, without the
	// field, resume with memory off.
	MemoryEnabled bool `json:"memory_enabled,omitempty"`
	// Memory is the snapshot of entries loaded into the system prompt at
	// run start, newest first.
	Memory []MemoryLine `json:"memory,omitempty"`
	// MemoryOmitted counts active entries left out of the section to stay
	// within memory.max_bytes.
	MemoryOmitted int `json:"memory_omitted,omitempty"`
}

func Load added in v0.4.0

func Load(path string) (*Trajectory, error)

Load reads a trusted local checkpoint without modifying it. Parse diagnostics intentionally omit decoder errors, which can contain transcript values.

func Read added in v0.5.0

func Read(path string) (*Trajectory, error)

Read reads any trajectory file this or an older version of tinyagent wrote, finished or not, for display. Unlike Load it applies no resume validation and ignores fields it doesn't know; it shares Load's file checks and, like Load, never puts decoder text in its errors.

func (*Trajectory) Save

func (t *Trajectory) Save(path string) error

Save replaces path with a complete private file using a same-directory temporary file and rename. The file and its directory are fsynced so a completed save survives power loss on filesystems that honor fsync.

func (*Trajectory) SaveNew added in v0.4.0

func (t *Trajectory) SaveNew(path string) error

SaveNew publishes the starting checkpoint without replacing any existing destination, including symlinks. Linking the completed temporary file makes publication atomic and exclusive on filesystems supporting hard links.

func (*Trajectory) Validate added in v0.4.0

func (t *Trajectory) Validate() error

Validate checks a complete model-query boundary, matching IDs within each assistant turn. It never repairs or dispatches historical calls.

type WebFetchInfo added in v0.5.0

type WebFetchInfo struct {
	AllowedDomains []string `json:"allowed_domains"`
}

WebFetchInfo records the web_fetch allowlist of one invocation.

type WorktreeInfo added in v0.5.0

type WorktreeInfo struct {
	Path       string `json:"path"`
	Branch     string `json:"branch"`
	BaseCommit string `json:"base_commit"`
	RepoRoot   string `json:"repo_root"`
}

WorktreeInfo records the Git worktree a --worktree run worked in: its path, branch, the commit it was branched from and the main repository.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL