Skip to content

Commit 6a3ffbe

Browse files
authored
Merge pull request #221 from Opencode-DCP/dev
Dev
2 parents a26121c + 20e1efa commit 6a3ffbe

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff 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

lib/hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

lib/state/state.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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 {
6162
export function resetSessionState(state: SessionState): void {
6263
state.sessionId = null
6364
state.isSubAgent = false
65+
state.isInternalAgent = false
6466
state.prune = {
6567
toolIds: [],
6668
}

lib/state/types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff 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

1818
export interface SessionStats {
@@ -27,11 +27,12 @@ export interface Prune {
2727
export 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
}

0 commit comments

Comments
 (0)