Documentation
¶
Index ¶
- Variables
- type HistoryStore
- type MemoryStore
- func (s *MemoryStore) LoadHistory(_ context.Context, threadID string) ([]protocol.ChatMessage, error)
- func (s *MemoryStore) LoadWorkspaceHistory(_ context.Context, workspaceID, threadID string) ([]protocol.ChatMessage, error)
- func (s *MemoryStore) SaveHistory(_ context.Context, threadID string, messages []protocol.ChatMessage) error
- func (s *MemoryStore) SaveWorkspaceHistory(_ context.Context, workspaceID, threadID string, ...) error
- type Session
- func (s *Session) Append(ctx context.Context, msg protocol.ChatMessage) error
- func (s *Session) AppendToolResult(ctx context.Context, callID string, part protocol.ContentPart) error
- func (s *Session) AppendToolResultParts(ctx context.Context, callID string, parts ...protocol.ContentPart) error
- func (s *Session) DropTrailingUserDuplicate(msg protocol.ChatMessage) bool
- func (s *Session) History() []protocol.ChatMessage
- func (s *Session) InvokeTool(ctx context.Context, env protocol.ToolInvokeEnvelope) (tools.Result, error)
- func (s *Session) InvokeToolApproved(ctx context.Context, env protocol.ToolInvokeEnvelope) (tools.Result, error)
- func (s *Session) PrepareTool(ctx context.Context, env protocol.ToolInvokeEnvelope) (tools.PreparedInvocation, error)
- func (s *Session) PrepareToolApproved(ctx context.Context, env protocol.ToolInvokeEnvelope) (tools.PreparedInvocation, error)
- type WorkspaceHistoryStore
Constants ¶
This section is empty.
Variables ¶
var ( ErrMissingThreadID = errors.New("harness: thread id required") ErrMissingHistoryStore = errors.New("harness: history store required") )
Functions ¶
This section is empty.
Types ¶
type HistoryStore ¶
type HistoryStore interface {
// LoadHistory returns the thread's messages. When the turn carries an OBO
// authority it is available on ctx via tools.MemoryAuthorityFrom — an
// authority-aware store (e.g. a MemoryLayer-backed loader) should apply it;
// local stores ignore it.
LoadHistory(ctx context.Context, threadID string) ([]protocol.ChatMessage, error)
SaveHistory(ctx context.Context, threadID string, messages []protocol.ChatMessage) error
}
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore is an in-process HistoryStore. It backs ephemeral sub-agent sessions (which must not persist to or pollute the durable thread history) and is handy for tests.
func NewMemoryStore ¶
func NewMemoryStore() *MemoryStore
NewMemoryStore returns an empty in-memory history store.
func (*MemoryStore) LoadHistory ¶
func (s *MemoryStore) LoadHistory(_ context.Context, threadID string) ([]protocol.ChatMessage, error)
LoadHistory returns a copy of the thread's messages.
func (*MemoryStore) LoadWorkspaceHistory ¶ added in v0.0.2
func (s *MemoryStore) LoadWorkspaceHistory(_ context.Context, workspaceID, threadID string) ([]protocol.ChatMessage, error)
LoadWorkspaceHistory returns a copy of the messages stored under the composite (workspaceID, threadID).
func (*MemoryStore) SaveHistory ¶
func (s *MemoryStore) SaveHistory(_ context.Context, threadID string, messages []protocol.ChatMessage) error
SaveHistory replaces the thread's messages with a copy of the given slice.
func (*MemoryStore) SaveWorkspaceHistory ¶ added in v0.0.2
func (s *MemoryStore) SaveWorkspaceHistory(_ context.Context, workspaceID, threadID string, messages []protocol.ChatMessage) error
SaveWorkspaceHistory replaces the messages stored under the composite (workspaceID, threadID).
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
func NewEphemeralSession ¶
func NewEphemeralSession(addr protocol.MessageAddress, registry *tools.Registry, authority tools.MemoryAuthority) (*Session, error)
NewEphemeralSession starts a session for a one-shot EPHEMERAL turn: it loads NO prior durable history (the turn's context is only the inbound message + its parts) and its Append mutates only in-memory state — SaveHistory is never called, so nothing the turn produces is persisted durably. The in-memory history still accumulates the user/tool/assistant messages so the tool loop and context assembly work exactly as a normal turn.
func NewSession ¶
func NewSession(ctx context.Context, addr protocol.MessageAddress, store HistoryStore, registry *tools.Registry, authority tools.MemoryAuthority) (*Session, error)
func (*Session) AppendToolResult ¶
func (s *Session) AppendToolResult(ctx context.Context, callID string, part protocol.ContentPart) error
AppendToolResult persists a tool_result content part as a tool-result message. The turn loop calls it for every tool outcome — success, denial, and error — so the result reliably enters the history sent back to the model.
func (*Session) AppendToolResultParts ¶
func (s *Session) AppendToolResultParts(ctx context.Context, callID string, parts ...protocol.ContentPart) error
AppendToolResultParts persists one tool-result message carrying the given parts (the tool_result part plus any extra parts a tool co-located with it, e.g. a subagent reference part). Co-locating on the tool-result message keeps the provider message non-empty (it already carries the tool_result part), so an extra reference part can't produce an empty provider message.
func (*Session) DropTrailingUserDuplicate ¶
func (s *Session) DropTrailingUserDuplicate(msg protocol.ChatMessage) bool
DropTrailingUserDuplicate removes the last history message when it is a user message that duplicates msg — same id, or (when ids differ or are absent) the same non-empty text. It exists to drop a copy of the incoming turn that the host committed to the store out-of-band, so appending the incoming turn does not double it. It mutates only the in-memory history; a following Append persists the result. Returns whether a message was dropped.
func (*Session) History ¶
func (s *Session) History() []protocol.ChatMessage
func (*Session) InvokeTool ¶
func (*Session) InvokeToolApproved ¶
func (s *Session) InvokeToolApproved(ctx context.Context, env protocol.ToolInvokeEnvelope) (tools.Result, error)
InvokeToolApproved invokes a tool the user just authorized via the approval flow, bypassing the registry policy gate for this single call.
func (*Session) PrepareTool ¶ added in v0.0.2
func (s *Session) PrepareTool(ctx context.Context, env protocol.ToolInvokeEnvelope) (tools.PreparedInvocation, error)
PrepareTool performs registry policy/audit/view admission without invoking the tool body. It is used by deterministic parallel batches.
func (*Session) PrepareToolApproved ¶ added in v0.0.2
func (s *Session) PrepareToolApproved(ctx context.Context, env protocol.ToolInvokeEnvelope) (tools.PreparedInvocation, error)
PrepareToolApproved is PrepareTool for a once-approved invocation.
type WorkspaceHistoryStore ¶ added in v0.0.2
type WorkspaceHistoryStore interface {
LoadWorkspaceHistory(ctx context.Context, workspaceID, threadID string) ([]protocol.ChatMessage, error)
SaveWorkspaceHistory(ctx context.Context, workspaceID, threadID string, messages []protocol.ChatMessage) error
}
WorkspaceHistoryStore is the additive multi-workspace form of HistoryStore. NewSession uses it whenever the message address carries a workspace ID, while retaining HistoryStore as the compatibility surface for existing backends. Implementations must key data by the composite (workspaceID, threadID).