Skip to content
Merged

Dev #221

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ const plugin: Plugin = (async (ctx) => {
_input: unknown,
output: { system: string[] },
) => {
const systemText = output.system.join("\n")
const internalAgentSignatures = [
"You are a title generator",
"You are a helpful AI assistant tasked with summarizing conversations",
"Summarize what was done in this conversation",
]
if (internalAgentSignatures.some((sig) => systemText.includes(sig))) {
logger.info("Skipping DCP injection for internal agent")
state.isInternalAgent = true
return
}

// Reset flag for normal sessions
state.isInternalAgent = false

const discardEnabled = config.tools.discard.enabled
const extractEnabled = config.tools.extract.enabled

Expand Down
2 changes: 1 addition & 1 deletion lib/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function createChatMessageTransformHandler(
return async (input: {}, output: { messages: WithParts[] }) => {
await checkSession(client, state, logger, output.messages)

if (state.isSubAgent) {
if (state.isSubAgent || state.isInternalAgent) {
return
}

Expand Down
2 changes: 2 additions & 0 deletions lib/state/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export function createSessionState(): SessionState {
return {
sessionId: null,
isSubAgent: false,
isInternalAgent: false,
prune: {
toolIds: [],
},
Expand All @@ -61,6 +62,7 @@ export function createSessionState(): SessionState {
export function resetSessionState(state: SessionState): void {
state.sessionId = null
state.isSubAgent = false
state.isInternalAgent = false
state.prune = {
toolIds: [],
}
Expand Down
5 changes: 3 additions & 2 deletions lib/state/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface ToolParameterEntry {
parameters: any
status?: ToolStatus
error?: string
turn: number // Which turn (step-start count) this tool was called on
turn: number
}

export interface SessionStats {
Expand All @@ -27,11 +27,12 @@ export interface Prune {
export interface SessionState {
sessionId: string | null
isSubAgent: boolean
isInternalAgent: boolean
prune: Prune
stats: SessionStats
toolParameters: Map<string, ToolParameterEntry>
nudgeCounter: number
lastToolPrune: boolean
lastCompaction: number
currentTurn: number // Current turn count derived from step-start parts
currentTurn: number
}