File tree Expand file tree Collapse file tree 3 files changed +12
-14
lines changed
Expand file tree Collapse file tree 3 files changed +12
-14
lines changed Original file line number Diff line number Diff line change @@ -14,11 +14,12 @@ export function createChatMessageTransformHandler(
1414 logger : Logger ,
1515 config : PluginConfig
1616) {
17- return async (
17+ return async (
1818 input : { } ,
1919 output : { messages : WithParts [ ] }
2020 ) => {
21- checkSession ( client , state , logger , output . messages ) ;
21+ await checkSession ( client , state , logger , output . messages )
22+
2223 if ( state . isSubAgent ) {
2324 return
2425 }
Original file line number Diff line number Diff line change @@ -4,12 +4,12 @@ import { loadSessionState } from "./persistence"
44import { getLastUserMessage } from "../messages/utils"
55import { isSubAgentSession } from "../utils"
66
7- export const checkSession = (
7+ export const checkSession = async (
88 client : any ,
99 state : SessionState ,
1010 logger : Logger ,
1111 messages : WithParts [ ]
12- ) => {
12+ ) : Promise < void > => {
1313
1414 const lastUserMessage = getLastUserMessage ( messages )
1515 if ( ! lastUserMessage ) {
@@ -20,14 +20,11 @@ export const checkSession = (
2020
2121 if ( state . sessionId === null || state . sessionId !== lastSessionId ) {
2222 logger . info ( `Session changed: ${ state . sessionId } -> ${ lastSessionId } ` )
23- ensureSessionInitialized (
24- client ,
25- state ,
26- lastSessionId ,
27- logger
28- ) . catch ( ( err ) => {
23+ try {
24+ await ensureSessionInitialized ( client , state , lastSessionId , logger )
25+ } catch ( err : any ) {
2926 logger . error ( "Failed to initialize session state" , { error : err . message } )
30- } )
27+ }
3128 }
3229}
3330
Original file line number Diff line number Diff line change @@ -6,8 +6,6 @@ const MAX_TOOL_CACHE_SIZE = 500
66
77/**
88 * Sync tool parameters from OpenCode's session.messages() API.
9- * This is the single source of truth for tool parameters, replacing
10- * format-specific parsing from LLM API requests.
119 */
1210export async function syncToolCache (
1311 state : SessionState ,
@@ -24,6 +22,8 @@ export async function syncToolCache(
2422 continue
2523 }
2624
25+ const alreadyPruned = state . prune . toolIds . includes ( part . callID )
26+
2727 state . toolParameters . set (
2828 part . callID ,
2929 {
@@ -35,7 +35,7 @@ export async function syncToolCache(
3535 }
3636 )
3737
38- if ( ! config . strategies . pruneTool . protectedTools . includes ( part . tool ) ) {
38+ if ( ! alreadyPruned && ! config . strategies . pruneTool . protectedTools . includes ( part . tool ) ) {
3939 state . nudgeCounter ++
4040 }
4141
You can’t perform that action at this time.
0 commit comments