GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(core): add embedded v2 session runtime and tool foundation (#30632) · Archipel/opencode@76ee87e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .github/workflows
    • test.yml
  • AGENTS.md
  • CONTEXT.md
  • bun.lock
  • packages
    • core
      • migration
        • 20260603001617_session_message_projection_indexes
          • migration.sql
          • snapshot.json
        • 20260603040000_session_message_projection_order
          • migration.sql
          • snapshot.json
        • 20260603141458_session_input_inbox
          • migration.sql
          • snapshot.json
        • 20260603160727_jittery_ezekiel_stane
          • migration.sql
          • snapshot.json
      • package.json
      • src
        • background-job.ts
        • config.ts
        • config
          • agent.ts
          • plugin
            • skill.ts
        • database
          • migration.gen.ts
          • migration.ts
          • migration
            • 20260603001617_session_message_projection_indexes.ts
            • 20260603040000_session_message_projection_order.ts
            • 20260603141458_session_input_inbox.ts
            • 20260603160727_jittery_ezekiel_stane.ts
          • sqlite.bun.ts
          • sqlite.node.ts
        • effect
          • keyed-mutex.ts
        • event.ts
        • event
          • sql.ts
        • file-mutation.ts
        • filesystem.ts
        • filesystem
          • ripgrep.ts
        • flag
          • flag.ts
        • fs-util.ts
        • location-layer.ts
        • location-mutation.ts
        • location-search.ts
        • location.ts
        • model.ts
        • opencode.ts
        • patch.ts
        • permission.ts
        • plugin.ts
        • plugin
          • agent.ts
        • process.ts
        • provider.ts
        • question.ts
        • ripgrep.ts
        • schema.ts
        • session-system-context.ts
        • session.ts
        • session
          • context.ts
          • error.ts
          • event.ts
          • execution.ts
          • execution
            • local.ts
          • info.ts
          • input.ts
          • message-updater.ts
          • message.ts
          • projector.ts
          • prompt.ts
          • run-coordinator.ts
          • runner
            • index.ts
            • llm.ts
            • model.ts
            • publish-llm-event.ts
            • to-llm-message.ts
          • schema.ts
          • sql.ts
          • store.ts
          • todo.ts
        • skill.ts
        • skill
          • discovery.ts
        • state.ts
        • system-context.ts
        • tool-output-store.ts
        • tool-output.ts
        • tool-registry.ts
        • tool
          • apply-patch.ts
          • bash.ts
          • builtins.ts
          • edit.ts
          • glob.ts
          • grep.ts
          • question.ts
          • read.ts
          • skill.ts
          • todowrite.ts
          • webfetch.ts
          • websearch.ts
          • write.ts
        • util
          • hash.ts
        • v1
          • session.ts
      • test
        • agent.test.ts
        • background-job.test.ts
        • config
          • skill.test.ts
        • database-migration.test.ts
        • effect
          • keyed-mutex.test.ts
        • event.test.ts
        • file-mutation.test.ts
        • filesystem
          • filesystem.test.ts
          • ripgrep.test.ts
        • fixtures/recordings/session-runner
          • openai-chat-streams-text.json
        • fixture
          • tmpdir.ts
        • location-filesystem.test.ts
        • location-layer.test.ts
        • location-mutation.test.ts
        • location-search.test.ts
        • location.test.ts
        • opencode.test.ts
        • patch.test.ts
        • permission.test.ts
        • plugin.test.ts
        • process
          • process.test.ts
        • public-catalog.test.ts
        • question.test.ts
        • session-create.test.ts
        • session-projector.test.ts
        • session-prompt.test.ts
        • session-run-coordinator.test.ts
        • session-runner-message.test.ts
        • session-runner-model.test.ts
        • session-runner-recorded.test.ts
        • session-runner-tool-registry.test.ts
        • session-runner.test.ts
        • session-system-context.test.ts
        • session-todo.test.ts
        • session-tool-progress.test.ts
        • skill-discovery.test.ts
        • system-context.test.ts
        • tool-apply-patch.test.ts
        • tool-bash.test.ts
        • tool-edit.test.ts
        • tool-glob.test.ts
        • tool-grep.test.ts
        • tool-output-store.test.ts
        • tool-question.test.ts
        • tool-read.test.ts
        • tool-skill.test.ts
        • tool-todowrite.test.ts
        • tool-webfetch.test.ts
        • tool-websearch.test.ts
        • tool-write.test.ts
    • llm
      • AGENTS.md
      • example
        • tutorial.ts
      • src
        • index.ts
        • llm.ts
        • protocols
          • anthropic-messages.ts
          • bedrock-converse.ts
          • gemini.ts
          • openai-chat.ts
          • openai-responses.ts
          • shared.ts
          • utils
            • lifecycle.ts
        • route
          • client.ts
        • schema
          • events.ts
          • ids.ts
          • messages.ts
        • tool-runtime.ts
        • tool.ts
      • test
        • lib
          • tool-runtime.ts
        • llm.test.ts
        • provider
          • anthropic-messages.test.ts
          • bedrock-converse.test.ts
          • gemini.test.ts
          • openai-chat.test.ts
          • openai-responses.test.ts
        • recorded-scenarios.ts
        • schema.test.ts
        • tool-runtime.test.ts
        • tool.types.ts
    • opencode
      • src
        • background
          • job.ts
        • cli/cmd/tui
          • context
            • sync-v2.tsx
          • feature-plugins/system
            • session-v2.tsx
        • control-plane
          • workspace.ts
        • server/routes/instance/httpapi
          • groups
            • v2.ts
            • v2
              • location.ts
              • model.ts
              • provider.ts
              • question.ts
              • session.ts
          • handlers
            • sync.ts
            • v2.ts
            • v2
              • message.ts
              • model.ts
              • provider.ts
              • question.ts
              • session.ts
          • public.ts
        • session
          • llm
            • native-runtime.ts
          • processor.ts
          • prompt.ts
        • util
          • filesystem.ts
      • test
        • cli/tui
          • sync-v2.test.tsx
        • server
          • httpapi-exercise
            • backend.ts
            • index.ts
            • runner.ts
            • runtime.ts
          • httpapi-public-catalog-redaction.test.ts
          • httpapi-public-openapi.test.ts
          • httpapi-sdk.test.ts
          • httpapi-session.test.ts
        • session
          • llm-native-recorded.test.ts
          • llm-native.test.ts
          • processor-effect.test.ts
        • v2
          • session-message-updater.test.ts
    • sdk
      • js/src/v2
        • client.ts
        • gen
          • sdk.gen.ts
          • types.gen.ts
      • openapi.json
  • specs/v2
    • catalog-config-plugin-lifecycle.md
    • provider-model.md
    • schema-changelog.md
    • session.md
    • todo.md

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.github/workflows/test.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/test.yml
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ jobs:
6464
turbo-${{ runner.os }}-
6565
6666
- name: Run unit tests
67-
run: bun turbo test:ci
67+
timeout-minutes: 20
68+
run: bun turbo test:ci --log-order=stream --log-prefix=task
6869
env:
6970
OPENCODE_EXPERIMENTAL_DISABLE_FILEWATCHER: ${{ runner.os == 'Windows' && 'true' || 'false' }}
7071

Collapse file

‎AGENTS.md‎

Copy file name to clipboardExpand all lines: AGENTS.md
+11Lines changed: 11 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,14 @@ const table = sqliteTable("session", {
138138
## Type Checking
139139

140140
- Always run `bun typecheck` from package directories (e.g., `packages/opencode`), never `tsc` directly.
141+
142+
## V2 Session Core
143+
144+
- Keep durable prompt admission separate from model execution. `SessionV2.prompt(...)` admits one durable `session_input` row before scheduling advisory `SessionExecution.wake(sessionID)` unless `resume: false` requests admit-only behavior. The serialized runner promotes admitted inputs into visible user messages at safe boundaries.
145+
- Reusing a Session ID adopts the existing Session. Reusing a prompt message ID reconciles an exact retry only when Session, prompt, and delivery mode match; conflicting reuse fails. Historical projected prompts lazily synthesize promoted inbox records during exact retry.
146+
- Keep `SessionExecution` process-global and Session-ID based. It discovers placement through the read-side `SessionStore` and `LocationServiceMap.get(session.location)`; no layer should take a Session ID.
147+
- Keep `SessionRunner`, model resolution, tool registry, permissions, and filesystem Location-scoped. Omitted `Location.workspaceID` means implicit-local placement; explicit workspace identity remains reserved for future placement semantics.
148+
- Preserve one explicit `llm.stream(request)` call per provider turn and reload projected history before durable continuation. Do not bridge through legacy `SessionPrompt.loop(...)` or delegate orchestration to an in-memory tool loop.
149+
- Keep local Session drains process-local until clustering is implemented. `SessionRunCoordinator` joins explicit same-Session resumes, coalesces prompt wakeups, and allows different Sessions to run concurrently. Advisory wakes drain eligible durable inbox rows only; post-crash activity recovery requires a separate explicit design before it may retry provider work.
150+
- Keep delivery vocabulary explicit. Prompts steer by default and coalesce into the active activity at the next safe provider-turn boundary. Explicit `queue` inputs open FIFO future activities one at a time after the active activity settles.
151+
- Keep EventV2 replay owner claims separate from clustered Session execution ownership.
Collapse file

‎CONTEXT.md‎

Copy file name to clipboard
+77Lines changed: 77 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# OpenCode Session Runtime
2+
3+
OpenCode sessions preserve durable conversational history while assembling the runtime context an agent needs to act correctly in its current environment.
4+
5+
## Language
6+
7+
**System Context**:
8+
The structured collection of contextual facts presented to the model as initial instructions and chronological updates.
9+
_Avoid_: System prompt
10+
11+
**Context Component**:
12+
One independently loaded fact within the **System Context**, represented by a stable key and one effectfully loaded baseline/update rendering.
13+
_Avoid_: Prompt fragment
14+
15+
**Mid-Conversation System Message**:
16+
A durable chronological instruction that tells the model the newly effective state of a changed **Context Component**.
17+
_Avoid_: System update, system notification, raw text diff
18+
19+
**Context Epoch**:
20+
The span during which one initially rendered **System Context** remains immutable, ending at compaction or another baseline-replacing transition.
21+
22+
**Baseline System Context**:
23+
The full **System Context** rendered at the start of a **Context Epoch**.
24+
_Avoid_: Live system prompt
25+
26+
**Context Checkpoint**:
27+
The durable model-hidden comparison state used to detect which **Context Components** changed since context was last admitted to a provider turn.
28+
29+
**Unavailable Context**:
30+
An expected temporary inability to load a **Context Component** value; the runtime retains its prior effective state and emits no update, or omits it until first successfully loaded.
31+
32+
**Safe Provider-Turn Boundary**:
33+
The point immediately before a provider call, after durable input promotion and any required tool settlement, where context changes may be admitted chronologically.
34+
35+
## Relationships
36+
37+
- A **System Context** contains one or more **Context Components**.
38+
- A changed **Context Component** may produce one **Mid-Conversation System Message** containing its newly effective state.
39+
- A **Mid-Conversation System Message** persists its originating **Context Component** key and the exact rendered text sent to the model.
40+
- A **Context Checkpoint** advances atomically with the corresponding durable **Mid-Conversation System Message**.
41+
- A **Context Checkpoint** stores one rendered-content hash per stable **Context Component** key so core and plugin-defined components can evolve independently.
42+
- Changes from multiple **Context Components** admitted at one safe boundary combine into one **Mid-Conversation System Message**.
43+
- Context changes are sampled and admitted lazily at a **Safe Provider-Turn Boundary**, never pushed asynchronously when their source changes.
44+
- At a **Safe Provider-Turn Boundary**, newly promoted user input or settled tool results precede any combined **Mid-Conversation System Message**.
45+
- The first provider turn renders the latest **Baseline System Context** and initializes its **Context Checkpoint** without emitting a redundant **Mid-Conversation System Message**.
46+
- Compaction starts a new **Context Epoch** with a freshly rendered **Baseline System Context** and **Context Checkpoint**; prior **Mid-Conversation System Messages** remain durable audit history but leave projected model history.
47+
- A **Context Checkpoint** is an evolvable component map; a newly registered core or plugin-defined **Context Component** absent from an existing checkpoint emits its current state once at the next **Safe Provider-Turn Boundary**.
48+
- **Context Component** keys are stable and namespaced; duplicate keys fail assembly. Built-in components preserve declaration order and plugin-defined components append in lexicographic key order so rendered context is deterministic.
49+
- Each **Context Component** loader returns its model-visible baseline string and absolute current-state update string from one coherent sample; the update string is hashed for change detection.
50+
- **Unavailable Context** uses stale-while-revalidate semantics and is distinct from a successfully loaded absence, which may emit removal text.
51+
- Ordinary **Context Component** loaders return values directly; loaders that intentionally use stale-while-revalidate may explicitly return **Unavailable Context**.
52+
- Nested project instruction files discovered while reading join the effective instructions returned by the instruction service and are admitted durably at the next **Safe Provider-Turn Boundary**.
53+
- A discovered nested project instruction remains active for the session while it stays in the same location and is folded into later **Baseline System Contexts** after compaction.
54+
- Location-scoped services naturally re-resolve effective context when a moved session next runs in its destination location.
55+
- Instruction discovery, source identity, persistence, and file loading belong to the instruction service; the **System Context** abstraction only composes effectful producers and renders loaded values.
56+
- Plugin-defined **Context Components** register through a scoped replayable registry so plugin hot reload adds and removes components predictably.
57+
- Context source changes never wake idle sessions; the next naturally scheduled **Safe Provider-Turn Boundary** loads and compares current values lazily.
58+
- Once admitted, a **Mid-Conversation System Message** remains durable even if the following provider attempt fails and is replayed unchanged on retry.
59+
- **Mid-Conversation System Messages** remain durable model-projection history but are hidden from normal user-facing transcript surfaces.
60+
- The date **Context Component** initially preserves host-local calendar-date behavior; a configured user timezone may replace that default later.
61+
- A **Context Epoch** begins with one immutable **Baseline System Context**.
62+
- A **Baseline System Context** is stored durably and reused verbatim across process restarts within its **Context Epoch**.
63+
- A **Baseline System Context** durably preserves deterministic keyed top-level component strings rather than eagerly joining all text; request assembly lowers them into canonical LLM system parts.
64+
- Compaction or a model/provider switch starts a new **Context Epoch** because the baseline can be replaced without preserving the prior provider cache.
65+
- A model/provider switch always starts a new **Context Epoch** while preserving chronological conversation history.
66+
- A **Mid-Conversation System Message** lowers to the provider's native chronological instruction role when supported and to a wrapped chronological fallback otherwise.
67+
- When an effective instruction file changes, its **Mid-Conversation System Message** includes the complete current contents and supersedes the prior version from that source; when it is removed, the message states that it no longer applies.
68+
69+
## Example dialogue
70+
71+
> **Dev:** "The date changed while the session was active. Should the **Mid-Conversation System Message** say what the old date was?"
72+
> **Domain expert:** "No. Emit the newly effective date so the agent can act on the current **System Context**."
73+
74+
## Flagged ambiguities
75+
76+
- Legacy `experimental.chat.system.transform` can mutate the assembled baseline system prompt arbitrarily, but V2 plugins do not yet expose an equivalent hook. Decide separately whether to port it, replace dynamic uses with plugin-defined **Context Components**, or narrow its semantics.
77+
- A location change likely starts a new **Context Epoch** so location-dependent instructions and discovery can be rebuilt cleanly, but implementation should verify whether an append-only update is sufficient and meaningfully preserves cache.

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.