refactor(plugin): simplify session request hook
This commit is contained in:
parent
7edaa05869
commit
a84babca73
3 changed files with 11 additions and 11 deletions
|
|
@ -4,6 +4,7 @@ import { LLMError, LLMEvent, isContextOverflowFailure, type ProviderErrorEvent }
|
|||
import { SessionError } from "@opencode-ai/schema/session-error"
|
||||
import { Cause, Effect, Exit, Fiber, FiberSet, Layer, Option, Semaphore, Stream } from "effect"
|
||||
import { Database } from "../../database/database"
|
||||
import { AgentV2 } from "../../agent"
|
||||
import { EventV2 } from "../../event"
|
||||
import { PermissionV2 } from "../../permission"
|
||||
import { QuestionTool } from "../../tool/question"
|
||||
|
|
@ -40,6 +41,7 @@ const layer = Layer.effect(
|
|||
const db = (yield* Database.Service).db
|
||||
const compaction = yield* SessionCompaction.Service
|
||||
const title = yield* SessionTitle.Service
|
||||
const agents = yield* AgentV2.Service
|
||||
// Title generation is a side effect of the first step; it must not delay step continuation.
|
||||
// Tracked per process so repeated wakes before the second user message arrives don't
|
||||
// re-fire a redundant LLM call; `SessionTitle` itself is idempotent based on durable history.
|
||||
|
|
@ -415,8 +417,10 @@ const layer = Layer.effect(
|
|||
Effect.gen(function* () {
|
||||
const compacted = yield* restore(
|
||||
Effect.gen(function* () {
|
||||
const agent = yield* agents.select(session.agent)
|
||||
return yield* compaction.compactManual({
|
||||
session,
|
||||
agent: agent.id,
|
||||
messages: yield* store.context(sessionID),
|
||||
inputID: pending.id,
|
||||
})
|
||||
|
|
@ -501,6 +505,7 @@ export const node = makeLocationNode({
|
|||
SessionStore.node,
|
||||
SessionCompaction.node,
|
||||
SessionTitle.node,
|
||||
AgentV2.node,
|
||||
Snapshot.node,
|
||||
Database.node,
|
||||
],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue