Documentation
¶
Overview ¶
Package openhands reads the conversation directories of the OpenHands software agent SDK (OpenHands/software-agent-sdk, 1.0.0 to 1.55), the format the OpenHands CLI, the agent server and Agent Canvas write: one directory per conversation holding base_state.json, the conversation's state, and events/event-<index>-<event id>.json, one event per file. Sub-agents' conversations nest under subagents/<id>/ in the same layout; the agent server adds meta.json. It imports the standard library alone. The OpenHands app's V0 sessions and the 1.x app's v1_conversations mirror are other formats and are not read here.
Events are read as OpenHands reads them: in index order from 0 to the first missing index, a file of the events directory that is not in that sequence recorded with why. An event's envelope is decoded leniently, and its kind's members on demand (Event.Message, Event.Action and the like), so an event of a kind this package does not know, or one whose members do not fit, is still read. Every object keeps the members it does not declare and writes them back, so an event decoded and encoded again is the same JSON value.
ReadConversation reads a conversation directory, Parse its files' contents; FindSessions lists the conversation directories under a directory. No file records a format version; shapes are told apart by the converter. The reader does not interpret: rebuilding what the model saw, and converting to the Agent Session Format, are the convert subpackage's; docs/formats/openhands.md is the mapping.
Index ¶
- Constants
- Variables
- func ConversationDir(path string) (string, error)
- func Count(raw json.RawMessage) int
- func EventIDs(dir string) (map[string]bool, error)
- func FindSessions(root string) ([]string, error)
- func Float(raw json.RawMessage) (float64, bool)
- func HexID(id string) string
- func InContext(kind string) bool
- func Int(raw json.RawMessage) (n int64, exact, ok bool)
- func IsArtifact(kind string) bool
- func IsConversationDir(dir string) bool
- func IsConversationFile(path string) bool
- func IsKnownKind(kind string) bool
- func IsNull(raw json.RawMessage) bool
- func IsObservationLike(kind string) bool
- func ParseTime(s string, loc *time.Location) (t time.Time, naive, ok bool)
- func StateID(dir string) string
- func SubagentParent(dir string) (string, bool)
- func SummaryID(condensationID string) string
- type Action
- type ActionEvent
- type AgentErrorEvent
- type AgentInfo
- type Condensation
- type Content
- type Contents
- type Conversation
- type Cost
- type Event
- func (e *Event) Action() (*ActionEvent, error)
- func (e *Event) AgentError() (*AgentErrorEvent, error)
- func (e *Event) Condensation() (*Condensation, error)
- func (e *Event) Message() (*MessageEvent, error)
- func (e *Event) Observation() (*ObservationEvent, error)
- func (e *Event) SystemPrompt() (*SystemPromptEvent, error)
- func (e *Event) UserReject() (*UserRejectObservation, error)
- type File
- type FileStatus
- type Latency
- type Members
- type Message
- type MessageEvent
- type Meta
- type Metrics
- type MetricsMap
- type Observation
- type ObservationEvent
- type ReasoningItem
- type State
- type Stats
- type SystemPromptEvent
- type TerminalMetadata
- type ThinkingBlock
- type TokenUsage
- type ToolCall
- type UserRejectObservation
Constants ¶
const ( FileBaseState = "base_state.json" FileMeta = "meta.json" DirEvents = "events" DirSubagents = "subagents" DirObservations = "observations" )
Names in a conversation directory.
const ( KindSystemPrompt = "SystemPromptEvent" KindMessage = "MessageEvent" KindAction = "ActionEvent" KindObservation = "ObservationEvent" KindUserReject = "UserRejectObservation" KindAgentError = "AgentErrorEvent" KindCondensation = "Condensation" KindCondensationRequest = "CondensationRequest" KindCondensationSummary = "CondensationSummaryEvent" KindPause = "PauseEvent" KindInterrupt = "InterruptEvent" KindStateUpdate = "ConversationStateUpdateEvent" KindConversationError = "ConversationErrorEvent" KindServerError = "ServerErrorEvent" KindSecurityAnalysis = "SecurityAnalysisEvent" KindHookExecution = "HookExecutionEvent" KindToken = "TokenEvent" KindCompletionLog = "LLMCompletionLogEvent" KindACPToolCall = "ACPToolCallEvent" KindStreamingDelta = "StreamingDeltaEvent" )
Event kinds: the Python class name OpenHands writes as each event's kind.
const ( SourceAgent = "agent" SourceUser = "user" SourceEnvironment = "environment" SourceHook = "hook" )
Sources of an event.
const ( ContentText = "text" ContentImage = "image" )
Content types.
const ( BlockThinking = "thinking" BlockRedactedThinking = "redacted_thinking" )
Thinking block types.
const ( ActionTask = "TaskAction" ActionDelegate = "DelegateAction" )
Action kinds the converter reads.
const AgentKindACP = "ACPAgent"
AgentKindACP is the kind of an agent that drives an external ACP agent, such as Claude Code, and records its tool calls rather than a model context.
const DefaultRejectionReason = "User rejected the action"
DefaultRejectionReason is the reason OpenHands writes when none was given.
const InterruptedPrefix = "Tool call interrupted before completion."
InterruptedPrefix starts the error of an AgentErrorEvent that answers a call a pause or a crash cut.
const MaxSize = 1 << 30
MaxSize bounds a file the reader reads. A larger file is refused rather than read into memory, and reported as malformed.
const RootParent = "__root__"
RootParent is the parent_id that marks an event a new root of the event tree.
Variables ¶
var KnownKinds = []string{ KindSystemPrompt, KindMessage, KindAction, KindObservation, KindUserReject, KindAgentError, KindCondensation, KindCondensationRequest, KindCondensationSummary, KindPause, KindInterrupt, KindStateUpdate, KindConversationError, KindServerError, KindSecurityAnalysis, KindHookExecution, KindToken, KindCompletionLog, KindACPToolCall, KindStreamingDelta, }
KnownKinds lists every event kind the SDK writes, from 1.0.0 to 1.55.0.
Functions ¶
func ConversationDir ¶
ConversationDir returns the conversation directory a path names: the path itself when it is a directory, the directory of its base_state.json or meta.json, or the conversation of an event file.
func Count ¶
func Count(raw json.RawMessage) int
Count reads a token count: 0 for one that is absent, negative, not a whole number or over a billion billion.
func EventIDs ¶
EventIDs lists the event IDs the events directory of dir names, from the file names alone: what a fork's copied events are told by.
func FindSessions ¶
FindSessions returns the conversation directories under root, sorted. root may be a directory of conversations, such as ~/.openhands/conversations, a directory above several, such as ~/.openhands, one conversation directory, or a file in one, whose conversation is returned. Sub-agents' conversations under subagents/ are part of their parent's and are not listed; nor are events, observations and version-control directories walked. A directory that cannot be read is skipped.
func Float ¶
func Float(raw json.RawMessage) (float64, bool)
Float reads a number written as a number.
func HexID ¶
HexID is a conversation ID as its directory names it: 32 hex digits, no dashes, lowercase.
func Int ¶
func Int(raw json.RawMessage) (n int64, exact, ok bool)
Int reads an integer written as a number, possibly 12.0. exact is false when a fraction was dropped.
func IsArtifact ¶
IsArtifact reports whether events of kind are not nodes of the event tree: OpenHands stamps them with a parent but never makes one the head, and skips them when it picks a leaf.
func IsConversationDir ¶
IsConversationDir reports whether dir holds a conversation: a base_state.json that is OpenHands' state, or an events directory with an event file in it.
func IsConversationFile ¶
IsConversationFile reports whether path is a file a conversation directory is found by: its base_state.json, or an event file in its events directory.
func IsKnownKind ¶
IsKnownKind reports whether the SDK writes events of kind.
func IsObservationLike ¶
IsObservationLike reports whether events of kind answer a call.
func ParseTime ¶
ParseTime reads a timestamp as OpenHands writes it, datetime.now().isoformat(): local time with no zone, which takes loc. naive says the timestamp had no zone. A time outside the years 1 to 9999 is none.
func StateID ¶
StateID reads the conversation ID the base_state.json of dir holds; empty when it holds none.
func SubagentParent ¶
SubagentParent returns the conversation directory a sub-agent's directory, <parent>/subagents/<hex>, is under, and whether it is one.
Types ¶
type Action ¶
type Action struct {
Kind string `json:"kind"`
// TaskAction.
Description string `json:"description"`
Prompt string `json:"prompt"`
SubagentType string `json:"subagent_type"`
Resume string `json:"resume"`
// DelegateAction.
Command string `json:"command"`
IDs []string `json:"ids"`
Tasks map[string]string `json:"tasks"`
Members
}
Action is a tool call's action, kind-tagged. The members of the actions the converter reads are declared: the task tool's TaskAction and the delegate tool's DelegateAction.
func ParseAction ¶
func ParseAction(raw json.RawMessage) *Action
ParseAction reads an action object; nil when it is absent or not an object.
func (Action) MarshalJSON ¶
MarshalJSON writes the action back as it was read.
func (*Action) UnmarshalJSON ¶
UnmarshalJSON decodes the action, keeping undeclared members and members of another JSON type.
type ActionEvent ¶
type ActionEvent struct {
Kind string `json:"kind"`
ID string `json:"id"`
Timestamp string `json:"timestamp"`
Source string `json:"source"`
ParentID string `json:"parent_id"`
Thought Contents `json:"thought"`
ReasoningContent string `json:"reasoning_content"`
ThinkingBlocks []*ThinkingBlock `json:"thinking_blocks"`
ResponsesReasoningItem *ReasoningItem `json:"responses_reasoning_item"`
Action json.RawMessage `json:"action"`
ToolName string `json:"tool_name"`
ToolCallID string `json:"tool_call_id"`
ToolCall *ToolCall `json:"tool_call"`
LLMResponseID string `json:"llm_response_id"`
SecurityRisk string `json:"security_risk"`
CriticResult json.RawMessage `json:"critic_result"`
Summary string `json:"summary"`
Members
}
ActionEvent is one tool call. The response's text, reasoning and thinking are on the first action of a response only.
func (ActionEvent) MarshalJSON ¶
func (e ActionEvent) MarshalJSON() ([]byte, error)
MarshalJSON writes the event back as it was read.
func (*ActionEvent) UnmarshalJSON ¶
func (e *ActionEvent) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes the event, keeping undeclared members.
type AgentErrorEvent ¶
type AgentErrorEvent struct {
Kind string `json:"kind"`
ID string `json:"id"`
Timestamp string `json:"timestamp"`
Source string `json:"source"`
ParentID string `json:"parent_id"`
ToolName string `json:"tool_name"`
ToolCallID string `json:"tool_call_id"`
Error string `json:"error"`
Classification json.RawMessage `json:"classification"`
Members
}
AgentErrorEvent answers a call the agent could not run: an unknown tool, invalid arguments, a tool that raised, or a call cut by a pause or a crash.
func (AgentErrorEvent) MarshalJSON ¶
func (e AgentErrorEvent) MarshalJSON() ([]byte, error)
MarshalJSON writes the event back as it was read.
func (*AgentErrorEvent) UnmarshalJSON ¶
func (e *AgentErrorEvent) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes the event, keeping undeclared members.
type AgentInfo ¶
type AgentInfo struct {
// Kind is "Agent", or "ACPAgent" for an agent that drives an
// external ACP agent.
Kind string
// Model, UsageID and ReasoningEffort are the LLM's, as last saved.
Model, UsageID, ReasoningEffort string
}
AgentInfo is what the converter reads of the agent's configuration.
type Condensation ¶
type Condensation struct {
Kind string `json:"kind"`
ID string `json:"id"`
Timestamp string `json:"timestamp"`
Source string `json:"source"`
ParentID string `json:"parent_id"`
ForgottenEventIDs []json.RawMessage `json:"forgotten_event_ids"`
Summary *string `json:"summary"`
SummaryOffset json.RawMessage `json:"summary_offset"`
LLMResponseID string `json:"llm_response_id"`
Members
}
Condensation is a context edit: the events it forgets leave the view, and its summary, when it has one and an offset, enters it at the offset.
func (*Condensation) Forgotten ¶
func (e *Condensation) Forgotten() (ids []string, bad int)
Forgotten returns the IDs the condensation forgets, and how many of its elements were not strings.
func (Condensation) MarshalJSON ¶
func (e Condensation) MarshalJSON() ([]byte, error)
MarshalJSON writes the event back as it was read.
func (*Condensation) Offset ¶
func (e *Condensation) Offset() (int, bool)
Offset returns the summary offset; false when there is none or it is not a count.
func (*Condensation) UnmarshalJSON ¶
func (e *Condensation) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes the event, keeping undeclared members.
type Content ¶
type Content struct {
Type string `json:"type"`
Text string `json:"text"`
ImageURLs []string `json:"image_urls"`
CachePrompt bool `json:"cache_prompt"`
Members
// Raw is the element as read, and Err why it did not decode, for an
// element that is not an object; nothing else is then set.
Raw json.RawMessage `json:"-"`
Err error `json:"-"`
}
Content is one TextContent or ImageContent.
func (Content) MarshalJSON ¶
MarshalJSON writes the element back as it was read.
func (*Content) UnmarshalJSON ¶
UnmarshalJSON decodes a content element, keeping undeclared members.
type Contents ¶
Contents is a list of TextContent and ImageContent, read element by element; OpenHands also accepts a bare string for a message's content, which IsText keeps.
func (Contents) MarshalJSON ¶
MarshalJSON writes the list back as it was read.
func (*Contents) UnmarshalJSON ¶
UnmarshalJSON reads the list element by element: an element that is not an object is kept with its error.
type Conversation ¶
type Conversation struct {
// Dir is the directory, and Name its name: the conversation ID as
// 32 hex digits.
Dir string
Name string
// State is base_state.json; StateErr says why it did not read.
State *State
StateRaw json.RawMessage
StateErr error
HasState bool
// Meta is the agent server's meta.json; MetaErr says why it did not
// read.
Meta *Meta
MetaRaw json.RawMessage
MetaErr error
HasMeta bool
// Events are the events OpenHands reads, in index order from 0 up
// to the first missing index. A malformed file in the sequence is
// an Event with Err set.
Events []*Event
// Files are every file of the events directory, by name.
Files []*File
// Others lists the other files of the directory, Dirs its
// directories, and Subagents the directories under subagents/
// holding a conversation of their own.
Others []string
Dirs []string
Subagents []string
// SubagentsErr says why the subagents directory could not be
// listed.
SubagentsErr error
}
Conversation is one conversation directory as read.
func Parse ¶
func Parse(name string, files map[string][]byte) *Conversation
Parse reads a conversation from its files' contents, without touching the file system: base_state.json and meta.json by name, and each file of the events directory as "events/<name>". name is the directory's name.
func ReadConversation ¶
func ReadConversation(path string) (*Conversation, error)
ReadConversation reads the conversation directory path names, or the conversation of the file it names. A file that cannot be read or parsed is recorded on the conversation, never fatal: ReadConversation fails only when the directory cannot be listed or holds no conversation.
func (*Conversation) Units ¶
func (c *Conversation) Units() int
Units is the number of units the conversation accounts for: base_state.json, meta.json, each file of the events directory and each other file.
type Cost ¶
type Cost struct {
Model string `json:"model"`
Cost json.RawMessage `json:"cost"`
Timestamp json.RawMessage `json:"timestamp"`
Members
}
Cost is one call's cost. It names no response.
func (Cost) MarshalJSON ¶
MarshalJSON writes the cost back as it was read.
func (*Cost) UnmarshalJSON ¶
UnmarshalJSON decodes the cost, keeping undeclared members.
type Event ¶
type Event struct {
// Index is the event's position, from its file name; File is the
// file name.
Index int
File string
// FileID is the event ID the file name holds, by which OpenHands
// indexes the event and resolves parent_id and its legacy parent.
FileID string
Kind string
ID string
Timestamp string
Source string
// ParentID is the event's parent_id; HasParent says the event
// carried one, as events from SDK 1.31 do.
ParentID string
HasParent bool
// Raw is the event object as read.
Raw json.RawMessage
// Err is set when the file is not a JSON object; nothing else is
// then set but Index and File.
Err error
}
Event is one event file as read: its envelope, decoded leniently, and the object itself. The kind's members are decoded on demand by the Decode methods, so an event of a kind this package does not know, or one whose members do not fit its kind, is still an event.
func (*Event) Action ¶
func (e *Event) Action() (*ActionEvent, error)
Action decodes an ActionEvent.
func (*Event) AgentError ¶
func (e *Event) AgentError() (*AgentErrorEvent, error)
AgentError decodes an AgentErrorEvent.
func (*Event) Condensation ¶
func (e *Event) Condensation() (*Condensation, error)
Condensation decodes a Condensation.
func (*Event) Message ¶
func (e *Event) Message() (*MessageEvent, error)
Message decodes a MessageEvent.
func (*Event) Observation ¶
func (e *Event) Observation() (*ObservationEvent, error)
Observation decodes an ObservationEvent.
func (*Event) SystemPrompt ¶
func (e *Event) SystemPrompt() (*SystemPromptEvent, error)
SystemPrompt decodes a SystemPromptEvent.
func (*Event) UserReject ¶
func (e *Event) UserReject() (*UserRejectObservation, error)
UserReject decodes a UserRejectObservation.
type File ¶
type File struct {
Name string
Index int
ID string
Status FileStatus
// Err says why a malformed file did not read.
Err error
}
File is one file of the events directory: every file whose name does not start with ".", which OpenHands keeps for its own sidecars.
type FileStatus ¶
type FileStatus string
FileStatus is what an events/ file is to the reader.
const ( // StatusEvent: an event in the conversation's sequence. StatusEvent FileStatus = "event" // StatusMalformed: an event file in the sequence that is empty, // not JSON or not an object; OpenHands skips an empty one. StatusMalformed FileStatus = "malformed" // StatusGap: an event file after a missing index, which OpenHands // does not read. StatusGap FileStatus = "gap" // StatusDuplicate: a second file for an index already taken; // OpenHands keeps one of them. StatusDuplicate FileStatus = "duplicate" // StatusBadName: a file whose name is not an event file's. StatusBadName FileStatus = "bad-name" )
type Latency ¶
type Latency struct {
Model string `json:"model"`
Latency json.RawMessage `json:"latency"`
ResponseID string `json:"response_id"`
Members
}
Latency is one call's latency in seconds.
func (Latency) MarshalJSON ¶
MarshalJSON writes the latency back as it was read.
func (*Latency) UnmarshalJSON ¶
UnmarshalJSON decodes the latency, keeping undeclared members.
type Members ¶
Members is embedded in every object this package decodes. It keeps the members the Go type does not declare, and remembers which declared members the input carried and which were null, so an object decoded and encoded again is the same JSON value.
type Message ¶
type Message struct {
Role string `json:"role"`
Content Contents `json:"content"`
ToolCalls []*ToolCall `json:"tool_calls"`
ToolCallID string `json:"tool_call_id"`
Name string `json:"name"`
ReasoningContent string `json:"reasoning_content"`
ThinkingBlocks []*ThinkingBlock `json:"thinking_blocks"`
ResponsesReasoningItem *ReasoningItem `json:"responses_reasoning_item"`
Members
}
Message is OpenHands' own LLM message, the llm_message of a MessageEvent.
func (Message) MarshalJSON ¶
MarshalJSON writes the message back as it was read.
func (*Message) UnmarshalJSON ¶
UnmarshalJSON decodes a message, keeping undeclared members and members of another JSON type.
type MessageEvent ¶
type MessageEvent struct {
Kind string `json:"kind"`
ID string `json:"id"`
Timestamp string `json:"timestamp"`
Source string `json:"source"`
ParentID string `json:"parent_id"`
LLMMessage *Message `json:"llm_message"`
LLMResponseID string `json:"llm_response_id"`
ActivatedSkills []string `json:"activated_skills"`
ExtendedContent Contents `json:"extended_content"`
Sender string `json:"sender"`
CriticResult json.RawMessage `json:"critic_result"`
Members
}
MessageEvent is a message from the user, the agent or the environment.
func (MessageEvent) MarshalJSON ¶
func (e MessageEvent) MarshalJSON() ([]byte, error)
MarshalJSON writes the event back as it was read.
func (*MessageEvent) UnmarshalJSON ¶
func (e *MessageEvent) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes the event, keeping undeclared members.
type Meta ¶
type Meta struct {
ID string `json:"id"`
Title string `json:"title"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
ForkedFromConversationID string `json:"forked_from_conversation_id"`
ForkedFromEventID string `json:"forked_from_event_id"`
Members
}
Meta is meta.json, the agent server's StoredConversation.
func (Meta) MarshalJSON ¶
MarshalJSON writes the metadata back as it was read.
func (*Meta) UnmarshalJSON ¶
UnmarshalJSON decodes the metadata, keeping undeclared members and members of another JSON type.
type Metrics ¶
type Metrics struct {
ModelName string `json:"model_name"`
Costs []*Cost `json:"costs"`
ResponseLatencies []*Latency `json:"response_latencies"`
TokenUsages []*TokenUsage `json:"token_usages"`
Members
Raw json.RawMessage `json:"-"`
Err error `json:"-"`
}
Metrics is one LLM's metrics: every call's token usage, latency and cost.
func (Metrics) MarshalJSON ¶
MarshalJSON writes the metrics back as they were read.
func (*Metrics) UnmarshalJSON ¶
UnmarshalJSON decodes the metrics, keeping undeclared members; a value that is not an object is kept with Err set.
type MetricsMap ¶
MetricsMap is usage_to_metrics, read value by value.
func (*MetricsMap) UnmarshalJSON ¶
func (m *MetricsMap) UnmarshalJSON(data []byte) error
UnmarshalJSON reads each value on its own: one that is not an object is kept with its error.
type Observation ¶
type Observation struct {
Kind string `json:"kind"`
Content Contents `json:"content"`
IsError bool `json:"is_error"`
// TerminalObservation (ExecuteBashObservation in 1.0) and
// BrowserObservation.
Metadata json.RawMessage `json:"metadata"`
FullOutputSaveDir string `json:"full_output_save_dir"`
ScreenshotData string `json:"screenshot_data"`
// TaskObservation.
TaskID string `json:"task_id"`
Subagent string `json:"subagent"`
Status string `json:"status"`
// ConsultTomObservation and SleeptimeComputeObservation.
Suggestions string `json:"suggestions"`
Confidence json.RawMessage `json:"confidence"`
Reasoning string `json:"reasoning"`
Message string `json:"message"`
SessionsProcessed json.RawMessage `json:"sessions_processed"`
Members
}
Observation is a tool's kind-tagged observation. The members its kind's rendering reads are declared; the rest are kept.
func (Observation) MarshalJSON ¶
func (o Observation) MarshalJSON() ([]byte, error)
MarshalJSON writes the observation back as it was read.
func (*Observation) Terminal ¶
func (o *Observation) Terminal() TerminalMetadata
Terminal reads the metadata of a terminal observation: exit code -1, the SDK's default, when it has none.
func (*Observation) UnmarshalJSON ¶
func (o *Observation) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes the observation, keeping undeclared members and members of another JSON type.
type ObservationEvent ¶
type ObservationEvent struct {
Kind string `json:"kind"`
ID string `json:"id"`
Timestamp string `json:"timestamp"`
Source string `json:"source"`
ParentID string `json:"parent_id"`
ToolName string `json:"tool_name"`
ToolCallID string `json:"tool_call_id"`
Observation *Observation `json:"observation"`
ActionID string `json:"action_id"`
ExtendedContent Contents `json:"extended_content"`
Members
}
ObservationEvent is a tool's result.
func (ObservationEvent) MarshalJSON ¶
func (e ObservationEvent) MarshalJSON() ([]byte, error)
MarshalJSON writes the event back as it was read.
func (*ObservationEvent) UnmarshalJSON ¶
func (e *ObservationEvent) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes the event, keeping undeclared members.
type ReasoningItem ¶
type ReasoningItem struct {
ID string `json:"id"`
Summary []string `json:"summary"`
Content []string `json:"content"`
EncryptedContent string `json:"encrypted_content"`
Status string `json:"status"`
Members
}
ReasoningItem is the OpenAI Responses reasoning item OpenHands keeps: summary and content as plain strings.
func (ReasoningItem) MarshalJSON ¶
func (r ReasoningItem) MarshalJSON() ([]byte, error)
MarshalJSON writes the item back as it was read.
func (*ReasoningItem) UnmarshalJSON ¶
func (r *ReasoningItem) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes the item, keeping undeclared members.
type State ¶
type State struct {
ID string `json:"id"`
Agent json.RawMessage `json:"agent"`
Workspace json.RawMessage `json:"workspace"`
ExecutionStatus string `json:"execution_status"`
ConfirmationPolicy json.RawMessage `json:"confirmation_policy"`
LeafEventID string `json:"leaf_event_id"`
HeadIsEmpty bool `json:"head_is_empty"`
Stats *Stats `json:"stats"`
Members
}
State is base_state.json: the conversation's ConversationState, rewritten on every change. Events are not in it.
func (State) MarshalJSON ¶
MarshalJSON writes the state back as it was read.
func (*State) UnmarshalJSON ¶
UnmarshalJSON decodes the state, keeping undeclared members and members of another JSON type.
func (*State) WorkingDir ¶
WorkingDir reads the workspace's working directory.
type Stats ¶
type Stats struct {
UsageToMetrics MetricsMap `json:"usage_to_metrics"`
Members
}
Stats is the conversation's per-LLM metrics, by usage ID: "agent", "condenser", an LLM's own usage_id, and the copies of sub-agents' metrics under "task:<id>" and "delegate:<id>".
func (Stats) MarshalJSON ¶
MarshalJSON writes the stats back as it was read.
func (*Stats) UnmarshalJSON ¶
UnmarshalJSON decodes the stats, keeping undeclared members.
type SystemPromptEvent ¶
type SystemPromptEvent struct {
Kind string `json:"kind"`
ID string `json:"id"`
Timestamp string `json:"timestamp"`
Source string `json:"source"`
ParentID string `json:"parent_id"`
SystemPrompt *Content `json:"system_prompt"`
Tools []json.RawMessage `json:"tools"`
DynamicContext *Content `json:"dynamic_context"`
Members
}
SystemPromptEvent is the system prompt and the tools the agent was given. Tools are chat tool params in SDK 1.0 to 1.6, ToolDefinition dumps with no parameter schema from 1.7.
func (SystemPromptEvent) MarshalJSON ¶
func (e SystemPromptEvent) MarshalJSON() ([]byte, error)
MarshalJSON writes the event back as it was read.
func (*SystemPromptEvent) UnmarshalJSON ¶
func (e *SystemPromptEvent) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes the event, keeping undeclared members.
type TerminalMetadata ¶
type TerminalMetadata struct {
ExitCode int64
WorkingDir string
PyInterpreterPath string
Prefix, Suffix string
}
TerminalMetadata is a terminal observation's metadata, as its rendering reads it.
type ThinkingBlock ¶
type ThinkingBlock struct {
Type string `json:"type"`
Thinking string `json:"thinking"`
Signature string `json:"signature"`
Data string `json:"data"`
Members
}
ThinkingBlock is an Anthropic thinking or redacted_thinking block.
func (ThinkingBlock) MarshalJSON ¶
func (b ThinkingBlock) MarshalJSON() ([]byte, error)
MarshalJSON writes the block back as it was read.
func (*ThinkingBlock) UnmarshalJSON ¶
func (b *ThinkingBlock) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes a block, keeping undeclared members.
type TokenUsage ¶
type TokenUsage struct {
Model string `json:"model"`
PromptTokens json.RawMessage `json:"prompt_tokens"`
CompletionTokens json.RawMessage `json:"completion_tokens"`
CacheReadTokens json.RawMessage `json:"cache_read_tokens"`
CacheWriteTokens json.RawMessage `json:"cache_write_tokens"`
ReasoningTokens json.RawMessage `json:"reasoning_tokens"`
ContextWindow json.RawMessage `json:"context_window"`
PerTurnToken json.RawMessage `json:"per_turn_token"`
ResponseID string `json:"response_id"`
Members
}
TokenUsage is one call's token counts. PromptTokens is litellm's, which counts cache reads and writes, except for an ACPAgent, which counts them apart.
func (TokenUsage) MarshalJSON ¶
func (u TokenUsage) MarshalJSON() ([]byte, error)
MarshalJSON writes the usage back as it was read.
func (*TokenUsage) UnmarshalJSON ¶
func (u *TokenUsage) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes the usage, keeping undeclared members.
type ToolCall ¶
type ToolCall struct {
ID string `json:"id"`
ResponsesItemID string `json:"responses_item_id"`
Name string `json:"name"`
Arguments string `json:"arguments"`
Origin string `json:"origin"`
Members
}
ToolCall is a MessageToolCall: one function call as OpenHands stores it, its arguments a JSON string.
func (ToolCall) MarshalJSON ¶
MarshalJSON writes the tool call back as it was read.
func (*ToolCall) UnmarshalJSON ¶
UnmarshalJSON decodes a tool call, keeping undeclared members.
type UserRejectObservation ¶
type UserRejectObservation struct {
Kind string `json:"kind"`
ID string `json:"id"`
Timestamp string `json:"timestamp"`
Source string `json:"source"`
ParentID string `json:"parent_id"`
ToolName string `json:"tool_name"`
ToolCallID string `json:"tool_call_id"`
RejectionReason string `json:"rejection_reason"`
RejectionSource string `json:"rejection_source"`
ActionID string `json:"action_id"`
Members
}
UserRejectObservation answers a call the user or a hook rejected.
func (UserRejectObservation) MarshalJSON ¶
func (e UserRejectObservation) MarshalJSON() ([]byte, error)
MarshalJSON writes the event back as it was read.
func (*UserRejectObservation) UnmarshalJSON ¶
func (e *UserRejectObservation) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes the event, keeping undeclared members.