File tree Expand file tree Collapse file tree 4 files changed +21
-3
lines changed
Expand file tree Collapse file tree 4 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,21 @@ const plugin: Plugin = (async (ctx) => {
3030 _input : unknown ,
3131 output : { system : string [ ] } ,
3232 ) => {
33+ const systemText = output . system . join ( "\n" )
34+ const internalAgentSignatures = [
35+ "You are a title generator" ,
36+ "You are a helpful AI assistant tasked with summarizing conversations" ,
37+ "Summarize what was done in this conversation" ,
38+ ]
39+ if ( internalAgentSignatures . some ( ( sig ) => systemText . includes ( sig ) ) ) {
40+ logger . info ( "Skipping DCP injection for internal agent" )
41+ state . isInternalAgent = true
42+ return
43+ }
44+
45+ // Reset flag for normal sessions
46+ state . isInternalAgent = false
47+
3348 const discardEnabled = config . tools . discard . enabled
3449 const extractEnabled = config . tools . extract . enabled
3550
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ export function createChatMessageTransformHandler(
1515 return async ( input : { } , output : { messages : WithParts [ ] } ) => {
1616 await checkSession ( client , state , logger , output . messages )
1717
18- if ( state . isSubAgent ) {
18+ if ( state . isSubAgent || state . isInternalAgent ) {
1919 return
2020 }
2121
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ export function createSessionState(): SessionState {
4343 return {
4444 sessionId : null ,
4545 isSubAgent : false ,
46+ isInternalAgent : false ,
4647 prune : {
4748 toolIds : [ ] ,
4849 } ,
@@ -61,6 +62,7 @@ export function createSessionState(): SessionState {
6162export function resetSessionState ( state : SessionState ) : void {
6263 state . sessionId = null
6364 state . isSubAgent = false
65+ state . isInternalAgent = false
6466 state . prune = {
6567 toolIds : [ ] ,
6668 }
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ export interface ToolParameterEntry {
1212 parameters : any
1313 status ?: ToolStatus
1414 error ?: string
15- turn : number // Which turn (step-start count) this tool was called on
15+ turn : number
1616}
1717
1818export interface SessionStats {
@@ -27,11 +27,12 @@ export interface Prune {
2727export interface SessionState {
2828 sessionId : string | null
2929 isSubAgent : boolean
30+ isInternalAgent : boolean
3031 prune : Prune
3132 stats : SessionStats
3233 toolParameters : Map < string , ToolParameterEntry >
3334 nudgeCounter : number
3435 lastToolPrune : boolean
3536 lastCompaction : number
36- currentTurn : number // Current turn count derived from step-start parts
37+ currentTurn : number
3738}
You can’t perform that action at this time.
0 commit comments