mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-02 22:40:22 +00:00
5.2 KiB
5.2 KiB
Session V2 Concept Gaps
Compared with packages/opencode/src/session/message-v2.ts and packages/opencode/src/session/processor.ts, packages/opencode/src/v2 currently captures the rough event stream for prompts, assistant steps, text, reasoning, tools, retries, and compaction, but it does not yet capture several persisted-message and processor concepts.
Message Metadata
- User messages are missing selected
agent,model,system, enabledtools, outputformat, and summary metadata. - Assistant messages are missing
parentID,agent,providerID,modelID,variant,path.cwd,path.root, deprecatedmode,summary,structured,finish, and typederror.
Output Format
- Text output format.
- JSON-schema output format.
- Structured-output retry count.
- Structured assistant result payload.
- Structured-output error classification.
Errors
- Aborted error.
- Provider auth error.
- API error with status, retryability, headers, body, and metadata.
- Context-overflow error.
- Output-length error.
- Unknown error.
- V2 mostly reduces assistant errors to strings, except retry errors.
Part Identity
- V1 has stable
MessageID,PartID,sessionID, andmessageIDon every part. - V2 assistant content does not preserve stable per-content IDs.
- Stable content IDs matter for deltas, updates, removals, sync events, and UI reconciliation.
Part Timing And Metadata
- V1 text, reasoning, and tool states carry timing and provider metadata.
- V2 assistant text and reasoning content only store text.
- V2 events include metadata, but
SessionEntrycurrently drops most provider metadata.
Snapshots And Patches
- Snapshot parts.
- Patch parts.
- Step-start snapshot references.
- Step-finish snapshot references.
- Processor behavior that tracks a snapshot before the stream and emits patches after step finish or cleanup.
Step Boundaries
- V1 stores
step-startandstep-finishas first-class parts. - V2 has
step.startedandstep.endedevents, but the assistant entry only stores aggregate cost and tokens. - V2 does not preserve step boundary parts, finish reason, or snapshot details in the entry model.
Compaction
- V1 compaction parts have
auto,overflow, andtail_start_id. - V2 compacted events have
autoand optionaloverflow, but no retained-tail marker. - V1 also has history filtering semantics around completed summary messages and retained tails.
Files And Sources
- V1 file parts have
mime,filename,url, and typed source information. - V1 source variants include file, symbol, and resource sources.
- Symbol sources include LSP range, name, and kind.
- Resource sources include client name and URI.
- V2 file attachments have
uri,mime,name,description, and a generic text source, but lose source type, LSP metadata, and resource metadata.
Agents And Subtasks
- Agent parts.
- Subtask parts.
- Subtask prompt, description, agent, model, and command.
- V2 has agent attachments on prompts, but no assistant/session content equivalent for subtask execution.
Text Flags
- Synthetic text flag.
- Ignored text flag.
- V2 has a separate synthetic entry, but no ignored text concept.
Tool Calls
- V1 pending tool state stores parsed input and raw input text separately.
- V2 pending tool state stores a string input but does not preserve a separate raw field.
- V1 completed tool state has
time.start,time.end, and optionaltime.compacted. - V2 tool time has
created,ran,completed, andpruned, but the stepper currently does not setcompletedorpruned. - V1 error tool state has
time.startandtime.end. - V1 supports interrupted tool errors with
metadata.interruptedand preserved partial output. - V1 tracks provider execution and provider call metadata.
- V2 events include provider info, but
SessionEntryStepperdrops it from entries. - V1 has tool-output compaction and truncation behavior via
time.compacted.
Media Handling
- V1 models tool attachments as file parts and has provider-specific handling for media in tool results.
- V1 can strip media, inject synthetic user messages for unsupported providers, and uses a synthetic attachment prompt.
- V2 has attachments but not these model-message conversion semantics.
Retries
- V1 stores retries as independently addressable retry parts.
- V2 stores retries as an assistant aggregate.
- V2 captures some retry information, but not the independent part identity/update model.
Processor Control Flow
- Session status transitions: busy, retry, and idle.
- Retry policy integration.
- Context-overflow-driven compaction.
- Abort and interrupt handling.
- Permission-denied blocking.
- Doom-loop detection.
- Plugin hook for
experimental.text.complete. - Background summary generation after steps.
- Cleanup semantics for open text, reasoning, and tool calls.
Sync And Bus Events
- Message updated.
- Message removed.
- Message part updated.
- Message part delta.
- Message part removed.
- V2 has domain events, but not the sync/bus event model for persisted message and part updates/removals.
History Retrieval
- Cursor encoding and decoding.
- Paged message retrieval.
- Reverse streaming through history.
- Compaction-aware history filtering.