fix: respect multi-turn-disabled flag in KnowledgeQA pipeline
When a custom agent has `MultiTurnEnabled=false`, `applyAgentOverridesToChatManage`
sets `chatManage.MaxRounds = 0` to signal "no history". Two pipeline plugins
mistreated this zero value as "use the global default" and silently re-loaded
session history into the LLM context:
- `PluginLoadHistory` fell back to `Conversation.MaxRounds` when
`chatManage.MaxRounds == 0`.
- `PluginQueryUnderstand.loadHistory` had the same fallback, and even when
`LOAD_HISTORY` was skipped it would re-populate `chatManage.History`,
leaking previous turns into rewrite, image analysis, and the final answer.
The RAG branch in `session_knowledge_qa` also added `LOAD_HISTORY`
unconditionally, unlike the pure-chat branch which guarded it with `hasHistory`.
This change:
- Treats `chatManage.MaxRounds <= 0` as an explicit disable in both plugins;
no fallback to global config.
- Makes the RAG pipeline consistent with the pure-chat path by gating
`LOAD_HISTORY` on `hasHistory`.
- Removes the duplicated `Current Time: {{current_time}}` line from
`agent_system_prompt.yaml`. The agent already receives a fresh
`<runtime_context><current_time>` block with each turn from
`observe.buildRuntimeContextBlock`, so the static placeholder was
redundant.
The ReAct agent path (`session_agent_qa`) already checked `MultiTurnEnabled`
directly and is not affected.
Closes #1479
This commit is contained in:
@@ -32,10 +32,19 @@ func (p *PluginLoadHistory) ActivationEvents() []types.EventType {
|
||||
func (p *PluginLoadHistory) OnEvent(ctx context.Context,
|
||||
eventType types.EventType, chatManage *types.ChatManage, next func() *PluginError,
|
||||
) *PluginError {
|
||||
maxRounds := p.config.Conversation.MaxRounds
|
||||
if chatManage.MaxRounds > 0 {
|
||||
maxRounds = chatManage.MaxRounds
|
||||
// chatManage.MaxRounds == 0 means multi-turn is explicitly disabled
|
||||
// (e.g. by a custom agent with MultiTurnEnabled=false). Skip loading so
|
||||
// history doesn't leak into the LLM context. We do NOT fall back to the
|
||||
// global Conversation.MaxRounds default here, otherwise the disable flag
|
||||
// would be silently overridden.
|
||||
if chatManage.MaxRounds <= 0 {
|
||||
pipelineInfo(ctx, "LoadHistory", "skipped", map[string]interface{}{
|
||||
"session_id": chatManage.SessionID,
|
||||
"reason": "multi_turn_disabled",
|
||||
})
|
||||
return next()
|
||||
}
|
||||
maxRounds := chatManage.MaxRounds
|
||||
|
||||
pipelineInfo(ctx, "LoadHistory", "input", map[string]interface{}{
|
||||
"session_id": chatManage.SessionID,
|
||||
|
||||
Reference in New Issue
Block a user