@@ -11,7 +11,6 @@ import {
1111 Message ,
1212 type ContentPart ,
1313} from "@opencode/ai"
14- import { Agent } from "@opencode/schema/agent"
1514import { SessionError } from "@opencode/schema/session-error"
1615import { Context , Effect , Layer , Stream } from "effect"
1716import { Bus } from "../bus.js"
@@ -97,7 +96,7 @@ export type Editor = {
9796
9897export type AutoInput = {
9998 readonly context : SessionContext . Loaded
100- readonly prepare : SessionModelRequest . Interface [ "prepare " ]
99+ readonly prepare : SessionModelRequest . Interface [ "compaction " ]
101100 /** Known overflow must recover from durable history, not submit the overflowing native window again. */
102101 readonly overflow ?: boolean
103102}
@@ -120,7 +119,7 @@ export type ManualInput = {
120119 SessionContext . Loaded & { readonly instructionUpdate : string } ,
121120 SessionRunnerModel . Error | AgentNotFoundError | Instructions . InitializationBlocked
122121 >
123- readonly prepare : SessionModelRequest . Interface [ "prepare " ]
122+ readonly prepare : SessionModelRequest . Interface [ "compaction " ]
124123}
125124
126125type ExecuteInput = AutoInput & {
@@ -428,22 +427,16 @@ export const layer = Layer.effect(
428427 messages,
429428 } )
430429 return input . prepare ( {
431- kind : "compaction" ,
432- scope : {
433- session : context . session ,
434- agentID : Agent . ID . make ( "compaction" ) ,
435- contextAgentID : context . agent . id ,
436- model : context . model ,
437- tools : context . tools ,
438- } ,
439- transcript : {
440- system : transcript . system ,
441- messages : [
442- ...transcript . messages ,
443- ...( input . instructionUpdate ? [ Message . system ( input . instructionUpdate ) ] : [ ] ) ,
444- ...prompt ,
445- ] ,
446- } ,
430+ session : context . session ,
431+ agent : context . agent . id ,
432+ model : context . model ,
433+ tools : context . tools ,
434+ system : transcript . system ,
435+ messages : [
436+ ...transcript . messages ,
437+ ...( input . instructionUpdate ? [ Message . system ( input . instructionUpdate ) ] : [ ] ) ,
438+ ...prompt ,
439+ ] ,
447440 webSocket,
448441 } )
449442 }
@@ -478,7 +471,7 @@ export const layer = Layer.effect(
478471 "Provider compaction requires the endpoint in provider/model settings, not a model.request rewrite" ,
479472 )
480473 const transient = SessionRunnerRetry . transient ( yield * SessionRunnerRetry . policy ( context . session . id ) , {
481- agent : Agent . ID . make ( "compaction" ) ,
474+ agent : context . agent . id ,
482475 model : context . model . ref ,
483476 hook : prepared . retry ,
484477 } )
@@ -580,7 +573,7 @@ export const layer = Layer.effect(
580573 ] )
581574 // Both requests share the retry allowance; rejected output never enters the reminder request.
582575 const transient = SessionRunnerRetry . transient ( yield * SessionRunnerRetry . policy ( context . session . id ) , {
583- agent : Agent . ID . make ( "compaction" ) ,
576+ agent : context . agent . id ,
584577 model : context . model . ref ,
585578 hook : prepared . retry ,
586579 } )
0 commit comments