Skip to content

feat(core): add transient session generation#37330

Merged
kitlangton merged 3 commits into
v2from
session-generate
Jul 16, 2026
Merged

feat(core): add transient session generation#37330
kitlangton merged 3 commits into
v2from
session-generate

Conversation

@kitlangton

@kitlangton kitlangton commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

What

Adds the internal session.generate({ sessionID, prompt }) tracer bullet for one read-only, Session-aware model generation. It uses the selected agent and model, canonical settled history, current instructions, Session request hooks, headers, and cache identity, then returns collected text without admitting input or mutating durable Session state.

Fresh instruction changes are rendered only on the private request. Temporarily unavailable sources reuse their committed value, while an unavailable source with no baseline blocks generation before the provider call.

How

  • Adds one Location-scoped SessionGenerate deep module that owns model resolution, transient request construction, hooks, and the single LLMClient.generate call.
  • Keeps SessionContext and durable SessionModelRequest unchanged; generation is not threaded through those interfaces.
  • Adds operation-neutral InstructionState.preview and SessionHistory.preview primitives for read-only state and settled model-visible history.
  • Reads ambient instruction sources before opening the history transaction, then folds stale or missing instruction_state in memory instead of repairing the rebuildable cache.
  • Uses time.completed, the canonical active-assistant predicate, to retain superseded settled assistants while excluding the current unsettled suffix.
  • Excludes pending input, advertises no tools, and forces tool choice to none independently of agent permissions.
  • Routes the internal SessionV2.generate method through the Session's Location.

Scope

This PR intentionally does not add Protocol, Server, SDK, plugin, TUI, or recap surfaces. It also does not add retries, compaction, stale-result suppression, configurable tool modes, public revisions, or a generalized provider-attempt/request-mode abstraction.

Testing

  • bun run test in packages/core: 1,323 passed, 6 skipped.
  • bun turbo typecheck --concurrency=3: 32 package tasks passed.
  • Focused generation, instruction-state, and runner tests: 138 passed.
  • Changed-file Oxlint and ast-grep checks passed.
  • Integration coverage verifies fresh private instructions, unavailable-source behavior, stale/missing cache read-through, hook transforms, headers/cache identity, settled-versus-active assistants, no tools, and exact before/after equality for aggregate sequence, events, messages, pending input, instruction blobs/cache, and the Session row.

Flow

sequenceDiagram
    participant Caller
    participant Session
    participant Generate as SessionGenerate
    participant History as SessionHistory.preview
    participant DB
    participant Hooks as Session Context Hooks
    participant LLM as LLMClient

    Caller->>Session: generate(sessionID, prompt)
    Session->>Generate: route through Session Location
    Generate->>Generate: select agent and resolve model
    Generate->>History: preview(sessionID, instructions)
    History->>DB: read settled active history and committed instructions
    History-->>Generate: initial + messages + private instruction update
    Generate->>Hooks: transform system/messages with no tools
    Generate->>LLM: generate(tool-free request)
    LLM-->>Caller: text
    Note over Session,DB: No Session writes
Loading

@kitlangton kitlangton merged commit e4a1683 into v2 Jul 16, 2026
8 of 12 checks passed
@kitlangton kitlangton deleted the session-generate branch July 16, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant