Skip to content
Cisco AI Defense logo
CiscoAI Security

Multi-turn context — DefenseClaw

Overview

internal/gateway/context_tracker.go::ContextTracker is a bounded in-memory conversation buffer. It is useful support code for multi-turn analysis, but the inspected configuration does not expose a guardrail.multi_turn block and the guardrail pages should not document one as a user-facing setting.

Bounds

LimitDefaultSource
Turns per session10defaultMaxTurns
Sessions200defaultMaxSessions
Session TTL30mdefaultSessionTTL
Stale sweep cadenceEvery 50 Record callsstaleSweepFrequency

Zero or negative constructor arguments use the defaults. SetTTL can override TTL in code; a non-positive TTL disables TTL-based eviction and leaves max-session pruning as the bound.

Available operations

MethodBehavior
Record(sessionKey, role, content)Appends a message, drops empty inputs, trims the session to max turns, and prunes stale or oldest sessions as needed.
RecentMessages(sessionKey, n)Returns up to the most recent n messages as ChatMessage values.
HasRepeatedInjection(sessionKey, threshold)Counts repeated injection-like phrases in the stored window.
SessionCount()Returns current session count.

What not to claim

Unsupported claimSource-backed correction
Dedicated multi-turn detector in GuardrailInspectorThe inspected guardrail strategy functions operate on the provided content/messages; ContextTracker is a separate buffer type.
Tunable max_history in configNot present in GuardrailConfig.
Extra judge token tablesNo source-backed token accounting exists for this page.
Cache bypass for multi-turn verdictsThe judge cache keys judge content; multi-turn cache policy is not configured here.

Related